Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only add codegen backend to dep info if -Zbinary-dep-depinfo is used #93969

Merged
merged 3 commits into from
Apr 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions compiler/rustc_interface/src/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,11 +646,15 @@ fn write_out_deps(
});
files.extend(extra_tracked_files);

if let Some(ref backend) = sess.opts.debugging_opts.codegen_backend {
files.push(backend.to_string());
}

if sess.binary_dep_depinfo() {
if let Some(ref backend) = sess.opts.debugging_opts.codegen_backend {
if backend.contains('.') {
// If the backend name contain a `.`, it is the path to an external dynamic
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we expecting the . to come from the file extension separator (ie libcranelift.dll) or from a relative path (ie ./libcranelift) or both? I'm wondering if perhaps this check could be made more specific.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the file extension was my original idea, but from ./ also works. Rustc_interface does the exact same check.

// library. If not, it is not a path.
files.push(backend.to_string());
}
}

boxed_resolver.borrow_mut().access(|resolver| {
for cnum in resolver.cstore().crates_untracked() {
let source = resolver.cstore().crate_source_untracked(cnum);
Expand Down
19 changes: 17 additions & 2 deletions src/test/run-make-fulldeps/hotplug_codegen_backend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,25 @@ include ../tools.mk

# ignore-stage1

# This test both exists as a check that -Zcodegen-backend is capable of loading external codegen
# backends and that this external codegen backend is only included in the dep info if
# -Zbinary-dep-depinfo is used.

all:
/bin/echo || exit 0 # This test requires /bin/echo to exist
$(RUSTC) the_backend.rs --crate-name the_backend --crate-type dylib \
-o $(TMPDIR)/the_backend.dylib

$(RUSTC) some_crate.rs --crate-name some_crate --crate-type lib -o $(TMPDIR)/some_crate \
-Z codegen-backend=$(TMPDIR)/the_backend.dylib -Z unstable-options \
--emit link,dep-info
grep -x "This has been \"compiled\" successfully." $(TMPDIR)/libsome_crate.rlib
# don't declare a dependency on the codegen backend if -Zbinary-dep-depinfo isn't used.
grep -v "the_backend.dylib" $(TMPDIR)/some_crate.d

$(RUSTC) some_crate.rs --crate-name some_crate --crate-type lib -o $(TMPDIR)/some_crate \
-Z codegen-backend=$(TMPDIR)/the_backend.dylib -Z unstable-options
grep -x "This has been \"compiled\" successfully." $(TMPDIR)/some_crate
-Z codegen-backend=$(TMPDIR)/the_backend.dylib -Z unstable-options \
--emit link,dep-info -Zbinary-dep-depinfo
grep -x "This has been \"compiled\" successfully." $(TMPDIR)/libsome_crate.rlib
# but declare a dependency on the codegen backend if -Zbinary-dep-depinfo it used.
grep "the_backend.dylib" $(TMPDIR)/some_crate.d