Skip to content

Commit 99e7531

Browse files
committed
Auto merge of #124355 - workingjubilee:add-target-family-linux, r=<try>
[EXPERIMENT] Crater adding `target_family = "linux"` The lang team proposed, a while back, [deprecating `target_vendor`](#100343). With five operating systems all from Apple, using very similar, unifying characteristics for each, it is untenable to ask people to `cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos", target_os = "tvos", target_os = "visionos"))`. It is commonly preferred to use `target_vendor = "apple"` for things that are true for all of these OS variants, and we have to offer a replacement that is equally parsimonious. [The "obvious" choice is to add a `target_family = "apple"`](rust-lang/lang-team#102 (comment)). However, [there is a concern that adding a `target_family = "apple"` won't work without massive ecosystem breakage, because of poorly-designed build scripts](rust-lang/lang-team#102 (comment)). But we currently can't crater a test of that effectively, because most tests only test host compilation, and crater only runs on Linux. We could, however, test adding a hypothetical `target_family = "linux"`! This would be a hypothetical `target_family` that unites both `target_os = "linux"` and `target_os = "android"` targets. This isn't necessarily an "apples to apples" comparison (more like "penguins to robots"?) but it seems worth trying. Note that this is **not** a proposal to actually add such a `target_family`. I don't have any arguments about the merits beyond "it seems like a plausible target family we may one day add, it can be added in a way that disrupts relevant build scripts, and it impacts a 'high-value' target". For maximum coverage I have in fact added the relevant `target_family = "apple"` and `target_family = "linux"` also just in case any test suites somehow run cross-compilation tests.
2 parents 6a9758d + e1746e0 commit 99e7531

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

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

+4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
use crate::spec::{base, SanitizerSet, TargetOptions, TlsModel};
22

3+
use crate::spec::cvs;
4+
35
pub fn opts() -> TargetOptions {
46
let mut base = base::linux::opts();
57
base.os = "android".into();
8+
// listing families in different orders seems most chaotic. :^)
9+
base.families = cvs!["unix", "linux"];
610
base.is_like_android = true;
711
base.default_dwarf_version = 2;
812
base.tls_model = TlsModel::Emulated;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ pub fn opts(os: &'static str, arch: Arch) -> TargetOptions {
150150
function_sections: false,
151151
dynamic_linking: true,
152152
pre_link_args: pre_link_args(os, arch, abi),
153-
families: cvs!["unix"],
153+
families: cvs!["apple", "unix"],
154154
is_like_osx: true,
155155
// LLVM notes that macOS 10.11+ and iOS 9+ default
156156
// to v4, so we do the same.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub fn opts() -> TargetOptions {
55
TargetOptions {
66
os: "linux".into(),
77
dynamic_linking: true,
8-
families: cvs!["unix"],
8+
families: cvs!["linux", "unix"],
99
has_rpath: true,
1010
position_independent_executables: true,
1111
relro_level: RelroLevel::Full,

0 commit comments

Comments
 (0)