Skip to content

Commit 49a477d

Browse files
committed
cow! base - part 2
1 parent 7ecf136 commit 49a477d

35 files changed

+132
-97
lines changed
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
1+
use crate::spec::cow;
12
use std::sync::LazyLock;
23

34
use crate::abi::Endian;
45
use crate::spec::{crt_objects, cvs, Cc, CodeModel, LinkOutputKind, LinkerFlavor, TargetOptions};
56

67
pub fn opts() -> TargetOptions {
78
TargetOptions {
8-
abi: "vec-extabi".into(),
9+
abi: cow!("vec-extabi"),
910
code_model: Some(CodeModel::Small),
10-
cpu: "pwr7".into(),
11-
os: "aix".into(),
12-
vendor: "ibm".into(),
11+
cpu: cow!("pwr7"),
12+
os: cow!("aix"),
13+
vendor: cow!("ibm"),
1314
dynamic_linking: true,
1415
endian: Endian::Big,
1516
executables: true,
16-
archive_format: "aix_big".into(),
17+
archive_format: cow!("aix_big"),
1718
families: cvs!["unix"],
1819
has_rpath: false,
1920
has_thread_local: true,
2021
crt_static_respected: true,
2122
linker_flavor: LinkerFlavor::Unix(Cc::No),
22-
linker: Some("ld".into()),
23+
linker: Some(cow!("ld")),
2324
eh_frame_header: false,
2425
is_like_aix: true,
2526
default_dwarf_version: 3,
@@ -30,7 +31,7 @@ pub fn opts() -> TargetOptions {
3031
(LinkOutputKind::DynamicPicExe, &["/usr/lib/crt0_64.o", "/usr/lib/crti_64.o"]),
3132
])
3233
}),
33-
dll_suffix: ".a".into(),
34+
dll_suffix: cow!(".a"),
3435
..TargetOptions::default()
3536
}
3637
}

compiler/rustc_target/src/spec/base/android.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
use crate::spec::cow;
12
use crate::spec::{base, SanitizerSet, TargetOptions, TlsModel};
23

34
pub fn opts() -> TargetOptions {
45
let mut base = base::linux::opts();
5-
base.os = "android".into();
6+
base.os = cow!("android");
67
base.is_like_android = true;
78
base.default_dwarf_version = 2;
89
base.tls_model = TlsModel::Emulated;

compiler/rustc_target/src/spec/base/apple/mod.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::spec::cow;
12
use std::marker::ConstParamTy;
23
use std::sync::LazyLock;
34
use std::{borrow::Cow, env};
@@ -131,7 +132,7 @@ pub fn pre_link_args(os: &'static str, arch: Arch, abi: &'static str) -> LinkArg
131132
add_link_args_iter(
132133
&mut args,
133134
LinkerFlavor::Darwin(Cc::Yes, Lld::No),
134-
["-target".into(), mac_catalyst_llvm_target(arch).into()].into_iter(),
135+
[cow!("-target"), mac_catalyst_llvm_target(arch).into()].into_iter(),
135136
);
136137
}
137138

