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

Closed
drewkett opened this issue Nov 6, 2024 · 3 comments · Fixed by rust-lang/cmake-rs#235
Labels
O-apple Apple targets and toolchains

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
Collaborator

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.

@madsmtm madsmtm added the O-apple Apple targets and toolchains label Dec 6, 2024
@taddes
Copy link

taddes commented Feb 7, 2025

Greetings. I was just writing to ask if there are any updates on this issue? I - and some others I know of - are having this same issue as @drewkett raised. I have experimented with both Silicon and Intel-based systems with the same result. Ours is related to grpcio-sys that triggers the problem.

error: failed to run custom build command for grpcio-sys v0.13.0+1.56.2-patched

Caused by:
  process didn't exit successfully: `/Users/taddeskorris/Documents/code/mozilla/autopush-rs/target/debug/build/grpcio-sys-08498d5bf74a3ea3/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-changed=grpc_wrap.cc
  cargo:rerun-if-changed=grpc
  cargo:rerun-if-env-changed=CARGO_CFG_TARGET_OS
  cargo:rerun-if-env-changed=GRPCIO_SYS_USE_PKG_CONFIG
  cargo:rerun-if-env-changed=CARGO_CFG_TARGET_OS
  cargo:rustc-link-lib=resolv
  cargo:rerun-if-env-changed=CARGO_CFG_TARGET_OS
  cargo:rustc-link-lib=framework=CoreFoundation
  cargo:rerun-if-env-changed=CXX
  OPT_LEVEL = Some(0)
  OUT_DIR = Some(/Users/taddeskorris/Documents/code/mozilla/autopush-rs/target/debug/build/grpcio-sys-2a0bb54230892aea/out)
  TARGET = Some(aarch64-apple-darwin)
  HOST = Some(aarch64-apple-darwin)
  cargo:rerun-if-env-changed=CC_aarch64-apple-darwin
  CC_aarch64-apple-darwin = None
  cargo:rerun-if-env-changed=CC_aarch64_apple_darwin
  CC_aarch64_apple_darwin = None
  cargo:rerun-if-env-changed=HOST_CC
  HOST_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  RUSTC_WRAPPER = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some(true)
  cargo:rerun-if-env-changed=MACOSX_DEPLOYMENT_TARGET
  MACOSX_DEPLOYMENT_TARGET = None
  cargo:rerun-if-env-changed=CFLAGS_aarch64-apple-darwin
  CFLAGS_aarch64-apple-darwin = None
  cargo:rerun-if-env-changed=CFLAGS_aarch64_apple_darwin
  CFLAGS_aarch64_apple_darwin = None
  cargo:rerun-if-env-changed=HOST_CFLAGS
  HOST_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  CARGO_ENCODED_RUSTFLAGS = Some()
  cargo:rustc-link-search=native=/Users/taddeskorris/Documents/code/mozilla/autopush-rs/target/debug/build/libz-sys-de390d0a5dd9c503/out/build
  cargo:rustc-link-search=native=/Users/taddeskorris/Documents/code/mozilla/autopush-rs/target/debug/build/libz-sys-de390d0a5dd9c503/out/lib
  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 in cc-rs: unknown target `aarch64-apple-darwin11`.

  NOTE: `cc-rs` only supports a fixed set of targets when not in a build script.
  - If adding a new target, you will need to fork of `cc-rs` until the target
    has landed on nightly and the auto-generated list has been updated. See also
    the `rustc` dev guide on adding a new target:
    https://rustc-dev-guide.rust-lang.org/building/new-target.html
  - If using a custom target, prefer to upstream it to `rustc` if possible,
    otherwise open an issue with `cc-rs`:
    https://github.com/rust-lang/cc-rs/issues/new

Cmake from cargo.lock:

[[package]]
name = "cmake"
version = "0.1.52"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c682c223677e0e5b6b7f63a64b9351844c3f1b1678a68b7ee617e30fb082620e"
dependencies = [
 "cc",
]

@madsmtm
Copy link
Collaborator

madsmtm commented Feb 7, 2025

Filed rust-lang/cmake-rs#235.

tgross35 pushed a commit to rust-lang/cmake-rs that referenced this issue Feb 10, 2025
The workaround introduced in #39
is no longer necessary since `cc-rs` handles C++ requirements
internally, and is in fact detrimental since `cc-rs` has required the target to be
a `rustc` target triple since rust-lang/cc-rs#1225 /
rust-lang/cc-rs#1252.

Additionally, deprecate `uses_cxx11` which was introduced in the same
PR.

Fixes rust-lang/cc-rs#1276.

I didn't update the dependency to anything specific, just a version that
I know has the fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-apple Apple targets and toolchains
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants