Skip to content

Conversation

madsmtm
Copy link
Contributor

@madsmtm madsmtm commented Mar 24, 2025

Reliance on CARGO_CFG_TARGET_OS/CARGO_CFG_TARGET_ARCH was introduced in #158, but these are not available when outside build.rs scripts. Instead, we should try to determine CMAKE_SYSTEM_NAME and CMAKE_SYSTEM_PROCESSOR based on the target triple.

In cc-rs, we do this by parsing the target triple, though I suspect that to be overkill for cmake-rs' purposes, so I've tried to keep it simpler.
It's doable for CMAKE_SYSTEM_NAME but kinda difficult for CMAKE_SYSTEM_PROCESSOR, because the values expected that aren't really documented, so it's hard to know if we emit it correctly? In any case, I've written it in a way that the user can override CMAKE_SYSTEM_PROCESSOR if necessary.

Fixes #228.
bootstrap currently has to work around this in rust-lang/rust#138784.

madsmtm added 2 commits March 24, 2025 15:14
Do not expect CARGO_CFG_TARGET_OS/CARGO_CFG_TARGET_ARCH to always be
available, and instead try to determine this information based on the
rustc target tuple.
///
/// [`CMAKE_SYSTEM_NAME`]: https://cmake.org/cmake/help/latest/variable/CMAKE_SYSTEM_NAME.html
fn get_system_name(target: &str) -> &'static str {
let mapping = [

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Latest versions break rust-lang bootstrap
2 participants