Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 280dffd

Browse files
committed
Build rtstartup for none sysroot too
Even mini_core needs it
1 parent fd83b27 commit 280dffd

File tree

1 file changed

+32
-25
lines changed

1 file changed

+32
-25
lines changed

build_system/build_sysroot.rs

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ fn build_sysroot_for_triple(
129129
sysroot_kind: SysrootKind,
130130
) -> SysrootTarget {
131131
match sysroot_kind {
132-
SysrootKind::None => SysrootTarget { triple: compiler.triple, libs: vec![] },
132+
SysrootKind::None => build_rtstartup(dirs, &compiler)
133+
.unwrap_or(SysrootTarget { triple: compiler.triple, libs: vec![] }),
133134
SysrootKind::Llvm => build_llvm_sysroot_for_triple(compiler),
134135
SysrootKind::Clif => {
135136
build_clif_sysroot_for_triple(dirs, channel, compiler, &cg_clif_dylib_path)
@@ -198,31 +199,10 @@ fn build_clif_sysroot_for_triple(
198199

199200
let mut target_libs = SysrootTarget { triple: compiler.triple.clone(), libs: vec![] };
200201

201-
if compiler.triple.ends_with("windows-gnu") {
202-
eprintln!("[BUILD] rtstartup for {}", compiler.triple);
203-
204-
RTSTARTUP_SYSROOT.ensure_fresh(dirs);
205-
206-
let rtstartup_src = SYSROOT_SRC.to_path(dirs).join("library").join("rtstartup");
207-
let mut rtstartup_target_libs =
208-
SysrootTarget { triple: compiler.triple.clone(), libs: vec![] };
209-
210-
for file in ["rsbegin", "rsend"] {
211-
let obj = RTSTARTUP_SYSROOT.to_path(dirs).join(format!("{file}.o"));
212-
let mut build_rtstartup_cmd = Command::new(&compiler.rustc);
213-
build_rtstartup_cmd
214-
.arg("--target")
215-
.arg(&compiler.triple)
216-
.arg("--emit=obj")
217-
.arg("-o")
218-
.arg(&obj)
219-
.arg(rtstartup_src.join(format!("{file}.rs")));
220-
spawn_and_wait(build_rtstartup_cmd);
221-
rtstartup_target_libs.libs.push(obj.clone());
222-
target_libs.libs.push(obj);
223-
}
224-
202+
if let Some(rtstartup_target_libs) = build_rtstartup(dirs, &compiler) {
225203
rtstartup_target_libs.install_into_sysroot(&RTSTARTUP_SYSROOT.to_path(dirs));
204+
205+
target_libs.libs.extend(rtstartup_target_libs.libs);
226206
}
227207

228208
let build_dir = STANDARD_LIBRARY.target_dir(dirs).join(&compiler.triple).join(channel);
@@ -266,3 +246,30 @@ fn build_clif_sysroot_for_triple(
266246

267247
target_libs
268248
}
249+
250+
fn build_rtstartup(dirs: &Dirs, compiler: &Compiler) -> Option<SysrootTarget> {
251+
if !compiler.triple.ends_with("windows-gnu") {
252+
return None;
253+
}
254+
255+
RTSTARTUP_SYSROOT.ensure_fresh(dirs);
256+
257+
let rtstartup_src = SYSROOT_SRC.to_path(dirs).join("library").join("rtstartup");
258+
let mut target_libs = SysrootTarget { triple: compiler.triple.clone(), libs: vec![] };
259+
260+
for file in ["rsbegin", "rsend"] {
261+
let obj = RTSTARTUP_SYSROOT.to_path(dirs).join(format!("{file}.o"));
262+
let mut build_rtstartup_cmd = Command::new(&compiler.rustc);
263+
build_rtstartup_cmd
264+
.arg("--target")
265+
.arg(&compiler.triple)
266+
.arg("--emit=obj")
267+
.arg("-o")
268+
.arg(&obj)
269+
.arg(rtstartup_src.join(format!("{file}.rs")));
270+
spawn_and_wait(build_rtstartup_cmd);
271+
target_libs.libs.push(obj.clone());
272+
}
273+
274+
Some(target_libs)
275+
}

0 commit comments

Comments
 (0)