Skip to content

Commit 0229685

Browse files
authored
Unrolled build for rust-lang#117702
Rollup merge of rust-lang#117702 - davidtwco:target-tier-refactors, r=petrochenkov target: move base and target specifications Follow-up to rust-lang#116004. In anticipation of later PRs where we'll want to add tidy checks to ensure that, for each target, we have a test or a platform support document or something like that, this PR moves target specifications into a directory on their own so that we can just list the files in this directory to get a list of all targets. - Base specifications are moved to `rustc_target::spec::base`. - Target specifications are moved to `rustc_target::spec::targets`. - All the other source files containing types used in the target specs remain in `rustc_target::spec`. - `rustc_target/src/spec/abi.rs` is moved to `rustc_target/src/spec/abi/mod.rs` (where there was already a `tests.rs`) for uniformity. r? ``@petrochenkov``
2 parents 341efb1 + ef7ebaa commit 0229685

File tree

274 files changed

+479
-475
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

274 files changed

+479
-475
lines changed

compiler/rustc_target/src/spec/aarch64_fuchsia.rs

-1
This file was deleted.

compiler/rustc_target/src/spec/avr_unknown_gnu_atmega328.rs

-5
This file was deleted.

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use crate::spec::{SanitizerSet, TargetOptions};
1+
use crate::spec::{base, SanitizerSet, TargetOptions};
22

