forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#71030 - petrochenkov:linkorder2, r=nagisa
rustc_target: Refactor target specifications related to Windows and UEFI - LLD support is improved. - Code is cleaned up. - Target specs are organized in a more hierarchical way. - Possible issues in UWP and UEFI platforms are identified (see FIXMEs). The code is better read per-commit.
- Loading branch information
Showing
38 changed files
with
219 additions
and
225 deletions.
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
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
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
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
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
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 |
---|---|---|
@@ -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 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
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 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.