@@ -5,14 +5,14 @@ fn main() {
5
5
let target = env:: var ( "TARGET" ) . expect ( "TARGET was not set" ) ;
6
6
7
7
if cfg ! ( feature = "llvm-libunwind" ) &&
8
- ( target. contains ( "linux" ) ||
8
+ ( ( target. contains ( "linux" ) && !target . contains ( "musl" ) ) ||
9
9
target. contains ( "fuchsia" ) ) {
10
10
// Build the unwinding from libunwind C/C++ source code.
11
- #[ cfg( feature = "llvm-libunwind" ) ]
12
11
llvm_libunwind:: compile ( ) ;
13
12
} else if target. contains ( "linux" ) {
14
13
if target. contains ( "musl" ) {
15
- // musl is handled in lib.rs
14
+ // linking for musl is handled in lib.rs
15
+ llvm_libunwind:: compile ( ) ;
16
16
} else if !target. contains ( "android" ) {
17
17
println ! ( "cargo:rustc-link-lib=gcc_s" ) ;
18
18
}
@@ -44,7 +44,6 @@ fn main() {
44
44
}
45
45
}
46
46
47
- #[ cfg( feature = "llvm-libunwind" ) ]
48
47
mod llvm_libunwind {
49
48
use std:: env;
50
49
use std:: path:: Path ;
@@ -96,6 +95,15 @@ mod llvm_libunwind {
96
95
cfg. file ( root. join ( "src" ) . join ( src) ) ;
97
96
}
98
97
98
+ if target_env == "musl" {
99
+ // use the same C compiler command to compile C++ code so we do not need to setup the
100
+ // C++ compiler env variables on the builders
101
+ cfg. cpp ( false ) ;
102
+ // linking for musl is handled in lib.rs
103
+ cfg. cargo_metadata ( false ) ;
104
+ println ! ( "cargo:rustc-link-search=native={}" , env:: var( "OUT_DIR" ) . unwrap( ) ) ;
105
+ }
106
+
99
107
cfg. compile ( "unwind" ) ;
100
108
}
101
109
}
0 commit comments