Skip to content

Commit dcb6238

Browse files
authored
Unrolled build for #146758
Rollup merge of #146758 - mati865:amd64_mingw_no_rs_objects, r=petrochenkov Stop linking rs{begin,end} objects on x86_64-*-windows-gnu Until now, x86_64-pc-windows-gnu linked `rsbegin.o` and `rsend.o` just like i686-pc-windows-gnu, even though they were no-ops for it. This was likely done for the simplicity back when it was introduced. Today the things are different and these startup/end objects harm other features, like `build-std`. Given the demotion of i686-pc-windows-gnu from tier 1, there is no point in hurting x86_64-pc-windows-gnu, which remains a tier 1. The files are still shipped in case downstream crates expect them, as in case of the unmaintained `xargo`. Fixes #146739
2 parents 54a8a1d + 7eea65f commit dcb6238

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,7 @@ pub(crate) fn opts() -> TargetOptions {
9393
binary_format: BinaryFormat::Coff,
9494
allows_weak_linkage: false,
9595
pre_link_args,
96-
pre_link_objects: crt_objects::pre_mingw(),
97-
post_link_objects: crt_objects::post_mingw(),
9896
pre_link_objects_self_contained: crt_objects::pre_mingw_self_contained(),
99-
post_link_objects_self_contained: crt_objects::post_mingw_self_contained(),
10097
link_self_contained: LinkSelfContainedDefault::InferredForMingw,
10198
late_link_args,
10299
late_link_args_dynamic,

compiler/rustc_target/src/spec/crt_objects.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,17 @@ pub(super) fn post_musl_self_contained() -> CrtObjects {
8585
}
8686

8787
pub(super) fn pre_mingw_self_contained() -> CrtObjects {
88+
new(&[
89+
(LinkOutputKind::DynamicNoPicExe, &["crt2.o"]),
90+
(LinkOutputKind::DynamicPicExe, &["crt2.o"]),
91+
(LinkOutputKind::StaticNoPicExe, &["crt2.o"]),
92+
(LinkOutputKind::StaticPicExe, &["crt2.o"]),
93+
(LinkOutputKind::DynamicDylib, &["dllcrt2.o"]),
94+
(LinkOutputKind::StaticDylib, &["dllcrt2.o"]),
95+
])
96+
}
97+
98+
pub(super) fn pre_i686_mingw_self_contained() -> CrtObjects {
8899
new(&[
89100
(LinkOutputKind::DynamicNoPicExe, &["crt2.o", "rsbegin.o"]),
90101
(LinkOutputKind::DynamicPicExe, &["crt2.o", "rsbegin.o"]),
@@ -95,15 +106,15 @@ pub(super) fn pre_mingw_self_contained() -> CrtObjects {
95106
])
96107
}
97108

98-
pub(super) fn post_mingw_self_contained() -> CrtObjects {
109+
pub(super) fn post_i686_mingw_self_contained() -> CrtObjects {
99110
all("rsend.o")
100111
}
101112

102-
pub(super) fn pre_mingw() -> CrtObjects {
113+
pub(super) fn pre_i686_mingw() -> CrtObjects {
103114
all("rsbegin.o")
104115
}
105116

106-
pub(super) fn post_mingw() -> CrtObjects {
117+
pub(super) fn post_i686_mingw() -> CrtObjects {
107118
all("rsend.o")
108119
}
109120

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
use crate::spec::{Cc, FramePointer, LinkerFlavor, Lld, RustcAbi, Target, TargetMetadata, base};
1+
use crate::spec::{
2+
Cc, FramePointer, LinkerFlavor, Lld, RustcAbi, Target, TargetMetadata, base, crt_objects,
3+
};
24

35
pub(crate) fn target() -> Target {
46
let mut base = base::windows_gnu::opts();
@@ -15,6 +17,10 @@ pub(crate) fn target() -> Target {
1517
&["-m", "i386pe", "--large-address-aware"],
1618
);
1719
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-Wl,--large-address-aware"]);
20+
base.pre_link_objects = crt_objects::pre_i686_mingw();
21+
base.post_link_objects = crt_objects::post_i686_mingw();
22+
base.pre_link_objects_self_contained = crt_objects::pre_i686_mingw_self_contained();
23+
base.post_link_objects_self_contained = crt_objects::post_i686_mingw_self_contained();
1824

1925
Target {
2026
llvm_target: "i686-pc-windows-gnu".into(),

src/bootstrap/src/core/build_steps/compile.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,8 @@ impl Step for StartupObjects {
895895
fn run(self, builder: &Builder<'_>) -> Vec<(PathBuf, DependencyType)> {
896896
let for_compiler = self.compiler;
897897
let target = self.target;
898+
// Even though no longer necessary on x86_64, they are kept for now to
899+
// avoid potential issues in downstream crates.
898900
if !target.is_windows_gnu() {
899901
return vec![];
900902
}

0 commit comments

Comments
 (0)