@@ -19,6 +19,7 @@ use build_helper::{output, mtime, up_to_date};
19
19
use filetime:: FileTime ;
20
20
use serde_json;
21
21
22
+ use crate :: dist;
22
23
use crate :: util:: { exe, libdir, is_dylib} ;
23
24
use crate :: { Compiler , Mode , GitRepo } ;
24
25
use crate :: native;
@@ -104,7 +105,6 @@ impl Step for Std {
104
105
& compiler. host, target) ) ;
105
106
run_cargo ( builder,
106
107
& mut cargo,
107
- vec ! [ ] ,
108
108
& libstd_stamp ( builder, compiler, target) ,
109
109
false ) ;
110
110
@@ -365,7 +365,6 @@ impl Step for Test {
365
365
& compiler. host, target) ) ;
366
366
run_cargo ( builder,
367
367
& mut cargo,
368
- vec ! [ ] ,
369
368
& libtest_stamp ( builder, compiler, target) ,
370
369
false ) ;
371
370
@@ -493,7 +492,6 @@ impl Step for Rustc {
493
492
compiler. stage, & compiler. host, target) ) ;
494
493
run_cargo ( builder,
495
494
& mut cargo,
496
- vec ! [ ] ,
497
495
& librustc_stamp ( builder, compiler, target) ,
498
496
false ) ;
499
497
@@ -636,47 +634,18 @@ impl Step for CodegenBackend {
636
634
637
635
let out_dir = builder. cargo_out ( compiler, Mode :: Codegen , target) ;
638
636
639
- let mut cargo = builder. cargo ( compiler, Mode :: Codegen , target, "rustc " ) ;
637
+ let mut cargo = builder. cargo ( compiler, Mode :: Codegen , target, "build " ) ;
640
638
cargo. arg ( "--manifest-path" )
641
639
. arg ( builder. src . join ( "src/librustc_codegen_llvm/Cargo.toml" ) ) ;
642
640
rustc_cargo_env ( builder, & mut cargo) ;
643
641
644
642
let features = build_codegen_backend ( & builder, & mut cargo, & compiler, target, backend) ;
645
643
646
- let mut cargo_tails_args = vec ! [ ] ;
647
-
648
- if builder. config . llvm_thin_lto {
649
- cargo_tails_args. push ( "--" . to_string ( ) ) ;
650
-
651
- let num_jobs = builder. jobs ( ) ;
652
-
653
- if !target. contains ( "msvc" ) {
654
- // Here we assume that the linker is clang. If it's not, there'll
655
- // be linker errors.
656
- cargo_tails_args. push ( "-Clink-arg=-fuse-ld=lld" . to_string ( ) ) ;
657
- cargo_tails_args. push ( "-Clink-arg=-flto=thin" . to_string ( ) ) ;
658
-
659
- if builder. config . llvm_optimize {
660
- cargo_tails_args. push ( "-Clink-arg=-O2" . to_string ( ) ) ;
661
- }
662
-
663
- // Let's make LLD respect the `-j` option.
664
- let num_jobs_arg = format ! ( "-Clink-arg=-Wl,--thinlto-jobs={}" , num_jobs) ;
665
- cargo_tails_args. push ( num_jobs_arg) ;
666
- } else {
667
- // Here we assume that the linker is lld-link.exe. lld-link.exe
668
- // does not need the extra arguments except for num_jobs
669
- let num_jobs_arg = format ! ( "-Clink-arg=/opt:lldltojobs={}" , num_jobs) ;
670
- cargo_tails_args. push ( num_jobs_arg) ;
671
- }
672
- }
673
-
674
644
let tmp_stamp = out_dir. join ( ".tmp.stamp" ) ;
675
645
676
646
let _folder = builder. fold_output ( || format ! ( "stage{}-rustc_codegen_llvm" , compiler. stage) ) ;
677
647
let files = run_cargo ( builder,
678
648
cargo. arg ( "--features" ) . arg ( features) ,
679
- cargo_tails_args,
680
649
& tmp_stamp,
681
650
false ) ;
682
651
if builder. config . dry_run {
@@ -749,7 +718,9 @@ pub fn build_codegen_backend(builder: &Builder,
749
718
"libstdc++.a" ) ;
750
719
cargo. env ( "LLVM_STATIC_STDCPP" , file) ;
751
720
}
752
- if builder. config . llvm_link_shared {
721
+ if builder. config . llvm_link_shared ||
722
+ ( builder. config . llvm_thin_lto && backend != "emscripten" )
723
+ {
753
724
cargo. env ( "LLVM_LINK_SHARED" , "1" ) ;
754
725
}
755
726
}
@@ -989,6 +960,8 @@ impl Step for Assemble {
989
960
copy_lld_to_sysroot ( builder, target_compiler, & lld_install) ;
990
961
}
991
962
963
+ dist:: maybe_install_llvm_dylib ( builder, target_compiler. host , & sysroot) ;
964
+
992
965
// Link the compiler binary itself into place
993
966
let out_dir = builder. cargo_out ( build_compiler, Mode :: Rustc , host) ;
994
967
let rustc = out_dir. join ( exe ( "rustc_binary" , & * host) ) ;
@@ -1015,7 +988,6 @@ pub fn add_to_sysroot(builder: &Builder, sysroot_dst: &Path, stamp: &Path) {
1015
988
1016
989
pub fn run_cargo ( builder : & Builder ,
1017
990
cargo : & mut Command ,
1018
- tail_args : Vec < String > ,
1019
991
stamp : & Path ,
1020
992
is_check : bool )
1021
993
-> Vec < PathBuf >
@@ -1038,7 +1010,7 @@ pub fn run_cargo(builder: &Builder,
1038
1010
// files we need to probe for later.
1039
1011
let mut deps = Vec :: new ( ) ;
1040
1012
let mut toplevel = Vec :: new ( ) ;
1041
- let ok = stream_cargo ( builder, cargo, tail_args , & mut |msg| {
1013
+ let ok = stream_cargo ( builder, cargo, & mut |msg| {
1042
1014
let filenames = match msg {
1043
1015
CargoMessage :: CompilerArtifact { filenames, .. } => filenames,
1044
1016
_ => return ,
@@ -1163,7 +1135,6 @@ pub fn run_cargo(builder: &Builder,
1163
1135
pub fn stream_cargo (
1164
1136
builder : & Builder ,
1165
1137
cargo : & mut Command ,
1166
- tail_args : Vec < String > ,
1167
1138
cb : & mut dyn FnMut ( CargoMessage ) ,
1168
1139
) -> bool {
1169
1140
if builder. config . dry_run {
@@ -1174,10 +1145,6 @@ pub fn stream_cargo(
1174
1145
cargo. arg ( "--message-format" ) . arg ( "json" )
1175
1146
. stdout ( Stdio :: piped ( ) ) ;
1176
1147
1177
- for arg in tail_args {
1178
- cargo. arg ( arg) ;
1179
- }
1180
-
1181
1148
builder. verbose ( & format ! ( "running: {:?}" , cargo) ) ;
1182
1149
let mut child = match cargo. spawn ( ) {
1183
1150
Ok ( child) => child,
0 commit comments