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`). ]
Unified · Split
| @@ -78,6 +78,7 @@ quiet_cmd_rustdoc = RUSTDOC $(if $(rustdoc_host),H, ) $< · 77 unmodified lines | ||
| 78 | 78 | $(rustc_target_flags) -L$(objtree)/$(obj) \ |
| 79 | 79 | --output $(rustdoc_output) \ |
| 80 | 80 | --crate-name $(subst rustdoc-,,$@) \ |
| 81 | + $(if $(rustdoc_host),,--sysroot=/dev/null) \ | |
| 81 | 82 | @$(objtree)/include/generated/rustc_cfg $< |
| 82 | 83 | |
| 83 | 84 | # 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 | ||
| 178 | 179 | --extern build_error --extern macros \ |
| 179 | 180 | --extern bindings --extern uapi \ |
| 180 | 181 | --no-run --crate-name kernel -Zunstable-options \ |
| 182 | + --sysroot=/dev/null \ | |
| 181 | 183 | --test-builder $(objtree)/scripts/rustdoc_test_builder \ |
| 182 | 184 | $< $(rustdoc_test_kernel_quiet); \ |
| 183 | 185 | $(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 | ||
| 404 | 406 | --emit=metadata=$(dir $@)$(patsubst %.o,lib%.rmeta,$(notdir $@)) \ |
| 405 | 407 | --crate-type rlib -L$(objtree)/$(obj) \ |
| 406 | 408 | --crate-name $(patsubst %.o,%,$(notdir $@)) $< \ |
| 409 | + --sysroot=/dev/null \ | |
| 407 | 410 | $(if $(rustc_objcopy),;$(OBJCOPY) $(rustc_objcopy) $@) |
| 408 | 411 | |
| 409 | 412 | rust-analyzer: |
| @@ -275,6 +275,7 @@ rust_common_cmd = \ · 274 unmodified lines | ||
| 275 | 275 | --extern alloc --extern kernel \ |
| 276 | 276 | --crate-type rlib -L $(objtree)/rust/ \ |
| 277 | 277 | --crate-name $(basename $(notdir $@)) \ |
| 278 | + --sysroot=/dev/null \ | |
| 278 | 279 | --out-dir $(dir $@) --emit=dep-info=$(depfile) |
| 279 | 280 | |
| 280 | 281 | # `--emit=obj`, `--emit=asm` and `--emit=llvm-ir` imply a single codegen unit |