diff options
| -rw-r--r-- | src/bootstrap/src/core/build_steps/llvm.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs index 9ae1825fae8..0bc879c7d71 100644 --- a/src/bootstrap/src/core/build_steps/llvm.rs +++ b/src/bootstrap/src/core/build_steps/llvm.rs @@ -645,10 +645,17 @@ fn configure_cmake( if !builder.is_builder_target(target) { cfg.define("CMAKE_CROSSCOMPILING", "True"); + // NOTE: Ideally, we wouldn't have to do this, and `cmake-rs` would just handle it for us. + // But it currently determines this based on the `CARGO_CFG_TARGET_OS` environment variable, + // which isn't set when compiling outside `build.rs` (like bootstrap is). + // + // So for now, we define `CMAKE_SYSTEM_NAME` ourselves, to panicking in `cmake-rs`. if target.contains("netbsd") { cfg.define("CMAKE_SYSTEM_NAME", "NetBSD"); } else if target.contains("dragonfly") { cfg.define("CMAKE_SYSTEM_NAME", "DragonFly"); + } else if target.contains("openbsd") { + cfg.define("CMAKE_SYSTEM_NAME", "OpenBSD"); } else if target.contains("freebsd") { cfg.define("CMAKE_SYSTEM_NAME", "FreeBSD"); } else if target.is_windows() { @@ -659,10 +666,27 @@ fn configure_cmake( cfg.define("CMAKE_SYSTEM_NAME", "SunOS"); } else if target.contains("linux") { cfg.define("CMAKE_SYSTEM_NAME", "Linux"); + } else if target.contains("darwin") { + // macOS + cfg.define("CMAKE_SYSTEM_NAME", "Darwin"); + } else if target.contains("ios") { + cfg.define("CMAKE_SYSTEM_NAME", "iOS"); + } else if target.contains("tvos") { + cfg.define("CMAKE_SYSTEM_NAME", "tvOS"); + } else if target.contains("visionos") { + cfg.define("CMAKE_SYSTEM_NAME", "visionOS"); + } else if target.contains("watchos") { + cfg.define("CMAKE_SYSTEM_NAME", "watchOS"); + } else if target.contains("none") { + // "none" should be the last branch + cfg.define("CMAKE_SYSTEM_NAME", "Generic"); } else { builder.info(&format!( "could not determine CMAKE_SYSTEM_NAME from the target `{target}`, build may fail", )); + // Fallback, set `CMAKE_SYSTEM_NAME` anyhow to avoid the logic `cmake-rs` tries, and + // to avoid CMAKE_SYSTEM_NAME being inferred from the host. + cfg.define("CMAKE_SYSTEM_NAME", "Generic"); } // When cross-compiling we should also set CMAKE_SYSTEM_VERSION, but in |
