@@ -5,14 +5,14 @@ fn main() {
55    let  target = env:: var ( "TARGET" ) . expect ( "TARGET was not set" ) ; 
66
77    if  cfg ! ( feature = "llvm-libunwind" )  &&
8-         ( target. contains ( "linux" )  ||
8+         ( ( target. contains ( "linux" )  && !target . contains ( "musl" ) )  ||
99         target. contains ( "fuchsia" ) )  { 
1010        // Build the unwinding from libunwind C/C++ source code. 
11-         #[ cfg( feature = "llvm-libunwind" ) ]  
1211        llvm_libunwind:: compile ( ) ; 
1312    }  else  if  target. contains ( "linux" )  { 
1413        if  target. contains ( "musl" )  { 
15-             // musl is handled in lib.rs 
14+             // linking for musl is handled in lib.rs 
15+             llvm_libunwind:: compile ( ) ; 
1616        }  else  if  !target. contains ( "android" )  { 
1717            println ! ( "cargo:rustc-link-lib=gcc_s" ) ; 
1818        } 
@@ -44,7 +44,6 @@ fn main() {
4444    } 
4545} 
4646
47- #[ cfg( feature = "llvm-libunwind" ) ]  
4847mod  llvm_libunwind { 
4948    use  std:: env; 
5049    use  std:: path:: Path ; 
@@ -96,6 +95,15 @@ mod llvm_libunwind {
9695            cfg. file ( root. join ( "src" ) . join ( src) ) ; 
9796        } 
9897
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+ 
99107        cfg. compile ( "unwind" ) ; 
100108    } 
101109} 
0 commit comments