9
9
//! ensure that they're always in place if needed.
10
10
11
11
use std:: env;
12
+ use std:: env:: consts:: EXE_EXTENSION ;
12
13
use std:: ffi:: OsString ;
13
14
use std:: fs:: { self , File } ;
14
15
use std:: io;
@@ -252,8 +253,14 @@ impl Step for Llvm {
252
253
// FIXME: if the llvm root for the build triple is overridden then we
253
254
// should use llvm-tblgen from there, also should verify that it
254
255
// actually exists most of the time in normal installs of LLVM.
255
- let host = builder. llvm_out ( builder. config . build ) . join ( "bin/llvm-tblgen" ) ;
256
- cfg. define ( "CMAKE_CROSSCOMPILING" , "True" ) . define ( "LLVM_TABLEGEN" , & host) ;
256
+ let host_bin = builder. llvm_out ( builder. config . build ) . join ( "bin" ) ;
257
+ cfg. define ( "CMAKE_CROSSCOMPILING" , "True" ) ;
258
+ cfg. define ( "LLVM_TABLEGEN" , host_bin. join ( "llvm-tblgen" ) . with_extension ( EXE_EXTENSION ) ) ;
259
+ cfg. define ( "LLVM_NM" , host_bin. join ( "llvm-nm" ) . with_extension ( EXE_EXTENSION ) ) ;
260
+ cfg. define (
261
+ "LLVM_CONFIG_PATH" ,
262
+ host_bin. join ( "llvm-config" ) . with_extension ( EXE_EXTENSION ) ,
263
+ ) ;
257
264
258
265
if target. contains ( "netbsd" ) {
259
266
cfg. define ( "CMAKE_SYSTEM_NAME" , "NetBSD" ) ;
@@ -262,8 +269,6 @@ impl Step for Llvm {
262
269
} else if target. contains ( "windows" ) {
263
270
cfg. define ( "CMAKE_SYSTEM_NAME" , "Windows" ) ;
264
271
}
265
-
266
- cfg. define ( "LLVM_NATIVE_BUILD" , builder. llvm_out ( builder. config . build ) . join ( "build" ) ) ;
267
272
}
268
273
269
274
if let Some ( ref suffix) = builder. config . llvm_version_suffix {
@@ -431,6 +436,9 @@ fn configure_cmake(
431
436
cflags. push_str ( " -miphoneos-version-min=10.0" ) ;
432
437
}
433
438
}
439
+ if builder. config . llvm_clang_cl . is_some ( ) {
440
+ cflags. push_str ( & format ! ( " --target={}" , target) )
441
+ }
434
442
cfg. define ( "CMAKE_C_FLAGS" , cflags) ;
435
443
let mut cxxflags = builder. cflags ( target, GitRepo :: Llvm ) . join ( " " ) ;
436
444
if builder. config . llvm_static_stdcpp && !target. contains ( "msvc" ) && !target. contains ( "netbsd" ) {
@@ -439,6 +447,9 @@ fn configure_cmake(
439
447
if let Some ( ref s) = builder. config . llvm_cxxflags {
440
448
cxxflags. push_str ( & format ! ( " {}" , s) ) ;
441
449
}
450
+ if builder. config . llvm_clang_cl . is_some ( ) {
451
+ cxxflags. push_str ( & format ! ( " --target={}" , target) )
452
+ }
442
453
cfg. define ( "CMAKE_CXX_FLAGS" , cxxflags) ;
443
454
if let Some ( ar) = builder. ar ( target) {
444
455
if ar. is_absolute ( ) {
@@ -484,7 +495,7 @@ impl Step for Lld {
484
495
run. builder . ensure ( Lld { target : run. target } ) ;
485
496
}
486
497
487
- /// Compile LLVM for `target`.
498
+ /// Compile LLD for `target`.
488
499
fn run ( self , builder : & Builder < ' _ > ) -> PathBuf {
489
500
if builder. config . dry_run {
490
501
return PathBuf :: from ( "lld-out-dir-test-gen" ) ;
@@ -521,6 +532,7 @@ impl Step for Lld {
521
532
// can't build on a system where your paths require `\` on Windows, but
522
533
// there's probably a lot of reasons you can't do that other than this.
523
534
let llvm_config_shim = env:: current_exe ( ) . unwrap ( ) . with_file_name ( "llvm-config-wrapper" ) ;
535
+
524
536
cfg. out_dir ( & out_dir)
525
537
. profile ( "Release" )
526
538
. env ( "LLVM_CONFIG_REAL" , & llvm_config)
@@ -543,7 +555,10 @@ impl Step for Lld {
543
555
if target != builder. config . build {
544
556
cfg. env ( "LLVM_CONFIG_SHIM_REPLACE" , & builder. config . build )
545
557
. env ( "LLVM_CONFIG_SHIM_REPLACE_WITH" , & target)
546
- . define ( "LLVM_TABLEGEN_EXE" , llvm_config. with_file_name ( "llvm-tblgen" ) ) ;
558
+ . define (
559
+ "LLVM_TABLEGEN_EXE" ,
560
+ llvm_config. with_file_name ( "llvm-tblgen" ) . with_extension ( EXE_EXTENSION ) ,
561
+ ) ;
547
562
}
548
563
549
564
// Explicitly set C++ standard, because upstream doesn't do so
@@ -595,8 +610,8 @@ impl Step for TestHelpers {
595
610
}
596
611
597
612
// We may have found various cross-compilers a little differently due to our
598
- // extra configuration, so inform gcc of these compilers. Note, though, that
599
- // on MSVC we still need gcc 's detection of env vars (ugh).
613
+ // extra configuration, so inform cc of these compilers. Note, though, that
614
+ // on MSVC we still need cc 's detection of env vars (ugh).
600
615
if !target. contains ( "msvc" ) {
601
616
if let Some ( ar) = builder. ar ( target) {
602
617
cfg. archiver ( ar) ;
0 commit comments