Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression for MacOS using cmake with c++11 (unknown target aarch64-apple-darwin11) #1276

Open
drewkett opened this issue Nov 6, 2024 · 1 comment

Comments

@drewkett
Copy link

drewkett commented Nov 6, 2024

With version 1.1.32, it now is not possible to build a project on MacOS using the cmake crate enabling c++11. I'm not sure whether to make this issue here or in cmake-rs but i'll make it here because its specifically a release of cc that broke it.

See this example

Cargo.toml

[package]
name = "cmake_example"
version = "0.1.0"
edition = "2021"

[build-dependencies]
cmake = "0.1.51"

build.rs

fn main() {
    cmake::Config::new("src").uses_cxx11().build();
}

"src" is irrelevant here.

This fails to build with

% cargo build
   Compiling cmake_example v0.1.0 (/Users/andrew/cmake_example)
error: failed to run custom build command for `cmake_example v0.1.0 (/Users/andrew/cmake_example)`

Caused by:
  process didn't exit successfully: `/Users/andrew/cmake_example/target/debug/build/cmake_example-066fd92fa2dd9dd8/build-script-build` (exit status: 1)
  --- stdout
  CMAKE_TOOLCHAIN_FILE_aarch64-apple-darwin = None
  CMAKE_TOOLCHAIN_FILE_aarch64_apple_darwin = None
  HOST_CMAKE_TOOLCHAIN_FILE = None
  CMAKE_TOOLCHAIN_FILE = None
  CMAKE_GENERATOR_aarch64-apple-darwin = None
  CMAKE_GENERATOR_aarch64_apple_darwin = None
  HOST_CMAKE_GENERATOR = None
  CMAKE_GENERATOR = None

  --- stderr


  error occurred: unknown target `aarch64-apple-darwin11`

Looking at cmake code, it appends 11 as the target for C++11. My understanding is that darwin11 here is the MacOS clang way of specifying the minimum target MacOS version. In the cmake crate, the TARGET env var is set with that aarch64-apple-darwin11 which then causes cc to fail when trying to parse the target to a target triple.

After having typed this out, I'm guessing i can in all likelihood just stop setting uses_cxx11 from cmake because any toolchains i'd be compiling with likely have C++11 available. I also wonder if instead cmake could use a different mechanism to ensure a minimum toolchain version, but I don't know enough about how that works to have an immediate answer there. However, I'll leave this ticket here to call out the issue (and in case others run into the same thing).

@madsmtm
Copy link
Contributor

madsmtm commented Nov 6, 2024

I think this is a cmake issue, they are modifying the Rust target triple and adding 11 to it, see rust-lang/cmake-rs#39.

This is redundant nowadays, where:

  1. The minimum supported OS version in Rust is way above macOS 10.7
  2. cc sets this value in the deployment target.

And wrong because the target value in cc is the rustc target, while cmake invalidly assumed it refers to the Clang target.

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

No branches or pull requests

2 participants