Skip to content

Commit 29b6b5f

Browse files
authored
Rollup merge of #75376 - tmiasko:cmake-system-name, r=Mark-Simulacrum
Set CMAKE_SYSTEM_NAME when cross-compiling Configure CMAKE_SYSTEM_NAME when cross-compiling in `configure_cmake`, to tell CMake about target system. Previously this was done only for LLVM step and now applies more generally to steps using cmake. Helps with #74576.
2 parents 668a34e + 91f87bc commit 29b6b5f

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/bootstrap/native.rs

+16-8
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,6 @@ impl Step for Llvm {
282282
"LLVM_CONFIG_PATH",
283283
host_bin.join("llvm-config").with_extension(EXE_EXTENSION),
284284
);
285-
286-
if target.contains("netbsd") {
287-
cfg.define("CMAKE_SYSTEM_NAME", "NetBSD");
288-
} else if target.contains("freebsd") {
289-
cfg.define("CMAKE_SYSTEM_NAME", "FreeBSD");
290-
} else if target.contains("windows") {
291-
cfg.define("CMAKE_SYSTEM_NAME", "Windows");
292-
}
293285
}
294286

295287
if let Some(ref suffix) = builder.config.llvm_version_suffix {
@@ -378,6 +370,22 @@ fn configure_cmake(
378370
}
379371
cfg.target(&target.triple).host(&builder.config.build.triple);
380372

373+
if target != builder.config.build {
374+
if target.contains("netbsd") {
375+
cfg.define("CMAKE_SYSTEM_NAME", "NetBSD");
376+
} else if target.contains("freebsd") {
377+
cfg.define("CMAKE_SYSTEM_NAME", "FreeBSD");
378+
} else if target.contains("windows") {
379+
cfg.define("CMAKE_SYSTEM_NAME", "Windows");
380+
}
381+
// When cross-compiling we should also set CMAKE_SYSTEM_VERSION, but in
382+
// that case like CMake we cannot easily determine system version either.
383+
//
384+
// Since, the LLVM itself makes rather limited use of version checks in
385+
// CMakeFiles (and then only in tests), and so far no issues have been
386+
// reported, the system version is currently left unset.
387+
}
388+
381389
let sanitize_cc = |cc: &Path| {
382390
if target.contains("msvc") {
383391
OsString::from(cc.to_str().unwrap().replace("\\", "/"))

0 commit comments

Comments
 (0)