33
pub fn opts() -> TargetOptions {
4-
let mut base = super::linux_base::opts();
4+
let mut base = base::linux::opts();
55
base.os = "android".into();
66
base.is_like_android = true;
77
base.default_dwarf_version = 2;

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use std::{borrow::Cow, env};
22

3+
use crate::spec::{add_link_args, add_link_args_iter};
34
use crate::spec::{cvs, Cc, DebuginfoKind, FramePointer, LinkArgs};
45
use crate::spec::{LinkerFlavor, Lld, SplitDebuginfo, StaticCow, Target, TargetOptions};
56

67
#[cfg(test)]
7-
#[path = "apple/tests.rs"]
88
mod tests;
99

1010
use Arch::*;
@@ -102,13 +102,13 @@ fn pre_link_args(os: &'static str, arch: Arch, abi: &'static str) -> LinkArgs {
102102
LinkerFlavor::Darwin(Cc::No, Lld::No),
103103
&["-arch", arch, "-platform_version"],
104104
);
105-
super::add_link_args_iter(
105+
add_link_args_iter(
106106
&mut args,
107107
LinkerFlavor::Darwin(Cc::No, Lld::No),
108108
[platform_name, platform_version.clone(), platform_version].into_iter(),
109109
);
110110
if abi != "macabi" {
111-
super::add_link_args(&mut args, LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-arch", arch]);
111+
add_link_args(&mut args, LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-arch", arch]);
112112
}
113113

114114
args

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::spec::{
1+
use crate::spec::targets::{
22
aarch64_apple_darwin, aarch64_apple_ios_sim, aarch64_apple_watchos_sim, i686_apple_darwin,
33
x86_64_apple_darwin, x86_64_apple_ios, x86_64_apple_tvos, x86_64_apple_watchos_sim,
44
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
use crate::spec::{base, TargetOptions};
2+
3+
pub fn opts() -> TargetOptions {
4+
TargetOptions { env: "gnu".into(), ..base::hurd::opts() }
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
use crate::spec::{base, TargetOptions};
2+
3+
pub fn opts() -> TargetOptions {
4+
TargetOptions { env: "gnu".into(), ..base::linux::opts() }
5+
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::spec::crt_objects;
2-
use crate::spec::{LinkSelfContainedDefault, TargetOptions};
2+
use crate::spec::{base, LinkSelfContainedDefault, TargetOptions};
33

44
pub fn opts() -> TargetOptions {
5-
let mut base = super::linux_base::opts();
5+
let mut base = base::linux::opts();
66

77
base.env = "musl".into();
88
base.pre_link_objects_self_contained = crt_objects::pre_musl_self_contained();

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use crate::spec::TargetOptions;
1+
use crate::spec::{base, TargetOptions};
22

33
pub fn opts() -> TargetOptions {
4-
let mut base = super::linux_base::opts();
4+
let mut base = base::linux::opts();
55

66
base.env = "ohos".into();
77
base.crt_static_default = false;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
use crate::spec::{base, TargetOptions};
2+
3+
pub fn opts() -> TargetOptions {
4+
TargetOptions { env: "uclibc".into(), ..base::linux::opts() }
5+
}
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
pub(crate) mod aix;
2+
pub(crate) mod android;
3+
pub(crate) mod apple;
4+
pub(crate) mod avr_gnu;
5+
pub(crate) mod bpf;
6+
pub(crate) mod dragonfly;
7+
pub(crate) mod freebsd;
8+
pub(crate) mod fuchsia;
9+
pub(crate) mod haiku;
10+
pub(crate) mod hermit;
11+
pub(crate) mod hurd;
12+
pub(crate) mod hurd_gnu;
13+
pub(crate) mod illumos;
14+
pub(crate) mod l4re;
15+
pub(crate) mod linux;
16+
pub(crate) mod linux_gnu;
17+
pub(crate) mod linux_musl;
18+
pub(crate) mod linux_ohos;
19+
pub(crate) mod linux_uclibc;
20+
pub(crate) mod msvc;
21+
pub(crate) mod netbsd;
22+
pub(crate) mod nto_qnx;
23+
pub(crate) mod openbsd;
24+
pub(crate) mod redox;
25+
pub(crate) mod solaris;
26+
pub(crate) mod solid;
27+
pub(crate) mod teeos;
28+
pub(crate) mod thumb;
29+
pub(crate) mod uefi_msvc;
30+
pub(crate) mod unikraft_linux_musl;
31+
pub(crate) mod vxworks;
32+
pub(crate) mod wasm;
33+
pub(crate) mod windows_gnu;
34+
pub(crate) mod windows_gnullvm;
35+
pub(crate) mod windows_msvc;
36+
pub(crate) mod windows_uwp_gnu;
37+
pub(crate) mod windows_uwp_msvc;

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use super::FramePointer;
2-
use crate::spec::TargetOptions;
1+
use crate::spec::{FramePointer, TargetOptions};
32

43
pub fn opts(kernel: &str) -> TargetOptions {
54
TargetOptions {

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
use super::{Cc, LinkerFlavor, Lld, PanicStrategy};
2-
use crate::spec::{RelroLevel, TargetOptions};
1+
use crate::spec::{add_link_args, Cc, LinkerFlavor, Lld, PanicStrategy, RelroLevel, TargetOptions};
32

43
pub fn opts() -> TargetOptions {
54
let lld_args = &["-zmax-page-size=4096", "-znow", "-ztext", "--execute-only"];
65
let cc_args = &["-Wl,-zmax-page-size=4096", "-Wl,-znow", "-Wl,-ztext", "-mexecute-only"];
76

87
let mut pre_link_args = TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), lld_args);
9-
super::add_link_args(&mut pre_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), cc_args);
8+
add_link_args(&mut pre_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), cc_args);
109

1110
TargetOptions {
1211
os: "teeos".into(),

compiler/rustc_target/src/spec/uefi_msvc_base.rs compiler/rustc_target/src/spec/base/uefi_msvc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
// the timer-interrupt. Device-drivers are required to use polling-based models. Furthermore, all
1010
// code runs in the same environment, no process separation is supported.
1111

12-
use crate::spec::{LinkerFlavor, Lld, PanicStrategy, StackProbeType, TargetOptions};
12+
use crate::spec::{base, LinkerFlavor, Lld, PanicStrategy, StackProbeType, TargetOptions};
1313

1414
pub fn opts() -> TargetOptions {
15-
let mut base = super::msvc_base::opts();
15+
let mut base = base::msvc::opts();
1616

1717
base.add_pre_link_args(
1818
LinkerFlavor::Msvc(Lld::No),

compiler/rustc_target/src/spec/wasm_base.rs compiler/rustc_target/src/spec/base/wasm.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
use super::LinkSelfContainedDefault;
2-
use super::{cvs, Cc, LinkerFlavor, PanicStrategy, RelocModel, TargetOptions, TlsModel};
1+
use crate::spec::{
2+
add_link_args, cvs, Cc, LinkSelfContainedDefault, LinkerFlavor, PanicStrategy, RelocModel,
3+
TargetOptions, TlsModel,
4+
};
35

46
pub fn options() -> TargetOptions {
57
macro_rules! args {
@@ -50,7 +52,7 @@ pub fn options() -> TargetOptions {
5052
}
5153

5254
let mut pre_link_args = TargetOptions::link_args(LinkerFlavor::WasmLld(Cc::No), args!(""));
53-
super::add_link_args(&mut pre_link_args, LinkerFlavor::WasmLld(Cc::Yes), args!("-Wl,"));
55+
add_link_args(&mut pre_link_args, LinkerFlavor::WasmLld(Cc::Yes), args!("-Wl,"));
5456

5557
TargetOptions {
5658
is_like_wasm: true,

compiler/rustc_target/src/spec/windows_gnu_base.rs compiler/rustc_target/src/spec/base/windows_gnu.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::spec::crt_objects;
21
use crate::spec::LinkSelfContainedDefault;
2+
use crate::spec::{add_link_args, crt_objects};
33
use crate::spec::{cvs, Cc, DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, TargetOptions};
44
use std::borrow::Cow;
55

@@ -13,7 +13,7 @@ pub fn opts() -> TargetOptions {
1313
"--disable-auto-image-base",
1414
],
1515
);
16-
super::add_link_args(
16+
add_link_args(
1717
&mut pre_link_args,
1818
LinkerFlavor::Gnu(Cc::Yes, Lld::No),
1919
&[
@@ -45,14 +45,14 @@ pub fn opts() -> TargetOptions {
4545
];
4646
let mut late_link_args =
4747
TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), mingw_libs);
48-
super::add_link_args(&mut late_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), mingw_libs);
48+
add_link_args(&mut late_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), mingw_libs);
4949
// If any of our crates are dynamically linked then we need to use
5050
// the shared libgcc_s-dw2-1.dll. This is required to support
5151
// unwinding across DLL boundaries.
5252
let dynamic_unwind_libs = &["-lgcc_s"];
5353
let mut late_link_args_dynamic =
5454
TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), dynamic_unwind_libs);
55-
super::add_link_args(
55+
add_link_args(
5656
&mut late_link_args_dynamic,
5757
LinkerFlavor::Gnu(Cc::Yes, Lld::No),
5858
dynamic_unwind_libs,
@@ -65,7 +65,7 @@ pub fn opts() -> TargetOptions {
6565
let static_unwind_libs = &["-lgcc_eh", "-l:libpthread.a"];
6666
let mut late_link_args_static =
6767
TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), static_unwind_libs);
68-
super::add_link_args(
68+
add_link_args(
6969
&mut late_link_args_static,
7070
LinkerFlavor::Gnu(Cc::Yes, Lld::No),
7171
static_unwind_libs,

compiler/rustc_target/src/spec/windows_msvc_base.rs compiler/rustc_target/src/spec/base/windows_msvc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use crate::spec::{cvs, TargetOptions};
1+
use crate::spec::{base, cvs, TargetOptions};
22

33
pub fn opts() -> TargetOptions {
4-
let base = super::msvc_base::opts();
4+
let base = base::msvc::opts();
55

66
TargetOptions {
77
os: "windows".into(),

compiler/rustc_target/src/spec/windows_uwp_gnu_base.rs compiler/rustc_target/src/spec/base/windows_uwp_gnu.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use crate::spec::{Cc, LinkArgs, LinkerFlavor, Lld, TargetOptions};
1+
use crate::spec::{add_link_args, base, Cc, LinkArgs, LinkerFlavor, Lld, TargetOptions};
22

33
pub fn opts() -> TargetOptions {
4-
let base = super::windows_gnu_base::opts();
4+
let base = base::windows_gnu::opts();
55

66
// FIXME: This should be updated for the exception machinery changes from #67502
77
// and inherit from `windows_gnu_base`, at least partially.
@@ -17,7 +17,7 @@ pub fn opts() -> TargetOptions {
1717
];
1818
let mut late_link_args =
1919
TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), mingw_libs);
20-
super::add_link_args(&mut late_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), mingw_libs);
20+
add_link_args(&mut late_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), mingw_libs);
2121
// Reset the flags back to empty until the FIXME above is addressed.
2222
let late_link_args_dynamic = LinkArgs::new();
2323
let late_link_args_static = LinkArgs::new();

compiler/rustc_target/src/spec/windows_uwp_msvc_base.rs compiler/rustc_target/src/spec/base/windows_uwp_msvc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use crate::spec::{LinkerFlavor, Lld, TargetOptions};
1+
use crate::spec::{base, LinkerFlavor, Lld, TargetOptions};
22

33
pub fn opts() -> TargetOptions {
4-
let mut opts = super::windows_msvc_base::opts();
4+
let mut opts = base::windows_msvc::opts();
55

66
opts.abi = "uwp".into();
77
opts.vendor = "uwp".into();

compiler/rustc_target/src/spec/hurd_gnu_base.rs

-5
This file was deleted.

compiler/rustc_target/src/spec/linux_gnu_base.rs

-5
This file was deleted.

compiler/rustc_target/src/spec/linux_uclibc_base.rs

-5
This file was deleted.

compiler/rustc_target/src/spec/mod.rs

+10-44
Original file line numberDiff line numberDiff line change
@@ -57,47 +57,11 @@ use rustc_macros::HashStable_Generic;
5757
pub mod abi;
5858
pub mod crt_objects;
5959

60-
mod aix_base;
61-
mod android_base;
62-
mod apple_base;
63-
pub use apple_base::deployment_target as current_apple_deployment_target;
64-
pub use apple_base::platform as current_apple_platform;
65-
pub use apple_base::sdk_version as current_apple_sdk_version;
66-
mod avr_gnu_base;
67-
pub use avr_gnu_base::ef_avr_arch;
68-
mod bpf_base;
69-
mod dragonfly_base;
70-
mod freebsd_base;
71-
mod fuchsia_base;
72-
mod haiku_base;
73-
mod hermit_base;
74-
mod hurd_base;
75-
mod hurd_gnu_base;
76-
mod illumos_base;
77-
mod l4re_base;
78-
mod linux_base;
79-
mod linux_gnu_base;
80-
mod linux_musl_base;
81-
mod linux_ohos_base;
82-
mod linux_uclibc_base;
83-
mod msvc_base;
84-
mod netbsd_base;
85-
mod nto_qnx_base;
86-
mod openbsd_base;
87-
mod redox_base;
88-
mod solaris_base;
89-
mod solid_base;
90-
mod teeos_base;
91-
mod thumb_base;
92-
mod uefi_msvc_base;
93-
mod unikraft_linux_musl_base;
94-
mod vxworks_base;
95-
mod wasm_base;
96-
mod windows_gnu_base;
97-
mod windows_gnullvm_base;
98-
mod windows_msvc_base;
99-
mod windows_uwp_gnu_base;
100-
mod windows_uwp_msvc_base;
60+
mod base;
61+
pub use base::apple::deployment_target as current_apple_deployment_target;
62+
pub use base::apple::platform as current_apple_platform;
63+
pub use base::apple::sdk_version as current_apple_sdk_version;
64+
pub use base::avr_gnu::ef_avr_arch;
10165

10266
/// Linker is called through a C/C++ compiler.
10367
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
@@ -1444,14 +1408,16 @@ impl fmt::Display for StackProtector {
14441408

14451409
macro_rules! supported_targets {
14461410
( $(($triple:literal, $module:ident),)+ ) => {
1447-
$(mod $module;)+
1411+
mod targets {
1412+
$(pub(crate) mod $module;)+
1413+
}
14481414

14491415
/// List of supported targets
14501416
pub const TARGETS: &[&str] = &[$($triple),+];
14511417

14521418
fn load_builtin(target: &str) -> Option<Target> {
14531419
let mut t = match target {
1454-
$( $triple => $module::target(), )+
1420+
$( $triple => targets::$module::target(), )+
14551421
_ => return None,
14561422
};
14571423
t.is_builtin = true;
@@ -1467,7 +1433,7 @@ macro_rules! supported_targets {
14671433
$(
14681434
#[test] // `#[test]`
14691435
fn $module() {
1470-
tests_impl::test_target(super::$module::target());
1436+
tests_impl::test_target(crate::spec::targets::$module::target());
14711437
}
14721438
)+
14731439
}

compiler/rustc_target/src/spec/aarch64_apple_darwin.rs compiler/rustc_target/src/spec/targets/aarch64_apple_darwin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::apple_base::{macos_llvm_target, opts, Arch};
1+
use crate::spec::base::apple::{macos_llvm_target, opts, Arch};
22
use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions};
33

44
pub fn target() -> Target {

compiler/rustc_target/src/spec/aarch64_apple_ios.rs compiler/rustc_target/src/spec/targets/aarch64_apple_ios.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::apple_base::{ios_llvm_target, opts, Arch};
1+
use crate::spec::base::apple::{ios_llvm_target, opts, Arch};
22
use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions};
33

44
pub fn target() -> Target {

compiler/rustc_target/src/spec/aarch64_apple_ios_macabi.rs compiler/rustc_target/src/spec/targets/aarch64_apple_ios_macabi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::apple_base::{opts, Arch};
1+
use crate::spec::base::apple::{opts, Arch};
22
use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, SanitizerSet, Target, TargetOptions};
33

44
pub fn target() -> Target {

compiler/rustc_target/src/spec/aarch64_apple_ios_sim.rs compiler/rustc_target/src/spec/targets/aarch64_apple_ios_sim.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::apple_base::{ios_sim_llvm_target, opts, Arch};
1+
use crate::spec::base::apple::{ios_sim_llvm_target, opts, Arch};
22
use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions};
33

44
pub fn target() -> Target {

compiler/rustc_target/src/spec/aarch64_apple_tvos.rs compiler/rustc_target/src/spec/targets/aarch64_apple_tvos.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::apple_base::{opts, tvos_llvm_target, Arch};
1+
use crate::spec::base::apple::{opts, tvos_llvm_target, Arch};
22
use crate::spec::{FramePointer, Target, TargetOptions};
33

44
pub fn target() -> Target {

compiler/rustc_target/src/spec/aarch64_apple_tvos_sim.rs compiler/rustc_target/src/spec/targets/aarch64_apple_tvos_sim.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::apple_base::{opts, tvos_sim_llvm_target, Arch};
1+
use crate::spec::base::apple::{opts, tvos_sim_llvm_target, Arch};
22
use crate::spec::{FramePointer, Target, TargetOptions};
33

44
pub fn target() -> Target {

0 commit comments

Comments
 (0)