File tree Expand file tree Collapse file tree 3 files changed +13
-0
lines changed Expand file tree Collapse file tree 3 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -604,6 +604,15 @@ impl Builder<'_> {
604604 rustflags. arg ( arg) ;
605605 }
606606
607+ // target specific rustflags take precedence over general rustflags
608+ if let Some ( target_rustflags) =
609+ self . config . target_config . get ( & target) . map ( |t| & t. rustflags [ ..] )
610+ {
611+ for arg in target_rustflags {
612+ rustflags. arg ( & arg) ;
613+ }
614+ }
615+
607616 rustflags. propagate_cargo_env ( "RUSTFLAGS" ) ;
608617
609618 if build_compiler_stage != 0 {
Original file line number Diff line number Diff line change @@ -856,6 +856,7 @@ impl Config {
856856 sanitizers : target_sanitizers,
857857 profiler : target_profiler,
858858 rpath : target_rpath,
859+ rustflags : target_rustflags,
859860 crt_static : target_crt_static,
860861 musl_root : target_musl_root,
861862 musl_libdir : target_musl_libdir,
@@ -939,6 +940,7 @@ impl Config {
939940 target. sanitizers = target_sanitizers;
940941 target. profiler = target_profiler;
941942 target. rpath = target_rpath;
943+ target. rustflags = target_rustflags. unwrap_or_default ( ) ;
942944 target. optimized_compiler_builtins = target_optimized_compiler_builtins;
943945 target. jemalloc = target_jemalloc;
944946 if let Some ( backends) = target_codegen_backends {
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ define_config! {
3737 sanitizers: Option <bool > = "sanitizers" ,
3838 profiler: Option <StringOrBool > = "profiler" ,
3939 rpath: Option <bool > = "rpath" ,
40+ rustflags: Option <Vec <String >> = "rustflags" ,
4041 crt_static: Option <bool > = "crt-static" ,
4142 musl_root: Option <String > = "musl-root" ,
4243 musl_libdir: Option <String > = "musl-libdir" ,
@@ -70,6 +71,7 @@ pub struct Target {
7071 pub sanitizers : Option < bool > ,
7172 pub profiler : Option < StringOrBool > ,
7273 pub rpath : Option < bool > ,
74+ pub rustflags : Vec < String > ,
7375 pub crt_static : Option < bool > ,
7476 pub musl_root : Option < PathBuf > ,
7577 pub musl_libdir : Option < PathBuf > ,
You can’t perform that action at this time.
0 commit comments