@@ -29,6 +29,7 @@ use build_helper::{output, mtime, up_to_date};
29
29
use filetime:: FileTime ;
30
30
use serde_json;
31
31
32
+ use crate :: dist;
32
33
use crate :: util:: { exe, libdir, is_dylib} ;
33
34
use crate :: { Compiler , Mode , GitRepo } ;
34
35
use crate :: native;
@@ -114,7 +115,6 @@ impl Step for Std {
114
115
& compiler. host, target) ) ;
115
116
run_cargo ( builder,
116
117
& mut cargo,
117
- vec ! [ ] ,
118
118
& libstd_stamp ( builder, compiler, target) ,
119
119
false ) ;
120
120
@@ -375,7 +375,6 @@ impl Step for Test {
375
375
& compiler. host, target) ) ;
376
376
run_cargo ( builder,
377
377
& mut cargo,
378
- vec ! [ ] ,
379
378
& libtest_stamp ( builder, compiler, target) ,
380
379
false ) ;
381
380
@@ -503,7 +502,6 @@ impl Step for Rustc {
503
502
compiler. stage, & compiler. host, target) ) ;
504
503
run_cargo ( builder,
505
504
& mut cargo,
506
- vec ! [ ] ,
507
505
& librustc_stamp ( builder, compiler, target) ,
508
506
false ) ;
509
507
@@ -646,47 +644,18 @@ impl Step for CodegenBackend {
646
644
647
645
let out_dir = builder. cargo_out ( compiler, Mode :: Codegen , target) ;
648
646
649
- let mut cargo = builder. cargo ( compiler, Mode :: Codegen , target, "rustc " ) ;
647
+ let mut cargo = builder. cargo ( compiler, Mode :: Codegen , target, "build " ) ;
650
648
cargo. arg ( "--manifest-path" )
651
649
. arg ( builder. src . join ( "src/librustc_codegen_llvm/Cargo.toml" ) ) ;
652
650
rustc_cargo_env ( builder, & mut cargo) ;
653
651
654
652
let features = build_codegen_backend ( & builder, & mut cargo, & compiler, target, backend) ;
655
653
656
- let mut cargo_tails_args = vec ! [ ] ;
657
-
658
- if builder. config . llvm_thin_lto {
659
- cargo_tails_args. push ( "--" . to_string ( ) ) ;
660
-
661
- let num_jobs = builder. jobs ( ) ;
662
-
663
- if !target. contains ( "msvc" ) {
664
- // Here we assume that the linker is clang. If it's not, there'll
665
- // be linker errors.
666
- cargo_tails_args. push ( "-Clink-arg=-fuse-ld=lld" . to_string ( ) ) ;
667
- cargo_tails_args. push ( "-Clink-arg=-flto=thin" . to_string ( ) ) ;
668
-
669
- if builder. config . llvm_optimize {
670
- cargo_tails_args. push ( "-Clink-arg=-O2" . to_string ( ) ) ;
671
- }
672
-
673
- // Let's make LLD respect the `-j` option.
674
- let num_jobs_arg = format ! ( "-Clink-arg=-Wl,--thinlto-jobs={}" , num_jobs) ;
675
- cargo_tails_args. push ( num_jobs_arg) ;
676
- } else {
677
- // Here we assume that the linker is lld-link.exe. lld-link.exe
678
- // does not need the extra arguments except for num_jobs
679
- let num_jobs_arg = format ! ( "-Clink-arg=/opt:lldltojobs={}" , num_jobs) ;
680
- cargo_tails_args. push ( num_jobs_arg) ;
681
- }
682
- }
683
-
684
654
let tmp_stamp = out_dir. join ( ".tmp.stamp" ) ;
685
655
686
656
let _folder = builder. fold_output ( || format ! ( "stage{}-rustc_codegen_llvm" , compiler. stage) ) ;
687
657
let files = run_cargo ( builder,
688
658
cargo. arg ( "--features" ) . arg ( features) ,
689
- cargo_tails_args,
690
659
& tmp_stamp,
691
660
false ) ;
692
661
if builder. config . dry_run {
@@ -759,7 +728,9 @@ pub fn build_codegen_backend(builder: &Builder,
759
728
"libstdc++.a" ) ;
760
729
cargo. env ( "LLVM_STATIC_STDCPP" , file) ;
761
730
}
762
- if builder. config . llvm_link_shared {
731
+ if builder. config . llvm_link_shared ||
732
+ ( builder. config . llvm_thin_lto && backend != "emscripten" )
733
+ {
763
734
cargo. env ( "LLVM_LINK_SHARED" , "1" ) ;
764
735
}
765
736
}
@@ -999,6 +970,8 @@ impl Step for Assemble {
999
970
copy_lld_to_sysroot ( builder, target_compiler, & lld_install) ;
1000
971
}
1001
972
973
+ dist:: maybe_install_llvm_dylib ( builder, target_compiler. host , & sysroot) ;
974
+
1002
975
// Link the compiler binary itself into place
1003
976
let out_dir = builder. cargo_out ( build_compiler, Mode :: Rustc , host) ;
1004
977
let rustc = out_dir. join ( exe ( "rustc_binary" , & * host) ) ;
@@ -1025,7 +998,6 @@ pub fn add_to_sysroot(builder: &Builder, sysroot_dst: &Path, stamp: &Path) {
1025
998
1026
999
pub fn run_cargo ( builder : & Builder ,
1027
1000
cargo : & mut Command ,
1028
- tail_args : Vec < String > ,
1029
1001
stamp : & Path ,
1030
1002
is_check : bool )
1031
1003
-> Vec < PathBuf >
@@ -1048,7 +1020,7 @@ pub fn run_cargo(builder: &Builder,
1048
1020
// files we need to probe for later.
1049
1021
let mut deps = Vec :: new ( ) ;
1050
1022
let mut toplevel = Vec :: new ( ) ;
1051
- let ok = stream_cargo ( builder, cargo, tail_args , & mut |msg| {
1023
+ let ok = stream_cargo ( builder, cargo, & mut |msg| {
1052
1024
let filenames = match msg {
1053
1025
CargoMessage :: CompilerArtifact { filenames, .. } => filenames,
1054
1026
_ => return ,
@@ -1173,7 +1145,6 @@ pub fn run_cargo(builder: &Builder,
1173
1145
pub fn stream_cargo (
1174
1146
builder : & Builder ,
1175
1147
cargo : & mut Command ,
1176
- tail_args : Vec < String > ,
1177
1148
cb : & mut dyn FnMut ( CargoMessage ) ,
1178
1149
) -> bool {
1179
1150
if builder. config . dry_run {
@@ -1184,10 +1155,6 @@ pub fn stream_cargo(
1184
1155
cargo. arg ( "--message-format" ) . arg ( "json" )
1185
1156
. stdout ( Stdio :: piped ( ) ) ;
1186
1157
1187
- for arg in tail_args {
1188
- cargo. arg ( arg) ;
1189
- }
1190
-
1191
1158
builder. verbose ( & format ! ( "running: {:?}" , cargo) ) ;
1192
1159
let mut child = match cargo. spawn ( ) {
1193
1160
Ok ( child) => child,
0 commit comments