@@ -146,7 +147,7 @@ pub fn opts(os: &'static str, arch: Arch) -> TargetOptions {
146147
os: os.into(),
147148
cpu: arch.target_cpu().into(),
148149
link_env_remove: link_env_remove(os),
149-
vendor: "apple".into(),
150+
vendor: cow!("apple"),
150151
linker_flavor: LinkerFlavor::Darwin(Cc::Yes, Lld::No),
151152
// macOS has -dead_strip, which doesn't rely on function_sections
152153
function_sections: false,
@@ -160,8 +161,8 @@ pub fn opts(os: &'static str, arch: Arch) -> TargetOptions {
160161
default_dwarf_version: 4,
161162
frame_pointer: FramePointer::Always,
162163
has_rpath: true,
163-
dll_suffix: ".dylib".into(),
164-
archive_format: "darwin".into(),
164+
dll_suffix: cow!(".dylib"),
165+
archive_format: cow!("darwin"),
165166
// Thread locals became available with iOS 8 and macOS 10.7,
166167
// and both are far below our minimum.
167168
has_thread_local: true,
@@ -294,14 +295,14 @@ fn link_env_remove(os: &'static str) -> StaticCow<[StaticCow<str>]> {
294295
|| sdkroot.contains("WatchOS.platform")
295296
|| sdkroot.contains("WatchSimulator.platform")
296297
{
297-
env_remove.push("SDKROOT".into())
298+
env_remove.push(cow!("SDKROOT"))
298299
}
299300
}
300301
// Additionally, `IPHONEOS_DEPLOYMENT_TARGET` must not be set when using the Xcode linker at
301302
// "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld",
302303
// although this is apparently ignored when using the linker at "/usr/bin/ld".
303-
env_remove.push("IPHONEOS_DEPLOYMENT_TARGET".into());
304-
env_remove.push("TVOS_DEPLOYMENT_TARGET".into());
304+
env_remove.push(cow!("IPHONEOS_DEPLOYMENT_TARGET"));
305+
env_remove.push(cow!("TVOS_DEPLOYMENT_TARGET"));
305306
env_remove.into()
306307
} else {
307308
// Otherwise if cross-compiling for a different OS/SDK (including Mac Catalyst), remove any part

compiler/rustc_target/src/spec/base/avr_gnu.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::spec::cow;
12
use std::sync::LazyLock;
23

34
use crate::spec::{Cc, LinkerFlavor, Lld, RelocModel, Target, TargetOptions};
@@ -9,16 +10,16 @@ use object::elf;
910
/// FIXME: Remove the second parameter when const string concatenation is possible.
1011
pub fn target<const MMCU: &'static str>(target_cpu: &'static str) -> Target {
1112
Target {
12-
arch: "avr".into(),
13-
data_layout: "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8".into(),
14-
llvm_target: "avr-unknown-unknown".into(),
13+
arch: cow!("avr"),
14+
data_layout: cow!("e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8"),
15+
llvm_target: cow!("avr-unknown-unknown"),
1516
pointer_width: 16,
1617
options: TargetOptions {
17-
c_int_width: "16".into(),
18+
c_int_width: cow!("16"),
1819
cpu: target_cpu.into(),
19-
exe_suffix: ".elf".into(),
20+
exe_suffix: cow!(".elf"),
2021

21-
linker: Some("avr-gcc".into()),
22+
linker: Some(cow!("avr-gcc")),
2223
eh_frame_header: false,
2324
pre_link_args: LazyLock::new(|| {
2425
TargetOptions::link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &[MMCU])

compiler/rustc_target/src/spec/base/dragonfly.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
use crate::spec::cow;
12
use crate::spec::{cvs, RelroLevel, TargetOptions};
23

34
pub fn opts() -> TargetOptions {
45
TargetOptions {
5-
os: "dragonfly".into(),
6+
os: cow!("dragonfly"),
67
dynamic_linking: true,
78
families: cvs!["unix"],
89
has_rpath: true,

compiler/rustc_target/src/spec/base/freebsd.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
use crate::spec::cow;
12
use crate::spec::{cvs, RelroLevel, TargetOptions};
23

34
pub fn opts() -> TargetOptions {
45
TargetOptions {
5-
os: "freebsd".into(),
6+
os: cow!("freebsd"),
67
dynamic_linking: true,
78
families: cvs!["unix"],
89
has_rpath: true,

compiler/rustc_target/src/spec/base/fuchsia.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1+
use crate::spec::cow;
12
use std::sync::LazyLock;
23

34
use crate::spec::{crt_objects, cvs, Cc, LinkOutputKind, LinkerFlavor, Lld, TargetOptions};
45

56
pub fn opts() -> TargetOptions {
67
TargetOptions {
7-
os: "fuchsia".into(),
8+
os: cow!("fuchsia"),
89
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
9-
linker: Some("rust-lld".into()),
10+
linker: Some(cow!("rust-lld")),
1011
dynamic_linking: true,
1112
families: cvs!["unix"],
1213
// This mirrors the linker options provided by clang. We presume lld for

compiler/rustc_target/src/spec/base/haiku.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
use crate::spec::cow;
12
use crate::spec::{cvs, RelroLevel, TargetOptions};
23

34
pub fn opts() -> TargetOptions {
45
TargetOptions {
5-
os: "haiku".into(),
6+
os: cow!("haiku"),
67
dynamic_linking: true,
78
families: cvs!["unix"],
89
relro_level: RelroLevel::Full,

compiler/rustc_target/src/spec/base/hermit.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
use crate::spec::cow;
12
use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, TargetOptions, TlsModel};
23

34
pub fn opts() -> TargetOptions {
45
TargetOptions {
5-
os: "hermit".into(),
6-
linker: Some("rust-lld".into()),
6+
os: cow!("hermit"),
7+
linker: Some(cow!("rust-lld")),
78
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
89
tls_model: TlsModel::InitialExec,
910
position_independent_executables: true,

compiler/rustc_target/src/spec/base/hurd.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
use crate::spec::cow;
12
use crate::spec::{cvs, RelroLevel, TargetOptions};
23

34
pub fn opts() -> TargetOptions {
45
TargetOptions {
5-
os: "hurd".into(),
6+
os: cow!("hurd"),
67
dynamic_linking: true,
78
families: cvs!["unix"],
89
has_rpath: true,
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
use crate::spec::cow;
12
use crate::spec::{base, TargetOptions};
23

34
pub fn opts() -> TargetOptions {
4-
TargetOptions { env: "gnu".into(), ..base::hurd::opts() }
5+
TargetOptions { env: cow!("gnu"), ..base::hurd::opts() }
56
}

compiler/rustc_target/src/spec/base/illumos.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
use crate::spec::cow;
12
use std::sync::LazyLock;
23

34
use crate::spec::{cvs, Cc, FramePointer, LinkerFlavor, TargetOptions};
45

56
pub fn opts() -> TargetOptions {
67
TargetOptions {
7-
os: "illumos".into(),
8+
os: cow!("illumos"),
89
dynamic_linking: true,
910
has_rpath: true,
1011
families: cvs!["unix"],
@@ -54,8 +55,8 @@ pub fn opts() -> TargetOptions {
5455
//
5556
// We want XPG6 behavior from libc and libm. See standards(5)
5657
//pre_link_objects_exe: vec![
57-
// "/usr/lib/amd64/values-Xc.o".into(),
58-
// "/usr/lib/amd64/values-xpg6.o".into(),
58+
// cow!("/usr/lib/amd64/values-Xc.o"),
59+
// cow!("/usr/lib/amd64/values-xpg6.o"),
5960
//],
6061
..TargetOptions::default()
6162
}

compiler/rustc_target/src/spec/base/l4re.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1+
use crate::spec::cow;
12
use crate::spec::{cvs, Cc, LinkerFlavor, PanicStrategy, RelocModel, TargetOptions};
23

34
pub fn opts() -> TargetOptions {
45
TargetOptions {
5-
os: "l4re".into(),
6-
env: "uclibc".into(),
6+
os: cow!("l4re"),
7+
env: cow!("uclibc"),
78
linker_flavor: LinkerFlavor::Unix(Cc::No),
89
panic_strategy: PanicStrategy::Abort,
9-
linker: Some("l4-bender".into()),
10+
linker: Some(cow!("l4-bender")),
1011
families: cvs!["unix"],
1112
relocation_model: RelocModel::Static,
1213
..TargetOptions::default()

compiler/rustc_target/src/spec/base/linux.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
use crate::spec::cow;
12
use crate::spec::{cvs, RelroLevel, SplitDebuginfo, TargetOptions};
23
use std::borrow::Cow;
34

45
pub fn opts() -> TargetOptions {
56
TargetOptions {
6-
os: "linux".into(),
7+
os: cow!("linux"),
78
dynamic_linking: true,
89
families: cvs!["unix"],
910
has_rpath: true,
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
use crate::spec::cow;
12
use crate::spec::{base, TargetOptions};
23

34
pub fn opts() -> TargetOptions {
4-
TargetOptions { env: "gnu".into(), ..base::linux::opts() }
5+
TargetOptions { env: cow!("gnu"), ..base::linux::opts() }
56
}

compiler/rustc_target/src/spec/base/linux_musl.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::spec::cow;
12
use std::sync::LazyLock;
23

34
use crate::spec::crt_objects;
@@ -6,7 +7,7 @@ use crate::spec::{base, LinkSelfContainedDefault, TargetOptions};
67
pub fn opts() -> TargetOptions {
78
let mut base = base::linux::opts();
89

9-
base.env = "musl".into();
10+
base.env = cow!("musl");
1011
base.pre_link_objects_self_contained = LazyLock::new(|| crt_objects::pre_musl_self_contained());
1112
base.post_link_objects_self_contained =
1213
LazyLock::new(|| crt_objects::post_musl_self_contained());

compiler/rustc_target/src/spec/base/linux_ohos.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
use crate::spec::cow;
12
use crate::spec::{base, TargetOptions, TlsModel};
23

34
pub fn opts() -> TargetOptions {
45
let mut base = base::linux::opts();
56

6-
base.env = "ohos".into();
7+
base.env = cow!("ohos");
78
base.crt_static_default = false;
89
base.tls_model = TlsModel::Emulated;
910
base.has_thread_local = false;
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
use crate::spec::cow;
12
use crate::spec::{base, TargetOptions};
23

34
pub fn opts() -> TargetOptions {
4-
TargetOptions { env: "uclibc".into(), ..base::linux::opts() }
5+
TargetOptions { env: cow!("uclibc"), ..base::linux::opts() }
56
}

compiler/rustc_target/src/spec/base/netbsd.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
use crate::spec::cow;
12
use crate::spec::{cvs, RelroLevel, TargetOptions};
23

34
pub fn opts() -> TargetOptions {
45
TargetOptions {
5-
os: "netbsd".into(),
6+
os: cow!("netbsd"),
67
dynamic_linking: true,
78
families: cvs!["unix"],
89
no_default_libraries: false,

compiler/rustc_target/src/spec/base/nto_qnx.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::spec::cow;
12
use crate::spec::{cvs, RelroLevel, TargetOptions};
23

34
pub fn opts() -> TargetOptions {
@@ -8,8 +9,8 @@ pub fn opts() -> TargetOptions {
89
families: cvs!["unix"],
910
has_rpath: true,
1011
has_thread_local: false,
11-
linker: Some("qcc".into()),
12-
os: "nto".into(),
12+
linker: Some(cow!("qcc")),
13+
os: cow!("nto"),
1314
position_independent_executables: true,
1415
static_position_independent_executables: true,
1516
relro_level: RelroLevel::Full,

compiler/rustc_target/src/spec/base/openbsd.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
use crate::spec::cow;
12
use crate::spec::{cvs, FramePointer, RelroLevel, TargetOptions, TlsModel};
23

34
pub fn opts() -> TargetOptions {
45
TargetOptions {
5-
os: "openbsd".into(),
6+
os: cow!("openbsd"),
67
dynamic_linking: true,
78
families: cvs!["unix"],
89
has_rpath: true,

compiler/rustc_target/src/spec/base/redox.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
use crate::spec::cow;
12
use crate::spec::{cvs, RelroLevel, TargetOptions};
23

34
pub fn opts() -> TargetOptions {
45
TargetOptions {
5-
os: "redox".into(),
6-
env: "relibc".into(),
6+
os: cow!("redox"),
7+
env: cow!("relibc"),
78
dynamic_linking: true,
89
families: cvs!["unix"],
910
has_rpath: true,

compiler/rustc_target/src/spec/base/solaris.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
use crate::spec::cow;
12
use crate::spec::{cvs, Cc, LinkerFlavor, TargetOptions};
23

34
pub fn opts() -> TargetOptions {
45
TargetOptions {
5-
os: "solaris".into(),
6+
os: cow!("solaris"),
67
dynamic_linking: true,
78
has_rpath: true,
89
families: cvs!["unix"],

compiler/rustc_target/src/spec/base/solid.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
use crate::spec::cow;
12
use crate::spec::{FramePointer, TargetOptions};
23

34
pub fn opts(kernel: &str) -> TargetOptions {
45
TargetOptions {
56
os: format!("solid_{kernel}").into(),
6-
vendor: "kmc".into(),
7+
vendor: cow!("kmc"),
78
executables: false,
89
frame_pointer: FramePointer::NonLeaf,
910
has_thread_local: true,

compiler/rustc_target/src/spec/base/teeos.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
use crate::spec::cow;
12
use std::sync::LazyLock;
23

34
use crate::spec::{add_link_args, Cc, LinkerFlavor, Lld, PanicStrategy, RelroLevel, TargetOptions};
45

56
pub fn opts() -> TargetOptions {
67
TargetOptions {
7-
os: "teeos".into(),
8-
vendor: "unknown".into(),
8+
os: cow!("teeos"),
9+
vendor: cow!("unknown"),
910
dynamic_linking: true,
1011
linker_flavor: LinkerFlavor::Gnu(Cc::Yes, Lld::No),
1112
// rpath hardcodes -Wl, so it can't be used together with ld.lld.

0 commit comments

Comments
 (0)