-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Make --emit=metadata output metadata regardless of link #49289
Conversation
Ping from triage @nrc! This PR needs your review. |
LGTM |
src/librustc_trans/back/link.rs
Outdated
if (sess.opts.debugging_opts.no_trans || | ||
!sess.opts.output_types.should_trans()) && | ||
crate_type == config::CrateTypeExecutable { | ||
if sess.opts.debugging_opts.no_trans && crate_type == config::CrateTypeExecutable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that this is correct. This loop goes on to link the code units which have been generated, but if we are in !sess.opts.output_types.should_trans()
mode, then there should be no code units to link. Also I think it is odd that emit=metadata
and -Ztrans
would have different behaviour, which is what is happening now.
However, it has been a long time since I wrote this, so I'm not really sure what should be done, sorry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you find it acceptable just to special-case !sess.opts.output_types.should_trans() && !sess.opts.output_types.contains_key(&OutputType::Metadata)
as a quick fix for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm really not sure, sorry. ping @rust-lang/compiler anybody know about this code?
Ping from triage @nrc! The author pushed new commits addressing your concerns, can you review this PR again? |
@pietroalbini: there was a follow-up comment, but it was hidden here. Someone else from the compiler team should probably review instead. |
src/librustc_trans/back/link.rs
Outdated
let output_metadata = sess.opts.output_types.contains_key(&OutputType::Metadata); | ||
let ignore_executable = sess.opts.debugging_opts.no_trans || | ||
!(sess.opts.output_types.should_trans() || output_metadata); | ||
if crate_type == config::CrateTypeExecutable && ignore_executable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason I find this condition really hard to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you do the following?
let output_metadata = sess.opts.output_types.contains_key(&OutputType::Metadata);
if (sess.opts.debugging_opts.no_trans || !sess.opts.output_types.should_trans()) &&
!output_metadata &&
crate_type == config::CrateTypeExecutable {
continue;
}
📌 Commit 7575d96 has been approved by |
…r=michaelwoerister Make --emit=metadata output metadata regardless of link Fixes rust-lang#40109. I'm not sure whether this condition was important here or not, but I can't see why it is required (removing it doesn't cause the error the comment warns about, so I'm assuming it's safe). If this is too heavy-handed, I can special-case on `OutputType::Metadata`.
⌛ Testing commit 7575d96 with merge 441363cbacfdb6ddf6e905f1e6b356ba004f326e... |
💔 Test failed - status-travis |
Your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem. Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
Your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem. Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@bors retry p=6 Travis bug. |
…erister Make --emit=metadata output metadata regardless of link Fixes #40109. I'm not sure whether this condition was important here or not, but I can't see why it is required (removing it doesn't cause the error the comment warns about, so I'm assuming it's safe). If this is too heavy-handed, I can special-case on `OutputType::Metadata`. r? @nrc
☀️ Test successful - status-appveyor, status-travis |
In rust-lang#49289, rustc was changed to emit metadata for binaries, which made it so that the librustc.rmeta file created when compiling librustc was overwritten by the rustc-main compilation. This commit renames the rustc-main binary to avoid this problem. rust-lang/cargo#5524 has also been filed to see if Cargo can learn to warn on this situation instead of leaving it for the user to debug.
Fixes #40109. I'm not sure whether this condition was important here or not, but I can't see why it is required (removing it doesn't cause the error the comment warns about, so I'm assuming it's safe). If this is too heavy-handed, I can special-case on
OutputType::Metadata
.r? @nrc