History

kbuild: mark `rustc` (and others) invocations as recursive

`rustc` (like Cargo) may take advantage of the jobserver at any time (e.g. for backend parallelism, or eventually frontend too). In the kernel, we call `rustc` with `-Ccodegen-units=1` (and `-Zthreads` is 1 so far), so we do not expect parallelism. However, in the upcoming Rust 1.76.0, a warning is emitted by `rustc` [1] when it cannot connect to the jobserver it was passed (in many cases, but not all: compiling and `--print sysroot` do, but `--version` does not). And given GNU Make always passes the jobserver in the environment variable (even when a line is deemed non-recursive), `rustc` will end up complaining about it (in particular in Make 4.3 where there is only the simple pipe jobserver style). One solution is to remove the jobserver from `MAKEFLAGS`. However, we can mark the lines with calls to `rustc` (and Cargo) as recursive, which looks simpler. This is being documented as a recommendation in `rustc` [2] and allows us to be ready for the time we may use parallelism inside `rustc` (potentially now, if a user passes `-Zthreads`). Thus do so. Similarly, do the same for `rustdoc` and `cargo` calls. Finally, there is one case that the solution does not cover, which is the `$(shell ...)` call we have. Thus, for that one, set an empty `MAKEFLAGS` environment variable.

Miguel Ojeda committed 2 years ago

Commit ecab4111 parent e9441714 files · +31 −31Browse files

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

Unified · Split

2 files
  1. scripts/Makefile.build +4 −4
  2. scripts/Makefile.host +1 −1
scripts/Makefile.build+4−4
@@ -290,7 +290,7 @@ quiet_cmd_rustc_o_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@ · 289 unmodified lines
290 cmd_rustc_o_rs = $(rust_common_cmd) --emit=obj=$@ $<290 cmd_rustc_o_rs = $(rust_common_cmd) --emit=obj=$@ $<
291 291
292$(obj)/%.o: $(src)/%.rs FORCE292$(obj)/%.o: $(src)/%.rs FORCE
293 $(call if_changed_dep,rustc_o_rs)293 +$(call if_changed_dep,rustc_o_rs)
294 294
295quiet_cmd_rustc_rsi_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@295quiet_cmd_rustc_rsi_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@
296 cmd_rustc_rsi_rs = \296 cmd_rustc_rsi_rs = \
@@ -298,19 +298,19 @@ quiet_cmd_rustc_rsi_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@ · 1 unmodified line
298 command -v $(RUSTFMT) >/dev/null && $(RUSTFMT) $@298 command -v $(RUSTFMT) >/dev/null && $(RUSTFMT) $@
299 299
300$(obj)/%.rsi: $(src)/%.rs FORCE300$(obj)/%.rsi: $(src)/%.rs FORCE
301 $(call if_changed_dep,rustc_rsi_rs)301 +$(call if_changed_dep,rustc_rsi_rs)
302 302
303quiet_cmd_rustc_s_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@303quiet_cmd_rustc_s_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@
304 cmd_rustc_s_rs = $(rust_common_cmd) --emit=asm=$@ $<304 cmd_rustc_s_rs = $(rust_common_cmd) --emit=asm=$@ $<
305 305
306$(obj)/%.s: $(src)/%.rs FORCE306$(obj)/%.s: $(src)/%.rs FORCE
307 $(call if_changed_dep,rustc_s_rs)307 +$(call if_changed_dep,rustc_s_rs)
308 308
309quiet_cmd_rustc_ll_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@309quiet_cmd_rustc_ll_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@
310 cmd_rustc_ll_rs = $(rust_common_cmd) --emit=llvm-ir=$@ $<310 cmd_rustc_ll_rs = $(rust_common_cmd) --emit=llvm-ir=$@ $<
311 311
312$(obj)/%.ll: $(src)/%.rs FORCE312$(obj)/%.ll: $(src)/%.rs FORCE
313 $(call if_changed_dep,rustc_ll_rs)313 +$(call if_changed_dep,rustc_ll_rs)
314 314
315# Compile assembler sources (.S)315# Compile assembler sources (.S)
316# ---------------------------------------------------------------------------316# ---------------------------------------------------------------------------
scripts/Makefile.host+1−1
@@ -156,7 +156,7 @@ quiet_cmd_host-rust = HOSTRUSTC $@ · 155 unmodified lines
156 cmd_host-rust = \156 cmd_host-rust = \
157 $(HOSTRUSTC) $(hostrust_flags) --emit=link=$@ $<157 $(HOSTRUSTC) $(hostrust_flags) --emit=link=$@ $<
158$(host-rust): $(obj)/%: $(src)/%.rs FORCE158$(host-rust): $(obj)/%: $(src)/%.rs FORCE
159 $(call if_changed_dep,host-rust)159 +$(call if_changed_dep,host-rust)
160 160
161targets += $(host-csingle) $(host-cmulti) $(host-cobjs) \161targets += $(host-csingle) $(host-cmulti) $(host-cobjs) \
162 $(host-cxxmulti) $(host-cxxobjs) $(host-rust)162 $(host-cxxmulti) $(host-cxxobjs) $(host-rust)