Skip to content

Commit 9c37c14

Browse files
committed
Update linux_musl base to dynamically link the crt by default
However, don't change the behavior of any existing targets at this time. For targets that used the old default, explicitly set `crt_static_default = true`. This makes it easier for new targets to use the correct defaults while leaving the changing of individual targets to future PRs. Related to rust-lang/compiler-team#422
1 parent 3fee0f1 commit 9c37c14

23 files changed

+37
-7
lines changed

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

-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,5 @@ pub(crate) fn opts() -> TargetOptions {
88
base.post_link_objects_self_contained = crt_objects::post_musl_self_contained();
99
base.link_self_contained = LinkSelfContainedDefault::InferredForMusl;
1010

11-
// These targets statically link libc by default
12-
base.crt_static_default = true;
13-
1411
base
1512
}

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

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ pub(crate) fn target() -> Target {
1212
| SanitizerSet::MEMORY
1313
| SanitizerSet::THREAD;
1414

15+
// FIXME(compiler-team#422): musl targets should be dynamically linked by default.
16+
base.crt_static_default = true;
17+
1518
Target {
1619
llvm_target: "aarch64-unknown-linux-musl".into(),
1720
metadata: crate::spec::TargetMetadata {

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

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ pub(crate) fn target() -> Target {
2222
features: "+strict-align,+v6".into(),
2323
max_atomic_width: Some(64),
2424
mcount: "\u{1}mcount".into(),
25+
// FIXME(compiler-team#422): musl targets should be dynamically linked by default.
26+
crt_static_default: true,
2527
..base::linux_musl::opts()
2628
},
2729
}

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

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ pub(crate) fn target() -> Target {
2222
features: "+strict-align,+v6,+vfp2,-d32".into(),
2323
max_atomic_width: Some(64),
2424
mcount: "\u{1}mcount".into(),
25+
// FIXME(compiler-team#422): musl targets should be dynamically linked by default.
26+
crt_static_default: true,
2527
..base::linux_musl::opts()
2628
},
2729
}

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

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ pub(crate) fn target() -> Target {
2323
max_atomic_width: Some(32),
2424
mcount: "\u{1}mcount".into(),
2525
has_thumb_interworking: true,
26+
// FIXME(compiler-team#422): musl targets should be dynamically linked by default.
27+
crt_static_default: true,
2628
..base::linux_musl::opts()
2729
},
2830
}

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

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ pub(crate) fn target() -> Target {
2626
features: "+v7,+thumb2,+soft-float,-neon".into(),
2727
max_atomic_width: Some(64),
2828
mcount: "\u{1}mcount".into(),
29+
// FIXME(compiler-team#422): musl targets should be dynamically linked by default.
30+
crt_static_default: true,
2931
..base::linux_musl::opts()
3032
},
3133
}

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

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ pub(crate) fn target() -> Target {
2525
features: "+v7,+vfp3,-d32,+thumb2,-neon".into(),
2626
max_atomic_width: Some(64),
2727
mcount: "\u{1}mcount".into(),
28+
// FIXME(compiler-team#422): musl targets should be dynamically linked by default.
29+
crt_static_default: true,
2830
..base::linux_musl::opts()
2931
},
3032
}

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

