Skip to content

Commit 30f21bf

Browse files
David Tolnayfacebook-github-bot
David Tolnay
authored andcommitted
Inside empty sysroot, is the rustlib load-bearing?
Summary: This code is from {D54130104}. Prior to that, we had been using an entirely empty directory since {D34351072}. Ensuring a `lib/rustlib/{target}/lib` subdirectory present in the directory given to `--sysroot` used to be necessary because rustc would pass `-L{sysroot}/lib/rustlib/{target}/lib` to the linker, which would cause some linkers (`ld64`) to error out if nonexistent. Since [rust-lang/rust#128370](rust-lang/rust#128370) in Rust 1.82, rustc no longer passes that, so we no longer need to create the subdirectory. > **linker: Pass fewer search directories to the linker** > ... > The main sysroot library directory shouldn't generally be passed because it shouldn't contain native libraries, except for one case which is now marked with a FIXME. Reviewed By: capickett, JakobDegen Differential Revision: D72823498 fbshipit-source-id: 4343ab0fa4c19a168574b57d6eed8df23630af1d
1 parent f3826bb commit 30f21bf

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

prelude/rust/build.bzl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,11 @@ def compile_context(ctx: AnalysisContext, binary: bool = False) -> CompileContex
152152
panic_runtime = toolchain_info.panic_runtime,
153153
)
154154

155-
# When we pass explicit sysroot deps, we need to override the default sysroot to avoid accidentally
156-
# linking against the prebuilt sysroot libs provided by the toolchain. Rustc requires a specific layout
157-
# for these libs, so we need to carefully recreate the directory structure below.
155+
# When we pass explicit sysroot deps, we need to override the default
156+
# sysroot to avoid accidentally linking against the prebuilt sysroot libs
157+
# provided by the toolchain.
158158
if toolchain_info.explicit_sysroot_deps:
159-
empty_dir = ctx.actions.copied_dir("empty_dir", {})
160-
empty_sysroot = ctx.actions.copied_dir("empty_sysroot", {"lib/rustlib/" + toolchain_info.rustc_target_triple + "/lib": empty_dir})
161-
159+
empty_sysroot = ctx.actions.copied_dir("empty_dir", {})
162160
sysroot_args = cmd_args("--sysroot=", empty_sysroot, delimiter = "")
163161
elif toolchain_info.sysroot_path:
164162
sysroot_args = cmd_args("--sysroot=", toolchain_info.sysroot_path, delimiter = "")

0 commit comments

Comments
 (0)