`rustc` outputs by default the temporary files (i.e. the ones saved by `-Csave-temps`, such as `*.rcgu*` files) in the current working directory when `-o` and `--out-dir` are not given (even if `--emit=x=path` is given, i.e. it does not use those for temporaries). Since out-of-tree modules are compiled from the `linux` tree, `rustc` then tries to create them there, which may not be accessible. Thus pass `--out-dir` explicitly, even if it is just for the temporary files. Similarly, do so for Rust host programs too.
Showing the changes to scripts (2 of 2 files). Show all
Unified · Split
| @@ -264,6 +264,9 @@ $(obj)/%.lst: $(src)/%.c FORCE · 263 unmodified lines | |||
| 264 | 264 | ||
| 265 | rust_allowed_features := new_uninit | 265 | rust_allowed_features := new_uninit |
| 266 | 266 | ||
| 267 | # `--out-dir` is required to avoid temporaries being created by `rustc` in the | ||
| 268 | # current working directory, which may be not accessible in the out-of-tree | ||
| 269 | # modules case. | ||
| 267 | rust_common_cmd = \ | 270 | rust_common_cmd = \ |
| 268 | RUST_MODFILE=$(modfile) $(RUSTC_OR_CLIPPY) $(rust_flags) \ | 271 | RUST_MODFILE=$(modfile) $(RUSTC_OR_CLIPPY) $(rust_flags) \ |
| 269 | -Zallow-features=$(rust_allowed_features) \ | 272 | -Zallow-features=$(rust_allowed_features) \ |
| @@ -272,7 +275,7 @@ rust_common_cmd = \ · 2 unmodified lines | |||
| 272 | --extern alloc --extern kernel \ | 275 | --extern alloc --extern kernel \ |
| 273 | --crate-type rlib -L $(objtree)/rust/ \ | 276 | --crate-type rlib -L $(objtree)/rust/ \ |
| 274 | --crate-name $(basename $(notdir $@)) \ | 277 | --crate-name $(basename $(notdir $@)) \ |
| 275 | --emit=dep-info=$(depfile) | 278 | --out-dir $(dir $@) --emit=dep-info=$(depfile) |
| 276 | 279 | ||
| 277 | # `--emit=obj`, `--emit=asm` and `--emit=llvm-ir` imply a single codegen unit | 280 | # `--emit=obj`, `--emit=asm` and `--emit=llvm-ir` imply a single codegen unit |
| 278 | # will be used. We explicitly request `-Ccodegen-units=1` in any case, and | 281 | # will be used. We explicitly request `-Ccodegen-units=1` in any case, and |
| @@ -86,7 +86,11 @@ hostc_flags = -Wp,-MMD,$(depfile) \ · 85 unmodified lines | |||
| 86 | hostcxx_flags = -Wp,-MMD,$(depfile) \ | 86 | hostcxx_flags = -Wp,-MMD,$(depfile) \ |
| 87 | $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \ | 87 | $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \ |
| 88 | $(HOSTCXXFLAGS_$(target-stem).o) | 88 | $(HOSTCXXFLAGS_$(target-stem).o) |
| 89 | hostrust_flags = --emit=dep-info=$(depfile) \ | 89 | |
| 90 | # `--out-dir` is required to avoid temporaries being created by `rustc` in the | ||
| 91 | # current working directory, which may be not accessible in the out-of-tree | ||
| 92 | # modules case. | ||
| 93 | hostrust_flags = --out-dir $(dir $@) --emit=dep-info=$(depfile) \ | ||
| 90 | $(KBUILD_HOSTRUSTFLAGS) $(HOST_EXTRARUSTFLAGS) \ | 94 | $(KBUILD_HOSTRUSTFLAGS) $(HOST_EXTRARUSTFLAGS) \ |
| 91 | $(HOSTRUSTFLAGS_$(target-stem)) | 95 | $(HOSTRUSTFLAGS_$(target-stem)) |
| 92 | 96 | ||