+2
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@ pub(crate) fn target() -> Target {
44
let mut base = super::i686_unknown_linux_musl::target();
55
base.cpu = "pentium".into();
66
base.llvm_target = "i586-unknown-linux-musl".into();
7+
// FIXME(compiler-team#422): musl targets should be dynamically linked by default.
8+
base.crt_static_default = true;
79
base
810
}

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

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ pub(crate) fn target() -> Target {
66
base.max_atomic_width = Some(64);
77
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32", "-Wl,-melf_i386"]);
88
base.stack_probes = StackProbeType::Inline;
9+
// FIXME(compiler-team#422): musl targets should be dynamically linked by default.
10+
base.crt_static_default = true;
911

1012
// The unwinder used by i686-unknown-linux-musl, the LLVM libunwind
1113
// implementation, apparently relies on frame pointers existing... somehow.

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

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ pub(crate) fn target() -> Target {
88
base.cpu = "mips64r2".into();
99
base.features = "+mips64r2,+soft-float".into();
1010
base.max_atomic_width = Some(64);
11-
base.crt_static_default = false;
1211

1312
Target {
1413
// LLVM doesn't recognize "muslabi64" yet.

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

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ pub(crate) fn target() -> Target {
2222
abi: "abi64".into(),
2323
endian: Endian::Big,
2424
mcount: "_mcount".into(),
25+
// FIXME(compiler-team#422): musl targets should be dynamically linked by default.
26+
crt_static_default: true,
2527
..base
2628
},
2729
}

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

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ pub(crate) fn target() -> Target {
55
base.cpu = "mips64r2".into();
66
base.features = "+mips64r2".into();
77
base.max_atomic_width = Some(64);
8+
// FIXME(compiler-team#422): musl targets should be dynamically linked by default.
9+
base.crt_static_default = true;
810
Target {
911
// LLVM doesn't recognize "muslabi64" yet.
1012
llvm_target: "mips64el-unknown-linux-musl".into(),

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

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ pub(crate) fn target() -> Target {
66
base.cpu = "mips32r2".into();
77
base.features = "+mips32r2,+soft-float".into();
88
base.max_atomic_width = Some(32);
9-
base.crt_static_default = false;
109
Target {
1110
llvm_target: "mips-unknown-linux-musl".into(),
1211
metadata: crate::spec::TargetMetadata {

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

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ pub(crate) fn target() -> Target {
55
base.cpu = "mips32r2".into();
66
base.features = "+mips32r2,+soft-float".into();
77
base.max_atomic_width = Some(32);
8-
base.crt_static_default = false;
98
Target {
109
llvm_target: "mipsel-unknown-linux-musl".into(),
1110
metadata: crate::spec::TargetMetadata {

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

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ pub(crate) fn target() -> Target {
77
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
88
base.max_atomic_width = Some(64);
99
base.stack_probes = StackProbeType::Inline;
10+
// FIXME(compiler-team#422): musl targets should be dynamically linked by default.
11+
base.crt_static_default = true;
1012

1113
Target {
1214
llvm_target: "powerpc64-unknown-linux-musl".into(),

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

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ pub(crate) fn target() -> Target {
66
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
77
base.max_atomic_width = Some(64);
88
base.stack_probes = StackProbeType::Inline;
9+
// FIXME(compiler-team#422): musl targets should be dynamically linked by default.
10+
base.crt_static_default = true;
911

1012
Target {
1113
llvm_target: "powerpc64le-unknown-linux-musl".into(),

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

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ pub(crate) fn target() -> Target {
66
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]);
77
base.max_atomic_width = Some(32);
88
base.stack_probes = StackProbeType::Inline;
9+
// FIXME(compiler-team#422): musl targets should be dynamically linked by default.
10+
base.crt_static_default = true;
911

1012
Target {
1113
llvm_target: "powerpc-unknown-linux-musl".into(),

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

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ pub(crate) fn target() -> Target {
66
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-mspe"]);
77
base.max_atomic_width = Some(32);
88
base.stack_probes = StackProbeType::Inline;
9+
// FIXME(compiler-team#422): musl targets should be dynamically linked by default.
10+
base.crt_static_default = true;
911

1012
Target {
1113
llvm_target: "powerpc-unknown-linux-muslspe".into(),

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

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ pub(crate) fn target() -> Target {
2323
llvm_abiname: "ilp32d".into(),
2424
max_atomic_width: Some(32),
2525
supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]),
26+
// FIXME(compiler-team#422): musl targets should be dynamically linked by default.
27+
crt_static_default: true,
2628
..base::linux_musl::opts()
2729
},
2830
}

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

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ pub(crate) fn target() -> Target {
2121
llvm_abiname: "lp64d".into(),
2222
max_atomic_width: Some(64),
2323
supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]),
24-
crt_static_default: false,
2524
..base::linux_musl::opts()
2625
},
2726
}

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

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ pub(crate) fn target() -> Target {
1515
base.stack_probes = StackProbeType::Inline;
1616
base.supported_sanitizers =
1717
SanitizerSet::ADDRESS | SanitizerSet::LEAK | SanitizerSet::MEMORY | SanitizerSet::THREAD;
18+
// FIXME(compiler-team#422): musl targets should be dynamically linked by default.
19+
base.crt_static_default = true;
1820

1921
Target {
2022
llvm_target: "s390x-unknown-linux-musl".into(),

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

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ pub(crate) fn target() -> Target {
2929
features: "+v7,+thumb-mode,+thumb2,+vfp3,+neon".into(),
3030
max_atomic_width: Some(64),
3131
mcount: "\u{1}mcount".into(),
32+
// FIXME(compiler-team#422): musl targets should be dynamically linked by default.
33+
crt_static_default: true,
3234
..base::linux_musl::opts()
3335
},
3436
}

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

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ pub(crate) fn target() -> Target {
1414
| SanitizerSet::MEMORY
1515
| SanitizerSet::THREAD;
1616
base.supports_xray = true;
17+
// FIXME(compiler-team#422): musl targets should be dynamically linked by default.
18+
base.crt_static_default = true;
1719

1820
Target {
1921
llvm_target: "x86_64-unknown-linux-musl".into(),

0 commit comments

Comments
 (0)