Skip to content

Commit 71479ee

Browse files
maurerojeda
authored andcommitted
rust: Suppress searching builtin sysroot
By default, if Rust is passed `--target=foo` rather than a target.json file, it will infer a default sysroot if that component is installed. As the proposed aarch64 support [1] uses `aarch64-unknown-none` rather than a target.json file, this is needed [2] to prevent rustc from being confused between the custom kernel sysroot and the pre-installed one. [ Miguel: Applied Boqun's extra case (for `rusttest`) and reworded to add links to the arm64 patch series discussion. In addition, fixed the `rustdoc` target too (which requires a conditional since `cmd_rustdoc` is also used for host crates like `macros`). ] Signed-off-by: Matthew Maurer <[email protected]> Tested-by: Boqun Feng <[email protected]> Reviewed-by: Alice Ryhl <[email protected]> Link: https://lore.kernel.org/rust-for-linux/[email protected]/ [1] Link: https://lore.kernel.org/rust-for-linux/CAGSQo01pOixiPXkW867h4vPUaAjtKtHGKhkV-rpifJvKxAf4Ww@mail.gmail.com/ [2] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 88c2e11 commit 71479ee

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

rust/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $<
7878
$(rustc_target_flags) -L$(objtree)/$(obj) \
7979
--output $(rustdoc_output) \
8080
--crate-name $(subst rustdoc-,,$@) \
81+
$(if $(rustdoc_host),,--sysroot=/dev/null) \
8182
@$(objtree)/include/generated/rustc_cfg $<
8283

8384
# The `html_logo_url` and `html_favicon_url` forms of the `doc` attribute
@@ -178,6 +179,7 @@ quiet_cmd_rustdoc_test_kernel = RUSTDOC TK $<
178179
--extern build_error --extern macros \
179180
--extern bindings --extern uapi \
180181
--no-run --crate-name kernel -Zunstable-options \
182+
--sysroot=/dev/null \
181183
--test-builder $(objtree)/scripts/rustdoc_test_builder \
182184
$< $(rustdoc_test_kernel_quiet); \
183185
$(objtree)/scripts/rustdoc_test_gen
@@ -404,6 +406,7 @@ quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L
404406
--emit=metadata=$(dir $@)$(patsubst %.o,lib%.rmeta,$(notdir $@)) \
405407
--crate-type rlib -L$(objtree)/$(obj) \
406408
--crate-name $(patsubst %.o,%,$(notdir $@)) $< \
409+
--sysroot=/dev/null \
407410
$(if $(rustc_objcopy),;$(OBJCOPY) $(rustc_objcopy) $@)
408411

409412
rust-analyzer:

scripts/Makefile.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ rust_common_cmd = \
275275
--extern alloc --extern kernel \
276276
--crate-type rlib -L $(objtree)/rust/ \
277277
--crate-name $(basename $(notdir $@)) \
278+
--sysroot=/dev/null \
278279
--out-dir $(dir $@) --emit=dep-info=$(depfile)
279280

280281
# `--emit=obj`, `--emit=asm` and `--emit=llvm-ir` imply a single codegen unit

0 commit comments

Comments
 (0)