History

kbuild: rust: avoid creating temporary files

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

Miguel Ojeda committed 3 years ago

Commit df01b7c1 parent 0817d252 files · +9 −2Browse files

Showing the changes to scripts (2 of 2 files). Show all

Unified · Split

2 files
  1. scripts/Makefile.build +4 −1
  2. scripts/Makefile.host +5 −1
scripts/Makefile.build+4−1
@@ -264,6 +264,9 @@ $(obj)/%.lst: $(src)/%.c FORCE · 263 unmodified lines
264 264
265rust_allowed_features := new_uninit265rust_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.
267rust_common_cmd = \270rust_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 unit280# `--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, and281# will be used. We explicitly request `-Ccodegen-units=1` in any case, and
scripts/Makefile.host+5−1
@@ -86,7 +86,11 @@ hostc_flags = -Wp,-MMD,$(depfile) \ · 85 unmodified lines
86hostcxx_flags = -Wp,-MMD,$(depfile) \86hostcxx_flags = -Wp,-MMD,$(depfile) \
87 $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \87 $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \
88 $(HOSTCXXFLAGS_$(target-stem).o)88 $(HOSTCXXFLAGS_$(target-stem).o)
89hostrust_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.
93hostrust_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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t