mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
Use libunwind from llvm-project submodule for musl targets
This commit is contained in:
parent
082cf2f9d1
commit
5941acd80f
@ -202,10 +202,6 @@ pub fn check(build: &mut Build) {
|
|||||||
panic!("couldn't find libc.a in musl dir: {}",
|
panic!("couldn't find libc.a in musl dir: {}",
|
||||||
root.join("lib").display());
|
root.join("lib").display());
|
||||||
}
|
}
|
||||||
if fs::metadata(root.join("lib/libunwind.a")).is_err() {
|
|
||||||
panic!("couldn't find libunwind.a in musl dir: {}",
|
|
||||||
root.join("lib").display());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
panic!("when targeting MUSL either the rust.musl-root \
|
panic!("when targeting MUSL either the rust.musl-root \
|
||||||
|
@ -54,29 +54,3 @@ if [ "$REPLACE_CC" = "1" ]; then
|
|||||||
ln -s $TARGET-g++ /usr/local/bin/$exec
|
ln -s $TARGET-g++ /usr/local/bin/$exec
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export CC=$TARGET-gcc
|
|
||||||
export CXX=$TARGET-g++
|
|
||||||
|
|
||||||
LLVM=70
|
|
||||||
|
|
||||||
# may have been downloaded in a previous run
|
|
||||||
if [ ! -d libunwind-release_$LLVM ]; then
|
|
||||||
curl -L https://github.com/llvm-mirror/llvm/archive/release_$LLVM.tar.gz | tar xzf -
|
|
||||||
curl -L https://github.com/llvm-mirror/libunwind/archive/release_$LLVM.tar.gz | tar xzf -
|
|
||||||
fi
|
|
||||||
|
|
||||||
# fixme(mati865): Replace it with https://github.com/rust-lang/rust/pull/59089
|
|
||||||
mkdir libunwind-build
|
|
||||||
cd libunwind-build
|
|
||||||
cmake ../libunwind-release_$LLVM \
|
|
||||||
-DLLVM_PATH=/build/llvm-release_$LLVM \
|
|
||||||
-DLIBUNWIND_ENABLE_SHARED=0 \
|
|
||||||
-DCMAKE_C_COMPILER=$CC \
|
|
||||||
-DCMAKE_CXX_COMPILER=$CXX \
|
|
||||||
-DCMAKE_C_FLAGS="$CFLAGS" \
|
|
||||||
-DCMAKE_CXX_FLAGS="$CXXFLAGS"
|
|
||||||
|
|
||||||
hide_output make -j$(nproc)
|
|
||||||
cp lib/libunwind.a $OUTPUT/$TARGET/lib
|
|
||||||
cd - && rm -rf libunwind-build
|
|
||||||
|
@ -20,6 +20,8 @@ exit 1
|
|||||||
TAG=$1
|
TAG=$1
|
||||||
shift
|
shift
|
||||||
|
|
||||||
|
# Ancient binutils versions don't understand debug symbols produced by more recent tools.
|
||||||
|
# Apparently applying `-fPIC` everywhere allows them to link successfully.
|
||||||
export CFLAGS="-fPIC $CFLAGS"
|
export CFLAGS="-fPIC $CFLAGS"
|
||||||
|
|
||||||
MUSL=musl-1.1.22
|
MUSL=musl-1.1.22
|
||||||
@ -38,27 +40,3 @@ else
|
|||||||
fi
|
fi
|
||||||
hide_output make install
|
hide_output make install
|
||||||
hide_output make clean
|
hide_output make clean
|
||||||
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
LLVM=70
|
|
||||||
|
|
||||||
# may have been downloaded in a previous run
|
|
||||||
if [ ! -d libunwind-release_$LLVM ]; then
|
|
||||||
curl -L https://github.com/llvm-mirror/llvm/archive/release_$LLVM.tar.gz | tar xzf -
|
|
||||||
curl -L https://github.com/llvm-mirror/libunwind/archive/release_$LLVM.tar.gz | tar xzf -
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir libunwind-build
|
|
||||||
cd libunwind-build
|
|
||||||
cmake ../libunwind-release_$LLVM \
|
|
||||||
-DLLVM_PATH=/build/llvm-release_$LLVM \
|
|
||||||
-DLIBUNWIND_ENABLE_SHARED=0 \
|
|
||||||
-DCMAKE_C_COMPILER=$CC \
|
|
||||||
-DCMAKE_CXX_COMPILER=$CXX \
|
|
||||||
-DCMAKE_C_FLAGS="$CFLAGS" \
|
|
||||||
-DCMAKE_CXX_FLAGS="$CXXFLAGS"
|
|
||||||
|
|
||||||
hide_output make -j$(nproc)
|
|
||||||
cp lib/libunwind.a /musl-$TAG/lib
|
|
||||||
cd ../ && rm -rf libunwind-build
|
|
||||||
|
@ -22,7 +22,7 @@ compiler_builtins = "0.1.0"
|
|||||||
cfg-if = "0.1.8"
|
cfg-if = "0.1.8"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
cc = { optional = true, version = "1.0.1" }
|
cc = { version = "1.0.1" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
llvm-libunwind = ["cc"]
|
llvm-libunwind = []
|
||||||
|
@ -5,14 +5,14 @@ fn main() {
|
|||||||
let target = env::var("TARGET").expect("TARGET was not set");
|
let target = env::var("TARGET").expect("TARGET was not set");
|
||||||
|
|
||||||
if cfg!(feature = "llvm-libunwind") &&
|
if cfg!(feature = "llvm-libunwind") &&
|
||||||
(target.contains("linux") ||
|
((target.contains("linux") && !target.contains("musl")) ||
|
||||||
target.contains("fuchsia")) {
|
target.contains("fuchsia")) {
|
||||||
// Build the unwinding from libunwind C/C++ source code.
|
// Build the unwinding from libunwind C/C++ source code.
|
||||||
#[cfg(feature = "llvm-libunwind")]
|
|
||||||
llvm_libunwind::compile();
|
llvm_libunwind::compile();
|
||||||
} else if target.contains("linux") {
|
} else if target.contains("linux") {
|
||||||
if target.contains("musl") {
|
if target.contains("musl") {
|
||||||
// musl is handled in lib.rs
|
// linking for musl is handled in lib.rs
|
||||||
|
llvm_libunwind::compile();
|
||||||
} else if !target.contains("android") {
|
} else if !target.contains("android") {
|
||||||
println!("cargo:rustc-link-lib=gcc_s");
|
println!("cargo:rustc-link-lib=gcc_s");
|
||||||
}
|
}
|
||||||
@ -44,7 +44,6 @@ fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "llvm-libunwind")]
|
|
||||||
mod llvm_libunwind {
|
mod llvm_libunwind {
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
@ -96,6 +95,15 @@ mod llvm_libunwind {
|
|||||||
cfg.file(root.join("src").join(src));
|
cfg.file(root.join("src").join(src));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if target_env == "musl" {
|
||||||
|
// use the same C compiler command to compile C++ code so we do not need to setup the
|
||||||
|
// C++ compiler env variables on the builders
|
||||||
|
cfg.cpp(false);
|
||||||
|
// linking for musl is handled in lib.rs
|
||||||
|
cfg.cargo_metadata(false);
|
||||||
|
println!("cargo:rustc-link-search=native={}", env::var("OUT_DIR").unwrap());
|
||||||
|
}
|
||||||
|
|
||||||
cfg.compile("unwind");
|
cfg.compile("unwind");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user