@@ -788,7 +788,8 @@ def construct_arguments(
788
788
use_json_output = False ,
789
789
build_metadata = False ,
790
790
force_depend_on_objects = False ,
791
- skip_expanding_rustc_env = False ):
791
+ skip_expanding_rustc_env = False ,
792
+ sandboxed_sysroot = True ):
792
793
"""Builds an Args object containing common rustc flags
793
794
794
795
Args:
@@ -965,6 +966,11 @@ def construct_arguments(
965
966
if linker_script :
966
967
rustc_flags .add (linker_script , format = "--codegen=link-arg=-T%s" )
967
968
969
+ if sandboxed_sysroot :
970
+ rustc_flags .add ("--sysroot" , toolchain .sysroot )
971
+ else :
972
+ rustc_flags .add (toolchain .sysroot_short_path , format = "--sysroot=${{pwd}}/%s" )
973
+
968
974
# Tell Rustc where to find the standard library (or libcore)
969
975
rustc_flags .add_all (toolchain .rust_std_paths , before_each = "-L" , format_each = "%s" )
970
976
rustc_flags .add_all (rust_flags )
@@ -1264,22 +1270,14 @@ def rustc_compile_action(
1264
1270
dsym_folder = ctx .actions .declare_directory (crate_info .output .basename + ".dSYM" , sibling = crate_info .output )
1265
1271
action_outputs .append (dsym_folder )
1266
1272
1267
- rustc_sysroot_arg = ctx .actions .args ()
1268
- rustc_sysroot_arg .add ("--sysroot" , toolchain .sysroot )
1269
-
1270
1273
if ctx .executable ._process_wrapper :
1271
1274
# Run as normal
1272
1275
ctx .actions .run (
1273
1276
executable = ctx .executable ._process_wrapper ,
1274
1277
inputs = compile_inputs ,
1275
1278
outputs = action_outputs ,
1276
1279
env = env ,
1277
- arguments = [
1278
- args .process_wrapper_flags ,
1279
- args .rustc_path ,
1280
- rustc_sysroot_arg ,
1281
- args .rustc_flags ,
1282
- ],
1280
+ arguments = args .all ,
1283
1281
mnemonic = "Rustc" ,
1284
1282
progress_message = "Compiling Rust {} {}{} ({} files)" .format (
1285
1283
crate_info .type ,
@@ -1295,12 +1293,7 @@ def rustc_compile_action(
1295
1293
inputs = compile_inputs ,
1296
1294
outputs = [build_metadata ],
1297
1295
env = env ,
1298
- arguments = [
1299
- args_metadata .process_wrapper_flags ,
1300
- args_metadata .rustc_path ,
1301
- rustc_sysroot_arg ,
1302
- args_metadata .rustc_flags ,
1303
- ],
1296
+ arguments = args_metadata .all ,
1304
1297
mnemonic = "RustcMetadata" ,
1305
1298
progress_message = "Compiling Rust metadata {} {}{} ({} files)" .format (
1306
1299
crate_info .type ,
@@ -1319,7 +1312,7 @@ def rustc_compile_action(
1319
1312
inputs = compile_inputs ,
1320
1313
outputs = action_outputs ,
1321
1314
env = env ,
1322
- arguments = [args .rustc_path , rustc_sysroot_arg , args .rustc_flags ],
1315
+ arguments = [args .rustc_path , args .rustc_flags ],
1323
1316
mnemonic = "Rustc" ,
1324
1317
progress_message = "Compiling Rust (without process_wrapper) {} {}{} ({} files)" .format (
1325
1318
crate_info .type ,
0 commit comments