History

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`). ]

Matthew Maurer committed 3 years ago

Commit 71479ee1 parent 88c2e112 files · +4 −0Browse files

Unified · Split

2 files
  1. rust/Makefile +3 −0
  2. scripts/Makefile.build +1 −0
rust/Makefile+3−0
@@ -78,6 +78,7 @@ quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $< · 77 unmodified lines
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 $< · 94 unmodified lines
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 · 220 unmodified lines
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+1−0
@@ -275,6 +275,7 @@ rust_common_cmd = \ · 274 unmodified lines
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