Skip to content

Make --emit=metadata output metadata regardless of link - #49289

Merged
bors merged 3 commits into
rust-lang:masterfrom
varkor:emit-metadata-without-link
Apr 14, 2018
Merged

Make --emit=metadata output metadata regardless of link#49289
bors merged 3 commits into
rust-lang:masterfrom
varkor:emit-metadata-without-link

Conversation

@varkor

Copy link
Copy Markdown
Contributor

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

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 23, 2018
@emilyalbini

Copy link
Copy Markdown
Member

Ping from triage @nrc! This PR needs your review.

@quxiaolong1504

Copy link
Copy Markdown

LGTM

Comment threadsrc/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 {

Copy link
Copy Markdown
Member

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

@varkorvarkorMar 28, 2018

Copy link
Copy Markdown
ContributorAuthor

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?

Copy link
Copy Markdown
Member

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?

@emilyalbini

Copy link
Copy Markdown
Member

Ping from triage @nrc! The author pushed new commits addressing your concerns, can you review this PR again?

@varkor

Copy link
Copy Markdown
ContributorAuthor

@pietroalbini: there was a follow-up comment, but it was hidden here. Someone else from the compiler team should probably review instead.

r? @michaelwoerister

Comment threadsrc/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 {

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member

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;}

@michaelwoerister

Copy link
Copy Markdown
Member

@bors r+

Thanks, @varkor!

@bors

bors commented Apr 13, 2018

Copy link
Copy Markdown
Collaborator

📌 Commit 7575d96 has been approved by michaelwoerister

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 13, 2018
@kennytmkennytm mentioned this pull request Apr 13, 2018
kennytm added a commit to kennytm/rust that referenced this pull request Apr 13, 2018
…r=michaelwoerister
Make --emit=metadata output metadata regardless of link
Fixesrust-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`.
@kennytmkennytm mentioned this pull request Apr 13, 2018
@bors

bors commented Apr 14, 2018

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 7575d96 with merge 441363cbacfdb6ddf6e905f1e6b356ba004f326e...

@bors

bors commented Apr 14, 2018

Copy link
Copy Markdown
Collaborator

💔 Test failed - status-travis

@borsbors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 14, 2018
@rust-highfive

Copy link
Copy Markdown
Contributor

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.
An error occurred while generating the build script.

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 @TimNN. (Feature Requests)

@rust-highfive

Copy link
Copy Markdown
Contributor

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.
An error occurred while generating the build script.

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 @TimNN. (Feature Requests)

@kennytm

kennytm commented Apr 14, 2018

Copy link
Copy Markdown
Member

@bors retry p=6

Travis bug.

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 14, 2018
@bors

bors commented Apr 14, 2018

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 7575d96 with merge cfc3465...

bors added a commit that referenced this pull request Apr 14, 2018
…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
@bors

bors commented Apr 14, 2018

Copy link
Copy Markdown
Collaborator

☀️ Test successful - status-appveyor, status-travis
Approved by: michaelwoerister
Pushing cfc3465 to master...

@bors
bors merged commit 7575d96 into rust-lang:masterApr 14, 2018
@varkor
varkor deleted the emit-metadata-without-link branch April 14, 2018 16:32
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request May 17, 2018
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.
@ehussehuss mentioned this pull request Mar 11, 2020
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@varkor@emilyalbini@quxiaolong1504@michaelwoerister@bors@rust-highfive@kennytm@nrc