Skip to content

Commit d14bda4

Browse files
authored
Rollup merge of #93969 - bjorn3:codegen_backend_dep_info, r=pnkfelix
Only add codegen backend to dep info if -Zbinary-dep-depinfo is used I am currently migrating the cg_clif build system from using a binary linked to the codegen backend as rustc replacement to passing `-Zcodegen-backend` instead. Without this PR this would force cargo to rebuild the sysroot on any change to the codegen backend even if I explicitly specify that I want it to be preserved, which would make development of cg_clif a lot slower. If you still want to have changes to the codegen backend invalidate the cargo build cache you can explicitly specify `-Zbinary-dep-depinfo`. cc ``@eddyb`` as the codegen backend was initially added to the depinfo for rust-gpu.
2 parents 27490eb + 147e5da commit d14bda4

File tree

2 files changed

+25
-6
lines changed
  • compiler/rustc_interface/src
  • src/test/run-make-fulldeps/hotplug_codegen_backend

2 files changed

+25
-6
lines changed

compiler/rustc_interface/src/passes.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -629,11 +629,15 @@ fn write_out_deps(
629629
});
630630
files.extend(extra_tracked_files);
631631

632-
if let Some(ref backend) = sess.opts.debugging_opts.codegen_backend {
633-
files.push(backend.to_string());
634-
}
635-
636632
if sess.binary_dep_depinfo() {
633+
if let Some(ref backend) = sess.opts.debugging_opts.codegen_backend {
634+
if backend.contains('.') {
635+
// If the backend name contain a `.`, it is the path to an external dynamic
636+
// library. If not, it is not a path.
637+
files.push(backend.to_string());
638+
}
639+
}
640+
637641
boxed_resolver.borrow_mut().access(|resolver| {
638642
for cnum in resolver.cstore().crates_untracked() {
639643
let source = resolver.cstore().crate_source_untracked(cnum);

src/test/run-make-fulldeps/hotplug_codegen_backend/Makefile

+17-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,25 @@ include ../tools.mk
22

33
# ignore-stage1
44

5+
# This test both exists as a check that -Zcodegen-backend is capable of loading external codegen
6+
# backends and that this external codegen backend is only included in the dep info if
7+
# -Zbinary-dep-depinfo is used.
8+
59
all:
610
/bin/echo || exit 0 # This test requires /bin/echo to exist
711
$(RUSTC) the_backend.rs --crate-name the_backend --crate-type dylib \
812
-o $(TMPDIR)/the_backend.dylib
13+
14+
$(RUSTC) some_crate.rs --crate-name some_crate --crate-type lib -o $(TMPDIR)/some_crate \
15+
-Z codegen-backend=$(TMPDIR)/the_backend.dylib -Z unstable-options \
16+
--emit link,dep-info
17+
grep -x "This has been \"compiled\" successfully." $(TMPDIR)/libsome_crate.rlib
18+
# don't declare a dependency on the codegen backend if -Zbinary-dep-depinfo isn't used.
19+
grep -v "the_backend.dylib" $(TMPDIR)/some_crate.d
20+
921
$(RUSTC) some_crate.rs --crate-name some_crate --crate-type lib -o $(TMPDIR)/some_crate \
10-
-Z codegen-backend=$(TMPDIR)/the_backend.dylib -Z unstable-options
11-
grep -x "This has been \"compiled\" successfully." $(TMPDIR)/some_crate
22+
-Z codegen-backend=$(TMPDIR)/the_backend.dylib -Z unstable-options \
23+
--emit link,dep-info -Zbinary-dep-depinfo
24+
grep -x "This has been \"compiled\" successfully." $(TMPDIR)/libsome_crate.rlib
25+
# but declare a dependency on the codegen backend if -Zbinary-dep-depinfo it used.
26+
grep "the_backend.dylib" $(TMPDIR)/some_crate.d

0 commit comments

Comments
 (0)