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

linker: Reorder linker arguments #85086

Merged
merged 4 commits into from
Jun 6, 2021
Merged

Conversation

petrochenkov
Copy link
Contributor

@petrochenkov petrochenkov commented May 8, 2021

  • Split arguments into order-independent and order-dependent, to define more precisely what (pre-,post-,late-,)link-args mean.
  • Add some comments.

@rust-highfive
Copy link
Collaborator

r? @estebank

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 8, 2021
@petrochenkov
Copy link
Contributor Author

r? @nagisa

@rust-highfive rust-highfive assigned nagisa and unassigned estebank May 8, 2021
@rust-log-analyzer

This comment has been minimized.

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 8, 2021
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@petrochenkov petrochenkov force-pushed the linkord2 branch 2 times, most recently from 728b735 to 416b9b8 Compare May 10, 2021 14:28
@rust-log-analyzer

This comment has been minimized.

@petrochenkov petrochenkov force-pushed the linkord2 branch 2 times, most recently from 8a91aca to 875f95a Compare May 10, 2021 18:06
@petrochenkov petrochenkov changed the title [WIP] linker: Reorder linker arguments linker: Reorder linker arguments May 10, 2021
@petrochenkov petrochenkov added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 10, 2021
@petrochenkov
Copy link
Contributor Author

This should be ready now.
@bors rollup=never

@bors

This comment has been minimized.

Copy link
Member

@nagisa nagisa left a comment

Choose a reason for hiding this comment

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

Implementation looks good to me, broadly speaking. There are some inline nits that I left, but otherwise r=me.

compiler/rustc_codegen_ssa/src/back/link.rs Outdated Show resolved Hide resolved
// ---------------------- Object code and libraries, order-dependent -------------------------

// Pre-link CRT objects.
add_pre_link_objects(cmd, sess, link_output_kind, crt_objects_fallback);
Copy link
Member

Choose a reason for hiding this comment

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

AFAICT in the past we did not export_symbols from the CRT objects nor the sanitizer libraries. Are there bugs that are fixed by this re-ordering? And if so, can they be linked in the commit message, or at least this change called out if there isn't an issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moving export_symbols to before add_pre_link_objects doesn't fix any issues, it's just for gathering objects/libraries into one group and options to another.

@@ -1373,11 +1364,6 @@ impl<'a> Linker for PtxLinker<'a> {
self.cmd.arg("-o").arg(path);
}

fn finalize(&mut self) {
Copy link
Member

Choose a reason for hiding this comment

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

Is there context for this removal that is necessary to understand why this argument is no longer necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The necessary part is replaced with fn reset_per_library_state, other uses are just random order-independent flags which are moved to fn add_order_independent_options.

compiler/rustc_codegen_ssa/src/back/link.rs Show resolved Hide resolved
@petrochenkov petrochenkov removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 23, 2021
@petrochenkov petrochenkov added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label May 23, 2021
@bors

This comment has been minimized.

- Combine all native library arguments together, to simplify potential support for library deduplication and similar things
- Split arguments into order-independent and order-dependent, to define more precisely what (pre,post,late)-link-args mean
@petrochenkov
Copy link
Contributor Author

@bors r=nagisa

@bors
Copy link
Contributor

bors commented Jun 6, 2021

📌 Commit 3eab280 has been approved by nagisa

@bors bors 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 6, 2021
@bors
Copy link
Contributor

bors commented Jun 6, 2021

⌛ Testing commit 3eab280 with merge 5b638c1...

@bors
Copy link
Contributor

bors commented Jun 6, 2021

☀️ Test successful - checks-actions
Approved by: nagisa
Pushing 5b638c1 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 6, 2021
@bors bors merged commit 5b638c1 into rust-lang:master Jun 6, 2021
@rustbot rustbot added this to the 1.54.0 milestone Jun 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: 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