-
Notifications
You must be signed in to change notification settings - Fork 13k
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
[WIP] Encode more info about order-dependence of linker arguments #71081
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -549,6 +549,26 @@ impl HasTargetSpec for Target { | |||||
} | ||||||
} | ||||||
|
||||||
/// "Unordered" options are options applied to the whole linking process rather than to individual | ||||||
/// input object files or libraries. So it doesn't matter whether they are passed before or after | ||||||
/// input files. | ||||||
#[derive(Default, PartialEq, Clone, Debug)] | ||||||
pub struct NewLinkArgs { | ||||||
/// These options cannot be overridden once specified. | ||||||
/// So they can be passed anywhere on the command line. | ||||||
pub unordered_non_overridable: Vec<String>, | ||||||
/// These option can be overridden by options placed to the left from them on the command line. | ||||||
/// So they need to be placed after customization points like `-C link-args`. | ||||||
/// (Library search directories traversed from left to right is a typical example.) | ||||||
pub unordered_left_overridable: Vec<String>, | ||||||
/// These option can be overridden by options placed to the right from them on the command line. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
/// So they need to be placed before customization points like `-C link-args`. | ||||||
/// (Options like `-foo=yes` overridden by `-foo=no` is a typical example.) | ||||||
pub unordered_right_overridable: Vec<String>, | ||||||
} | ||||||
|
||||||
type LinkArgsMap = BTreeMap<LinkerFlavor, NewLinkArgs>; | ||||||
|
||||||
/// Optional aspects of a target specification. | ||||||
/// | ||||||
/// This has an implementation of `Default`, see each field for what the default is. In general, | ||||||
|
@@ -565,6 +585,9 @@ pub struct TargetOptions { | |||||
/// without clarifying its flavor in any way. | ||||||
pub lld_flavor: LldFlavor, | ||||||
|
||||||
/// New style default linker arguments. | ||||||
/// Other link arg fields are supposed to be migrated to them eventually. | ||||||
pub link_args: LinkArgsMap, | ||||||
/// Linker arguments that are passed *before* any user-defined libraries. | ||||||
pub pre_link_args: LinkArgs, // ... unconditionally | ||||||
pub pre_link_args_crt: LinkArgs, // ... when linking with a bundled crt | ||||||
|
@@ -812,6 +835,7 @@ impl Default for TargetOptions { | |||||
is_builtin: false, | ||||||
linker: option_env!("CFG_DEFAULT_LINKER").map(|s| s.to_string()), | ||||||
lld_flavor: LldFlavor::Ld, | ||||||
link_args: Default::default(), | ||||||
pre_link_args: LinkArgs::new(), | ||||||
pre_link_args_crt: LinkArgs::new(), | ||||||
post_link_args: LinkArgs::new(), | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.