Skip to content

Commit 0fb5fef

Browse files
author
Vinh Tran
committed
Set --sysroot to sysroot generated by rust_toolchain
1 parent 1557205 commit 0fb5fef

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

rust/private/rustc.bzl

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,9 +1038,6 @@ def construct_arguments(
10381038
data_paths,
10391039
))
10401040

1041-
# Ensure the sysroot is set for the target platform
1042-
env["SYSROOT"] = toolchain.sysroot
1043-
10441041
if toolchain._rename_first_party_crates:
10451042
env["RULES_RUST_THIRD_PARTY_DIR"] = toolchain._third_party_dir
10461043

@@ -1267,14 +1264,22 @@ def rustc_compile_action(
12671264
dsym_folder = ctx.actions.declare_directory(crate_info.output.basename + ".dSYM", sibling = crate_info.output)
12681265
action_outputs.append(dsym_folder)
12691266

1267+
sysroot_arg = ctx.actions.args()
1268+
sysroot_arg.add("--sysroot", toolchain.sysroot)
1269+
12701270
if ctx.executable._process_wrapper:
12711271
# Run as normal
12721272
ctx.actions.run(
12731273
executable = ctx.executable._process_wrapper,
12741274
inputs = compile_inputs,
12751275
outputs = action_outputs,
12761276
env = env,
1277-
arguments = args.all,
1277+
arguments = [
1278+
args.process_wrapper_flags,
1279+
args.rustc_path,
1280+
sysroot_arg,
1281+
args.rustc_flags,
1282+
],
12781283
mnemonic = "Rustc",
12791284
progress_message = "Compiling Rust {} {}{} ({} files)".format(
12801285
crate_info.type,
@@ -1290,7 +1295,12 @@ def rustc_compile_action(
12901295
inputs = compile_inputs,
12911296
outputs = [build_metadata],
12921297
env = env,
1293-
arguments = args_metadata.all,
1298+
arguments = [
1299+
args_metadata.process_wrapper_flags,
1300+
args_metadata.rustc_path,
1301+
sysroot_arg,
1302+
args_metadata.rustc_flags,
1303+
],
12941304
mnemonic = "RustcMetadata",
12951305
progress_message = "Compiling Rust metadata {} {}{} ({} files)".format(
12961306
crate_info.type,
@@ -1309,7 +1319,7 @@ def rustc_compile_action(
13091319
inputs = compile_inputs,
13101320
outputs = action_outputs,
13111321
env = env,
1312-
arguments = [args.rustc_flags],
1322+
arguments = [sysroot_arg, args.rustc_flags],
13131323
mnemonic = "Rustc",
13141324
progress_message = "Compiling Rust (without process_wrapper) {} {}{} ({} files)".format(
13151325
crate_info.type,

0 commit comments

Comments
 (0)