-
Notifications
You must be signed in to change notification settings - Fork 13.4k
rustc_target: Refactor target specifications related to Windows and UEFI #71030
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3ad8c88
rustc_target: Make sure lld-link is treated as link.exe by default
petrochenkov 7a4f059
rustc_target: Move tests into a separate unconfigured file
petrochenkov cfe90eb
linker: Pass `/NODEFAULTLIB` in a more regular way
petrochenkov 6580ceb
rustc_target: `windows(_uwp)_base` -> `windows(_uwp)_gnu_base`
petrochenkov 9c9db3a
rustc_target: Remove some useless imports
petrochenkov fd0e298
rustc_target: Inherit `windows_uwp_msvc_base` from `windows_msvc_base`
petrochenkov 88c4802
rustc_target: Inherit `windows_uwp_gnu_base` from `windows_gnu_base`
petrochenkov 57870ea
rustc_target: Introduce `msvc_base`
petrochenkov 8392e47
Address review comments
petrochenkov 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use crate::spec::{LinkArgs, LinkerFlavor, LldFlavor, TargetOptions}; | ||
|
||
pub fn opts() -> TargetOptions { | ||
let pre_link_args_msvc = vec![ | ||
// Suppress the verbose logo and authorship debugging output, which would needlessly | ||
// clog any log files. | ||
"/NOLOGO".to_string(), | ||
// Tell the compiler that non-code sections can be marked as non-executable, | ||
// including stack pages. | ||
// UEFI is fully compatible to non-executable data pages. | ||
// In fact, firmware might enforce this, so we better let the linker know about this, | ||
// so it will fail if the compiler ever tries placing code on the stack | ||
// (e.g., trampoline constructs and alike). | ||
"/NXCOMPAT".to_string(), | ||
]; | ||
let mut pre_link_args = LinkArgs::new(); | ||
pre_link_args.insert(LinkerFlavor::Msvc, pre_link_args_msvc.clone()); | ||
pre_link_args.insert(LinkerFlavor::Lld(LldFlavor::Link), pre_link_args_msvc); | ||
|
||
TargetOptions { | ||
executables: true, | ||
is_like_windows: true, | ||
is_like_msvc: true, | ||
// set VSLANG to 1033 can prevent link.exe from using | ||
// language packs, and avoid generating Non-UTF-8 error | ||
// messages if a link error occurred. | ||
link_env: vec![("VSLANG".to_string(), "1033".to_string())], | ||
lld_flavor: LldFlavor::Link, | ||
pre_link_args, | ||
abi_return_struct_as_int: true, | ||
emit_debug_gdb_scripts: false, | ||
|
||
..Default::default() | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
use crate::spec::TargetOptions; | ||
use std::default::Default; | ||
|
||
pub fn opts() -> TargetOptions { | ||
TargetOptions { | ||
|
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use super::super::*; | ||
|
||
pub(super) fn test_target(target: TargetResult) { | ||
// Grab the TargetResult struct. If we successfully retrieved | ||
// a Target, then the test JSON encoding/decoding can run for this | ||
// Target on this testing platform (i.e., checking the iOS targets | ||
// only on a Mac test platform). | ||
if let Ok(original) = target { | ||
original.check_consistency(); | ||
let as_json = original.to_json(); | ||
let parsed = Target::from_json(as_json).unwrap(); | ||
assert_eq!(original, parsed); | ||
} | ||
} | ||
|
||
impl Target { | ||
fn check_consistency(&self) { | ||
// Check that LLD with the given flavor is treated identically to the linker it emulates. | ||
// If you target really needs to deviate from the rules below, whitelist it | ||
// and document the reasons. | ||
assert_eq!( | ||
self.linker_flavor == LinkerFlavor::Msvc | ||
|| self.linker_flavor == LinkerFlavor::Lld(LldFlavor::Link), | ||
self.options.lld_flavor == LldFlavor::Link, | ||
); | ||
for args in &[ | ||
&self.options.pre_link_args, | ||
&self.options.pre_link_args_crt, | ||
&self.options.late_link_args, | ||
&self.options.late_link_args_dynamic, | ||
&self.options.late_link_args_static, | ||
&self.options.post_link_args, | ||
] { | ||
assert_eq!( | ||
args.get(&LinkerFlavor::Msvc), | ||
args.get(&LinkerFlavor::Lld(LldFlavor::Link)), | ||
); | ||
if args.contains_key(&LinkerFlavor::Msvc) { | ||
assert_eq!(self.options.lld_flavor, LldFlavor::Link); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.