@@ -2,21 +2,20 @@ use std::env;
2
2
use std:: path:: { Path , PathBuf } ;
3
3
use std:: process:: Command ;
4
4
5
- use build_helper:: output;
5
+ use build_helper:: { output, tracked_env_var_os } ;
6
6
7
7
fn detect_llvm_link ( ) -> ( & ' static str , & ' static str ) {
8
8
// Force the link mode we want, preferring static by default, but
9
9
// possibly overridden by `configure --enable-llvm-link-shared`.
10
- if env :: var_os ( "LLVM_LINK_SHARED" ) . is_some ( ) {
10
+ if tracked_env_var_os ( "LLVM_LINK_SHARED" ) . is_some ( ) {
11
11
( "dylib" , "--link-shared" )
12
12
} else {
13
13
( "static" , "--link-static" )
14
14
}
15
15
}
16
16
17
17
fn main ( ) {
18
- println ! ( "cargo:rerun-if-env-changed=RUST_CHECK" ) ;
19
- if env:: var_os ( "RUST_CHECK" ) . is_some ( ) {
18
+ if tracked_env_var_os ( "RUST_CHECK" ) . is_some ( ) {
20
19
// If we're just running `check`, there's no need for LLVM to be built.
21
20
return ;
22
21
}
@@ -25,8 +24,8 @@ fn main() {
25
24
26
25
let target = env:: var ( "TARGET" ) . expect ( "TARGET was not set" ) ;
27
26
let llvm_config =
28
- env :: var_os ( "LLVM_CONFIG" ) . map ( |x| Some ( PathBuf :: from ( x) ) ) . unwrap_or_else ( || {
29
- if let Some ( dir) = env :: var_os ( "CARGO_TARGET_DIR" ) . map ( PathBuf :: from) {
27
+ tracked_env_var_os ( "LLVM_CONFIG" ) . map ( |x| Some ( PathBuf :: from ( x) ) ) . unwrap_or_else ( || {
28
+ if let Some ( dir) = tracked_env_var_os ( "CARGO_TARGET_DIR" ) . map ( PathBuf :: from) {
30
29
let to_test = dir
31
30
. parent ( )
32
31
. unwrap ( )
@@ -46,8 +45,6 @@ fn main() {
46
45
}
47
46
let llvm_config = llvm_config. unwrap_or_else ( || PathBuf :: from ( "llvm-config" ) ) ;
48
47
49
- println ! ( "cargo:rerun-if-env-changed=LLVM_CONFIG" ) ;
50
-
51
48
// Test whether we're cross-compiling LLVM. This is a pretty rare case
52
49
// currently where we're producing an LLVM for a different platform than
53
50
// what this build script is currently running on.
@@ -163,12 +160,11 @@ fn main() {
163
160
cfg. define ( & flag, None ) ;
164
161
}
165
162
166
- println ! ( "cargo:rerun-if-env-changed=LLVM_RUSTLLVM" ) ;
167
- if env:: var_os ( "LLVM_RUSTLLVM" ) . is_some ( ) {
163
+ if tracked_env_var_os ( "LLVM_RUSTLLVM" ) . is_some ( ) {
168
164
cfg. define ( "LLVM_RUSTLLVM" , None ) ;
169
165
}
170
166
171
- if env :: var_os ( "LLVM_NDEBUG" ) . is_some ( ) {
167
+ if tracked_env_var_os ( "LLVM_NDEBUG" ) . is_some ( ) {
172
168
cfg. define ( "NDEBUG" , None ) ;
173
169
cfg. debug ( false ) ;
174
170
}
@@ -255,7 +251,7 @@ fn main() {
255
251
// librustc_llvm, for example when using static libc++, we may need to
256
252
// manually specify the library search path and -ldl -lpthread as link
257
253
// dependencies.
258
- let llvm_linker_flags = env :: var_os ( "LLVM_LINKER_FLAGS" ) ;
254
+ let llvm_linker_flags = tracked_env_var_os ( "LLVM_LINKER_FLAGS" ) ;
259
255
if let Some ( s) = llvm_linker_flags {
260
256
for lib in s. into_string ( ) . unwrap ( ) . split_whitespace ( ) {
261
257
if lib. starts_with ( "-l" ) {
@@ -266,8 +262,8 @@ fn main() {
266
262
}
267
263
}
268
264
269
- let llvm_static_stdcpp = env :: var_os ( "LLVM_STATIC_STDCPP" ) ;
270
- let llvm_use_libcxx = env :: var_os ( "LLVM_USE_LIBCXX" ) ;
265
+ let llvm_static_stdcpp = tracked_env_var_os ( "LLVM_STATIC_STDCPP" ) ;
266
+ let llvm_use_libcxx = tracked_env_var_os ( "LLVM_USE_LIBCXX" ) ;
271
267
272
268
let stdcppname = if target. contains ( "openbsd" ) {
273
269
if target. contains ( "sparc64" ) { "estdc++" } else { "c++" }
0 commit comments