rustc_target: Refactor internal linker flavors slightly
Remove one unstable user-facing linker flavor (l4-bender)
This commit is contained in:
parent
7dc186ff7e
commit
a0e21ff105
@ -1173,13 +1173,6 @@ fn infer_from(
|
||||
// only the linker flavor is known; use the default linker for the selected flavor
|
||||
(None, Some(flavor)) => Some((
|
||||
PathBuf::from(match flavor {
|
||||
LinkerFlavor::Em => {
|
||||
if cfg!(windows) {
|
||||
"emcc.bat"
|
||||
} else {
|
||||
"emcc"
|
||||
}
|
||||
}
|
||||
LinkerFlavor::Gcc => {
|
||||
if cfg!(any(target_os = "solaris", target_os = "illumos")) {
|
||||
// On historical Solaris systems, "cc" may have
|
||||
@ -1194,11 +1187,17 @@ fn infer_from(
|
||||
}
|
||||
}
|
||||
LinkerFlavor::Ld => "ld",
|
||||
LinkerFlavor::Msvc => "link.exe",
|
||||
LinkerFlavor::Lld(_) => "lld",
|
||||
LinkerFlavor::PtxLinker => "rust-ptx-linker",
|
||||
LinkerFlavor::BpfLinker => "bpf-linker",
|
||||
LinkerFlavor::L4Bender => "l4-bender",
|
||||
LinkerFlavor::Msvc => "link.exe",
|
||||
LinkerFlavor::EmCc => {
|
||||
if cfg!(windows) {
|
||||
"emcc.bat"
|
||||
} else {
|
||||
"emcc"
|
||||
}
|
||||
}
|
||||
LinkerFlavor::Bpf => "bpf-linker",
|
||||
LinkerFlavor::Ptx => "rust-ptx-linker",
|
||||
}),
|
||||
flavor,
|
||||
)),
|
||||
@ -1208,7 +1207,7 @@ fn infer_from(
|
||||
});
|
||||
|
||||
let flavor = if stem == "emcc" {
|
||||
LinkerFlavor::Em
|
||||
LinkerFlavor::EmCc
|
||||
} else if stem == "gcc"
|
||||
|| stem.ends_with("-gcc")
|
||||
|| stem == "clang"
|
||||
@ -2114,11 +2113,11 @@ fn add_order_independent_options(
|
||||
});
|
||||
}
|
||||
|
||||
if flavor == LinkerFlavor::PtxLinker {
|
||||
if flavor == LinkerFlavor::Ptx {
|
||||
// Provide the linker with fallback to internal `target-cpu`.
|
||||
cmd.arg("--fallback-arch");
|
||||
cmd.arg(&codegen_results.crate_info.target_cpu);
|
||||
} else if flavor == LinkerFlavor::BpfLinker {
|
||||
} else if flavor == LinkerFlavor::Bpf {
|
||||
cmd.arg("--cpu");
|
||||
cmd.arg(&codegen_results.crate_info.target_cpu);
|
||||
cmd.arg("--cpu-features");
|
||||
|
@ -126,29 +126,26 @@ pub fn get_linker<'a>(
|
||||
// to the linker args construction.
|
||||
assert!(cmd.get_args().is_empty() || sess.target.vendor == "uwp");
|
||||
match flavor {
|
||||
LinkerFlavor::Lld(LldFlavor::Link) | LinkerFlavor::Msvc => {
|
||||
Box::new(MsvcLinker { cmd, sess }) as Box<dyn Linker>
|
||||
}
|
||||
LinkerFlavor::Em => Box::new(EmLinker { cmd, sess }) as Box<dyn Linker>,
|
||||
LinkerFlavor::Gcc => {
|
||||
Box::new(GccLinker { cmd, sess, target_cpu, hinted_static: false, is_ld: false })
|
||||
as Box<dyn Linker>
|
||||
}
|
||||
|
||||
LinkerFlavor::Ld if sess.target.os == "l4re" => {
|
||||
Box::new(L4Bender::new(cmd, sess)) as Box<dyn Linker>
|
||||
}
|
||||
LinkerFlavor::Lld(LldFlavor::Ld)
|
||||
| LinkerFlavor::Lld(LldFlavor::Ld64)
|
||||
| LinkerFlavor::Ld => {
|
||||
Box::new(GccLinker { cmd, sess, target_cpu, hinted_static: false, is_ld: true })
|
||||
as Box<dyn Linker>
|
||||
}
|
||||
|
||||
LinkerFlavor::Lld(LldFlavor::Link) | LinkerFlavor::Msvc => {
|
||||
Box::new(MsvcLinker { cmd, sess }) as Box<dyn Linker>
|
||||
}
|
||||
LinkerFlavor::Lld(LldFlavor::Wasm) => Box::new(WasmLd::new(cmd, sess)) as Box<dyn Linker>,
|
||||
|
||||
LinkerFlavor::PtxLinker => Box::new(PtxLinker { cmd, sess }) as Box<dyn Linker>,
|
||||
|
||||
LinkerFlavor::BpfLinker => Box::new(BpfLinker { cmd, sess }) as Box<dyn Linker>,
|
||||
|
||||
LinkerFlavor::L4Bender => Box::new(L4Bender::new(cmd, sess)) as Box<dyn Linker>,
|
||||
LinkerFlavor::EmCc => Box::new(EmLinker { cmd, sess }) as Box<dyn Linker>,
|
||||
LinkerFlavor::Bpf => Box::new(BpfLinker { cmd, sess }) as Box<dyn Linker>,
|
||||
LinkerFlavor::Ptx => Box::new(PtxLinker { cmd, sess }) as Box<dyn Linker>,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,10 +21,8 @@
|
||||
use rustc_span::edition::{Edition, DEFAULT_EDITION};
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::SourceFileHashAlgorithm;
|
||||
use rustc_target::spec::{CodeModel, LinkerFlavor, MergeFunctions, PanicStrategy};
|
||||
use rustc_target::spec::{
|
||||
RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, TlsModel,
|
||||
};
|
||||
use rustc_target::spec::{CodeModel, LinkerFlavorCli, MergeFunctions, PanicStrategy, RelocModel};
|
||||
use rustc_target::spec::{RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, TlsModel};
|
||||
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::iter::FromIterator;
|
||||
@ -552,7 +550,7 @@ macro_rules! untracked {
|
||||
untracked!(link_args, vec![String::from("abc"), String::from("def")]);
|
||||
untracked!(link_self_contained, Some(true));
|
||||
untracked!(linker, Some(PathBuf::from("linker")));
|
||||
untracked!(linker_flavor, Some(LinkerFlavor::Gcc));
|
||||
untracked!(linker_flavor, Some(LinkerFlavorCli::Gcc));
|
||||
untracked!(no_stack_check, true);
|
||||
untracked!(remark, Passes::Some(vec![String::from("pass1"), String::from("pass2")]));
|
||||
untracked!(rpath, true);
|
||||
|
@ -12,8 +12,8 @@
|
||||
|
||||
use rustc_data_structures::stable_hasher::ToStableHashKey;
|
||||
use rustc_target::abi::{Align, TargetDataLayout};
|
||||
use rustc_target::spec::{LinkerFlavorCli, SplitDebuginfo, Target, TargetTriple, TargetWarnings};
|
||||
use rustc_target::spec::{PanicStrategy, SanitizerSet, TARGETS};
|
||||
use rustc_target::spec::{PanicStrategy, SanitizerSet, SplitDebuginfo};
|
||||
use rustc_target::spec::{Target, TargetTriple, TargetWarnings, TARGETS};
|
||||
|
||||
use crate::parse::{CrateCheckConfig, CrateConfig};
|
||||
use rustc_feature::UnstableFeatures;
|
||||
@ -2379,16 +2379,6 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||
}
|
||||
}
|
||||
|
||||
if cg.linker_flavor == Some(LinkerFlavorCli::L4Bender)
|
||||
&& !nightly_options::is_unstable_enabled(matches)
|
||||
{
|
||||
early_error(
|
||||
error_format,
|
||||
"`l4-bender` linker flavor is unstable, `-Z unstable-options` \
|
||||
flag must also be passed to explicitly use it",
|
||||
);
|
||||
}
|
||||
|
||||
let prints = collect_print_requests(&mut cg, &mut unstable_opts, matches, error_format);
|
||||
|
||||
let cg = cg;
|
||||
|
@ -2,6 +2,6 @@
|
||||
|
||||
pub fn target() -> Target {
|
||||
let mut target = wasm32_unknown_emscripten::target();
|
||||
target.add_post_link_args(LinkerFlavor::Em, &["-sWASM=0", "--memory-init-file", "0"]);
|
||||
target.add_post_link_args(LinkerFlavor::EmCc, &["-sWASM=0", "--memory-init-file", "0"]);
|
||||
target
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ pub fn opts(endian: Endian) -> TargetOptions {
|
||||
TargetOptions {
|
||||
allow_asm: true,
|
||||
endian,
|
||||
linker_flavor: LinkerFlavor::BpfLinker,
|
||||
linker_flavor: LinkerFlavor::Bpf,
|
||||
atomic_cas: false,
|
||||
dynamic_linking: true,
|
||||
no_builtins: true,
|
||||
|
@ -4,7 +4,7 @@ pub fn opts() -> TargetOptions {
|
||||
TargetOptions {
|
||||
os: "l4re".into(),
|
||||
env: "uclibc".into(),
|
||||
linker_flavor: LinkerFlavor::L4Bender,
|
||||
linker_flavor: LinkerFlavor::Ld,
|
||||
panic_strategy: PanicStrategy::Abort,
|
||||
linker: Some("l4-bender".into()),
|
||||
linker_is_gnu: false,
|
||||
|
@ -92,26 +92,24 @@
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
|
||||
pub enum LinkerFlavor {
|
||||
Em,
|
||||
Gcc,
|
||||
L4Bender,
|
||||
Ld,
|
||||
Msvc,
|
||||
Lld(LldFlavor),
|
||||
PtxLinker,
|
||||
BpfLinker,
|
||||
Msvc,
|
||||
EmCc,
|
||||
Bpf,
|
||||
Ptx,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
|
||||
pub enum LinkerFlavorCli {
|
||||
Em,
|
||||
Gcc,
|
||||
L4Bender,
|
||||
Ld,
|
||||
Msvc,
|
||||
Lld(LldFlavor),
|
||||
PtxLinker,
|
||||
Msvc,
|
||||
Em,
|
||||
BpfLinker,
|
||||
PtxLinker,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
|
||||
@ -152,39 +150,37 @@ fn to_json(&self) -> Json {
|
||||
impl LinkerFlavor {
|
||||
pub fn from_cli(cli: LinkerFlavorCli) -> LinkerFlavor {
|
||||
match cli {
|
||||
LinkerFlavorCli::Em => LinkerFlavor::Em,
|
||||
LinkerFlavorCli::Gcc => LinkerFlavor::Gcc,
|
||||
LinkerFlavorCli::L4Bender => LinkerFlavor::L4Bender,
|
||||
LinkerFlavorCli::Ld => LinkerFlavor::Ld,
|
||||
LinkerFlavorCli::Msvc => LinkerFlavor::Msvc,
|
||||
LinkerFlavorCli::Lld(lld_flavor) => LinkerFlavor::Lld(lld_flavor),
|
||||
LinkerFlavorCli::PtxLinker => LinkerFlavor::PtxLinker,
|
||||
LinkerFlavorCli::BpfLinker => LinkerFlavor::BpfLinker,
|
||||
LinkerFlavorCli::Msvc => LinkerFlavor::Msvc,
|
||||
LinkerFlavorCli::Em => LinkerFlavor::EmCc,
|
||||
LinkerFlavorCli::BpfLinker => LinkerFlavor::Bpf,
|
||||
LinkerFlavorCli::PtxLinker => LinkerFlavor::Ptx,
|
||||
}
|
||||
}
|
||||
|
||||
fn to_cli(self) -> LinkerFlavorCli {
|
||||
match self {
|
||||
LinkerFlavor::Em => LinkerFlavorCli::Em,
|
||||
LinkerFlavor::Gcc => LinkerFlavorCli::Gcc,
|
||||
LinkerFlavor::L4Bender => LinkerFlavorCli::L4Bender,
|
||||
LinkerFlavor::Ld => LinkerFlavorCli::Ld,
|
||||
LinkerFlavor::Msvc => LinkerFlavorCli::Msvc,
|
||||
LinkerFlavor::Lld(lld_flavor) => LinkerFlavorCli::Lld(lld_flavor),
|
||||
LinkerFlavor::PtxLinker => LinkerFlavorCli::PtxLinker,
|
||||
LinkerFlavor::BpfLinker => LinkerFlavorCli::BpfLinker,
|
||||
LinkerFlavor::Msvc => LinkerFlavorCli::Msvc,
|
||||
LinkerFlavor::EmCc => LinkerFlavorCli::Em,
|
||||
LinkerFlavor::Bpf => LinkerFlavorCli::BpfLinker,
|
||||
LinkerFlavor::Ptx => LinkerFlavorCli::PtxLinker,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! flavor_mappings {
|
||||
($((($($flavor:tt)*), $string:expr),)*) => (
|
||||
macro_rules! linker_flavor_cli_impls {
|
||||
($(($($flavor:tt)*) $string:literal)*) => (
|
||||
impl LinkerFlavorCli {
|
||||
pub const fn one_of() -> &'static str {
|
||||
concat!("one of: ", $($string, " ",)*)
|
||||
}
|
||||
|
||||
pub fn from_str(s: &str) -> Option<Self> {
|
||||
pub fn from_str(s: &str) -> Option<LinkerFlavorCli> {
|
||||
Some(match s {
|
||||
$($string => $($flavor)*,)*
|
||||
_ => return None,
|
||||
@ -200,18 +196,17 @@ pub fn desc(&self) -> &str {
|
||||
)
|
||||
}
|
||||
|
||||
flavor_mappings! {
|
||||
((LinkerFlavorCli::Em), "em"),
|
||||
((LinkerFlavorCli::Gcc), "gcc"),
|
||||
((LinkerFlavorCli::L4Bender), "l4-bender"),
|
||||
((LinkerFlavorCli::Ld), "ld"),
|
||||
((LinkerFlavorCli::Msvc), "msvc"),
|
||||
((LinkerFlavorCli::PtxLinker), "ptx-linker"),
|
||||
((LinkerFlavorCli::BpfLinker), "bpf-linker"),
|
||||
((LinkerFlavorCli::Lld(LldFlavor::Wasm)), "wasm-ld"),
|
||||
((LinkerFlavorCli::Lld(LldFlavor::Ld64)), "ld64.lld"),
|
||||
((LinkerFlavorCli::Lld(LldFlavor::Ld)), "ld.lld"),
|
||||
((LinkerFlavorCli::Lld(LldFlavor::Link)), "lld-link"),
|
||||
linker_flavor_cli_impls! {
|
||||
(LinkerFlavorCli::Gcc) "gcc"
|
||||
(LinkerFlavorCli::Ld) "ld"
|
||||
(LinkerFlavorCli::Lld(LldFlavor::Ld)) "ld.lld"
|
||||
(LinkerFlavorCli::Lld(LldFlavor::Ld64)) "ld64.lld"
|
||||
(LinkerFlavorCli::Lld(LldFlavor::Link)) "lld-link"
|
||||
(LinkerFlavorCli::Lld(LldFlavor::Wasm)) "wasm-ld"
|
||||
(LinkerFlavorCli::Msvc) "msvc"
|
||||
(LinkerFlavorCli::Em) "em"
|
||||
(LinkerFlavorCli::BpfLinker) "bpf-linker"
|
||||
(LinkerFlavorCli::PtxLinker) "ptx-linker"
|
||||
}
|
||||
|
||||
impl ToJson for LinkerFlavorCli {
|
||||
@ -1252,21 +1247,21 @@ pub struct TargetOptions {
|
||||
pub abi: StaticCow<str>,
|
||||
/// Vendor name to use for conditional compilation (`target_vendor`). Defaults to "unknown".
|
||||
pub vendor: StaticCow<str>,
|
||||
|
||||
/// Linker to invoke
|
||||
pub linker: Option<StaticCow<str>>,
|
||||
/// Default linker flavor used if `-C linker-flavor` or `-C linker` are not passed
|
||||
/// on the command line. Defaults to `LinkerFlavor::Gcc`.
|
||||
pub linker_flavor: LinkerFlavor,
|
||||
linker_flavor_json: LinkerFlavorCli,
|
||||
|
||||
/// Linker to invoke
|
||||
pub linker: Option<StaticCow<str>>,
|
||||
|
||||
/// LLD flavor used if `lld` (or `rust-lld`) is specified as a linker
|
||||
/// without clarifying its flavor in any way.
|
||||
/// FIXME: Merge this into `LinkerFlavor`.
|
||||
pub lld_flavor: LldFlavor,
|
||||
/// Whether the linker support GNU-like arguments such as -O. Defaults to true.
|
||||
/// FIXME: Merge this into `LinkerFlavor`.
|
||||
pub linker_is_gnu: bool,
|
||||
|
||||
/// Linker arguments that are passed *before* any user-defined libraries.
|
||||
pub pre_link_args: LinkArgs,
|
||||
pre_link_args_json: LinkArgsCli,
|
||||
/// Objects to link before and after all other object code.
|
||||
pub pre_link_objects: CrtObjects,
|
||||
pub post_link_objects: CrtObjects,
|
||||
@ -1275,6 +1270,9 @@ pub struct TargetOptions {
|
||||
pub post_link_objects_self_contained: CrtObjects,
|
||||
pub link_self_contained: LinkSelfContainedDefault,
|
||||
|
||||
/// Linker arguments that are passed *before* any user-defined libraries.
|
||||
pub pre_link_args: LinkArgs,
|
||||
pre_link_args_json: LinkArgsCli,
|
||||
/// Linker arguments that are unconditionally passed after any
|
||||
/// user-defined but before post-link objects. Standard platform
|
||||
/// libraries that should be always be linked to, usually go here.
|
||||
@ -1292,11 +1290,11 @@ pub struct TargetOptions {
|
||||
/// user-defined libraries.
|
||||
pub post_link_args: LinkArgs,
|
||||
post_link_args_json: LinkArgsCli,
|
||||
|
||||
/// Optional link script applied to `dylib` and `executable` crate types.
|
||||
/// This is a string containing the script, not a path. Can only be applied
|
||||
/// to linkers where `linker_is_gnu` is true.
|
||||
pub link_script: Option<StaticCow<str>>,
|
||||
|
||||
/// Environment variables to be set for the linker invocation.
|
||||
pub link_env: StaticCow<[(StaticCow<str>, StaticCow<str>)]>,
|
||||
/// Environment variables to be removed for the linker invocation.
|
||||
@ -1381,8 +1379,6 @@ pub struct TargetOptions {
|
||||
/// Default supported version of DWARF on this platform.
|
||||
/// Useful because some platforms (osx, bsd) only want up to DWARF2.
|
||||
pub default_dwarf_version: u32,
|
||||
/// Whether the linker support GNU-like arguments such as -O. Defaults to true.
|
||||
pub linker_is_gnu: bool,
|
||||
/// The MinGW toolchain has a known issue that prevents it from correctly
|
||||
/// handling COFF object files with more than 2<sup>15</sup> sections. Since each weak
|
||||
/// symbol needs its own COMDAT section, weak linkage implies a large
|
||||
@ -1580,11 +1576,7 @@ fn add_link_args(link_args: &mut LinkArgs, flavor: LinkerFlavor, args: &[&'stati
|
||||
LinkerFlavor::Lld(lld_flavor) => {
|
||||
panic!("add_link_args: use non-LLD flavor for {:?}", lld_flavor)
|
||||
}
|
||||
LinkerFlavor::Gcc
|
||||
| LinkerFlavor::Em
|
||||
| LinkerFlavor::L4Bender
|
||||
| LinkerFlavor::BpfLinker
|
||||
| LinkerFlavor::PtxLinker => {}
|
||||
LinkerFlavor::Gcc | LinkerFlavor::EmCc | LinkerFlavor::Bpf | LinkerFlavor::Ptx => {}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1646,14 +1638,11 @@ fn default() -> TargetOptions {
|
||||
env: "".into(),
|
||||
abi: "".into(),
|
||||
vendor: "unknown".into(),
|
||||
linker: option_env!("CFG_DEFAULT_LINKER").map(|s| s.into()),
|
||||
linker_flavor: LinkerFlavor::Gcc,
|
||||
linker_flavor_json: LinkerFlavorCli::Gcc,
|
||||
linker: option_env!("CFG_DEFAULT_LINKER").map(|s| s.into()),
|
||||
lld_flavor: LldFlavor::Ld,
|
||||
pre_link_args: LinkArgs::new(),
|
||||
pre_link_args_json: LinkArgsCli::new(),
|
||||
post_link_args: LinkArgs::new(),
|
||||
post_link_args_json: LinkArgsCli::new(),
|
||||
linker_is_gnu: true,
|
||||
link_script: None,
|
||||
asm_args: cvs![],
|
||||
cpu: "generic".into(),
|
||||
@ -1680,7 +1669,6 @@ fn default() -> TargetOptions {
|
||||
is_like_msvc: false,
|
||||
is_like_wasm: false,
|
||||
default_dwarf_version: 4,
|
||||
linker_is_gnu: true,
|
||||
allows_weak_linkage: true,
|
||||
has_rpath: false,
|
||||
no_default_libraries: true,
|
||||
@ -1693,12 +1681,16 @@ fn default() -> TargetOptions {
|
||||
pre_link_objects_self_contained: Default::default(),
|
||||
post_link_objects_self_contained: Default::default(),
|
||||
link_self_contained: LinkSelfContainedDefault::False,
|
||||
pre_link_args: LinkArgs::new(),
|
||||
pre_link_args_json: LinkArgsCli::new(),
|
||||
late_link_args: LinkArgs::new(),
|
||||
late_link_args_json: LinkArgsCli::new(),
|
||||
late_link_args_dynamic: LinkArgs::new(),
|
||||
late_link_args_dynamic_json: LinkArgsCli::new(),
|
||||
late_link_args_static: LinkArgs::new(),
|
||||
late_link_args_static_json: LinkArgsCli::new(),
|
||||
post_link_args: LinkArgs::new(),
|
||||
post_link_args_json: LinkArgsCli::new(),
|
||||
link_env: cvs![],
|
||||
link_env_remove: cvs![],
|
||||
archive_format: "gnu".into(),
|
||||
@ -2283,9 +2275,10 @@ macro_rules! key {
|
||||
key!(env);
|
||||
key!(abi);
|
||||
key!(vendor);
|
||||
key!(linker_flavor_json = "linker-flavor", LinkerFlavor)?;
|
||||
key!(linker, optional);
|
||||
key!(linker_flavor_json = "linker-flavor", LinkerFlavor)?;
|
||||
key!(lld_flavor, LldFlavor)?;
|
||||
key!(linker_is_gnu, bool);
|
||||
key!(pre_link_objects = "pre-link-objects", link_objects);
|
||||
key!(post_link_objects = "post-link-objects", link_objects);
|
||||
key!(pre_link_objects_self_contained = "pre-link-objects-fallback", link_objects);
|
||||
@ -2323,7 +2316,6 @@ macro_rules! key {
|
||||
key!(is_like_msvc, bool);
|
||||
key!(is_like_wasm, bool);
|
||||
key!(default_dwarf_version, u32);
|
||||
key!(linker_is_gnu, bool);
|
||||
key!(allows_weak_linkage, bool);
|
||||
key!(has_rpath, bool);
|
||||
key!(no_default_libraries, bool);
|
||||
@ -2532,9 +2524,10 @@ macro_rules! target_option_val {
|
||||
target_option_val!(env);
|
||||
target_option_val!(abi);
|
||||
target_option_val!(vendor);
|
||||
target_option_val!(linker_flavor_json, "linker-flavor");
|
||||
target_option_val!(linker);
|
||||
target_option_val!(linker_flavor_json, "linker-flavor");
|
||||
target_option_val!(lld_flavor);
|
||||
target_option_val!(linker_is_gnu);
|
||||
target_option_val!(pre_link_objects);
|
||||
target_option_val!(post_link_objects);
|
||||
target_option_val!(pre_link_objects_self_contained, "pre-link-objects-fallback");
|
||||
@ -2573,7 +2566,6 @@ macro_rules! target_option_val {
|
||||
target_option_val!(is_like_msvc);
|
||||
target_option_val!(is_like_wasm);
|
||||
target_option_val!(default_dwarf_version);
|
||||
target_option_val!(linker_is_gnu);
|
||||
target_option_val!(allows_weak_linkage);
|
||||
target_option_val!(has_rpath);
|
||||
target_option_val!(no_default_libraries);
|
||||
|
@ -10,7 +10,7 @@ pub fn target() -> Target {
|
||||
options: TargetOptions {
|
||||
os: "cuda".into(),
|
||||
vendor: "nvidia".into(),
|
||||
linker_flavor: LinkerFlavor::PtxLinker,
|
||||
linker_flavor: LinkerFlavor::Ptx,
|
||||
// The linker can be installed from `crates.io`.
|
||||
linker: Some("rust-ptx-linker".into()),
|
||||
linker_is_gnu: false,
|
||||
|
@ -24,10 +24,9 @@ fn check_consistency(&self, triple: &str) {
|
||||
assert_eq!(self.is_like_osx, matches!(self.lld_flavor, LldFlavor::Ld64));
|
||||
assert_eq!(self.is_like_msvc, matches!(self.lld_flavor, LldFlavor::Link));
|
||||
assert_eq!(self.is_like_wasm, matches!(self.lld_flavor, LldFlavor::Wasm));
|
||||
assert_eq!(self.os == "l4re", matches!(self.linker_flavor, LinkerFlavor::L4Bender));
|
||||
assert_eq!(self.os == "emscripten", matches!(self.linker_flavor, LinkerFlavor::Em));
|
||||
assert_eq!(self.arch == "bpf", matches!(self.linker_flavor, LinkerFlavor::BpfLinker));
|
||||
assert_eq!(self.arch == "nvptx64", matches!(self.linker_flavor, LinkerFlavor::PtxLinker));
|
||||
assert_eq!(self.os == "emscripten", matches!(self.linker_flavor, LinkerFlavor::EmCc));
|
||||
assert_eq!(self.arch == "bpf", matches!(self.linker_flavor, LinkerFlavor::Bpf));
|
||||
assert_eq!(self.arch == "nvptx64", matches!(self.linker_flavor, LinkerFlavor::Ptx));
|
||||
|
||||
for args in [
|
||||
&self.pre_link_args,
|
||||
@ -67,17 +66,14 @@ fn check_consistency(&self, triple: &str) {
|
||||
LinkerFlavor::Lld(LldFlavor::Wasm) | LinkerFlavor::Gcc
|
||||
)
|
||||
}
|
||||
(LinkerFlavor::L4Bender, LldFlavor::Ld) => {
|
||||
assert_matches!(flavor, LinkerFlavor::L4Bender)
|
||||
(LinkerFlavor::EmCc, LldFlavor::Wasm) => {
|
||||
assert_matches!(flavor, LinkerFlavor::EmCc)
|
||||
}
|
||||
(LinkerFlavor::Em, LldFlavor::Wasm) => {
|
||||
assert_matches!(flavor, LinkerFlavor::Em)
|
||||
(LinkerFlavor::Bpf, LldFlavor::Ld) => {
|
||||
assert_matches!(flavor, LinkerFlavor::Bpf)
|
||||
}
|
||||
(LinkerFlavor::BpfLinker, LldFlavor::Ld) => {
|
||||
assert_matches!(flavor, LinkerFlavor::BpfLinker)
|
||||
}
|
||||
(LinkerFlavor::PtxLinker, LldFlavor::Ld) => {
|
||||
assert_matches!(flavor, LinkerFlavor::PtxLinker)
|
||||
(LinkerFlavor::Ptx, LldFlavor::Ld) => {
|
||||
assert_matches!(flavor, LinkerFlavor::Ptx)
|
||||
}
|
||||
flavors => unreachable!("unexpected flavor combination: {:?}", flavors),
|
||||
}
|
||||
|
@ -5,13 +5,13 @@ pub fn target() -> Target {
|
||||
// Reset flags for non-Em flavors back to empty to satisfy sanity checking tests.
|
||||
let pre_link_args = LinkArgs::new();
|
||||
let post_link_args = TargetOptions::link_args(
|
||||
LinkerFlavor::Em,
|
||||
LinkerFlavor::EmCc,
|
||||
&["-sABORTING_MALLOC=0", "-Wl,--fatal-warnings"],
|
||||
);
|
||||
|
||||
let opts = TargetOptions {
|
||||
os: "emscripten".into(),
|
||||
linker_flavor: LinkerFlavor::Em,
|
||||
linker_flavor: LinkerFlavor::EmCc,
|
||||
// emcc emits two files - a .js file to instantiate the wasm and supply platform
|
||||
// functionality, and a .wasm file.
|
||||
exe_suffix: ".js".into(),
|
||||
|
Loading…
Reference in New Issue
Block a user