`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 | 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 | 270 | rust_common_cmd = \ |
| 268 | 271 | RUST_MODFILE=$(modfile) $(RUSTC_OR_CLIPPY) $(rust_flags) \ |
| 269 | 272 | -Zallow-features=$(rust_allowed_features) \ |
| @@ -272,7 +275,7 @@ rust_common_cmd = \ · 2 unmodified lines | ||
| 272 | 275 | --extern alloc --extern kernel \ |
| 273 | 276 | --crate-type rlib -L $(objtree)/rust/ \ |
| 274 | 277 | --crate-name $(basename $(notdir $@)) \ |
| 275 | − --emit=dep-info=$(depfile) | |
| 278 | + --out-dir $(dir $@) --emit=dep-info=$(depfile) | |
| 276 | 279 | |
| 277 | 280 | # `--emit=obj`, `--emit=asm` and `--emit=llvm-ir` imply a single codegen unit |
| 278 | 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 | 86 | hostcxx_flags = -Wp,-MMD,$(depfile) \ |
| 87 | 87 | $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \ |
| 88 | 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 | 94 | $(KBUILD_HOSTRUSTFLAGS) $(HOST_EXTRARUSTFLAGS) \ |
| 91 | 95 | $(HOSTRUSTFLAGS_$(target-stem)) |
| 92 | 96 | |