cc-rs: `cc 1.0.85` breaks cross-compilation x86_64 Linux -> {x86_64,aarch64} Darwin

We use Zig as a C compiler and rust-lld as linker to cross-compile Rust from x86_64 (or aarch64) Linux to {x86_64,aarch64} Darwin. Updating cc from 1.0.83 to 1.0.85 breaks compilation for these.

Not sure if that’s caused by cc directly or whether that’s a problem in Ring.

x86_64-unknown-linux-gnu -> aarch64-apple-darwin

 The following warnings were emitted during compilation:
 warning: ring@0.17.7: error: UnknownArchitecture
 error: failed to run custom build command for `ring v0.17.7`
 Caused by:
   process didn't exit successfully: `/build/source/target/release/build/ring-dff0a7997c328e11/build-script-build` (exit status: 1)
   --- stdout
   cargo:rerun-if-env-changed=RING_PREGENERATE_ASM
   cargo:rustc-env=RING_CORE_PREFIX=ring_core_0_17_7_
   OPT_LEVEL = Some("3")
   TARGET = Some("aarch64-apple-darwin")
   HOST = Some("x86_64-unknown-linux-gnu")
   cargo:rerun-if-env-changed=CC_aarch64-apple-darwin
   CC_aarch64-apple-darwin = Some("aarch64-apple-darwin-zigcc")
   running: "aarch64-apple-darwin-zigcc" "--version"
   exit status: 0
   cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
   CRATE_CC_NO_DEFAULTS = None
   DEBUG = Some("false")
   running: "xcrun" "--show-sdk-platform-version" "--sdk" "macosx"
   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=TARGET_CFLAGS
   TARGET_CFLAGS = None
   cargo:rerun-if-env-changed=CFLAGS
   CFLAGS = None
   running: "aarch64-apple-darwin-zigcc" "--version"
   exit status: 0
   running: "xcrun" "--show-sdk-platform-version" "--sdk" "macosx"
   running: "aarch64-apple-darwin-zigcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=arm64-apple-darwin" "-mmacosx-version-min=11.0" "-I" "include" "-I" "/build/source/target/aarch64-apple-darwin/release/build/ring-18a91eda96a80e50/out" "-Wall" "-Wextra" "-fvisibility=hidden" "-std=c1x" "-pedantic" "-Wall" "-Wextra" "-Wbad-function-cast" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wnested-externs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wstrict-prototypes" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-gfull" "-DNDEBUG" "-o" "/build/source/target/aarch64-apple-darwin/release/build/ring-18a91eda96a80e50/out/fad98b632b8ce3cc-curve25519.o" "-c" "crypto/curve25519/curve25519.c"
   cargo:warning=error: UnknownArchitecture
   exit status: 1
   --- stderr
   error occurred: Command "aarch64-apple-darwin-zigcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=arm64-apple-darwin" "-mmacosx-version-min=11.0" "-I" "include" "-I" "/build/source/target/aarch64-apple-darwin/release/build/ring-18a91eda96a80e50/out" "-Wall" "-Wextra" "-fvisibility=hidden" "-std=c1x" "-pedantic" "-Wall" "-Wextra" "-Wbad-function-cast" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wnested-externs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wstrict-prototypes" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-gfull" "-DNDEBUG" "-o" "/build/source/target/aarch64-apple-darwin/release/build/ring-18a91eda96a80e50/out/fad98b632b8ce3cc-curve25519.o" "-c" "crypto/curve25519/curve25519.c" with args "aarch64-apple-darwin-zigcc" did not execute successfully (status code exit status: 1).

x86_64-unknown-linux-gnu -> x86_64-apple-darwin

 The following warnings were emitted during compilation:
 warning: ring@0.17.7: error: UnknownOperatingSystem
 error: failed to run custom build command for `ring v0.17.7`
 Caused by:
   process didn't exit successfully: `/build/source/target/release/build/ring-dff0a7997c328e11/build-script-build` (exit status: 1)
   --- stdout
   cargo:rerun-if-env-changed=RING_PREGENERATE_ASM
   cargo:rustc-env=RING_CORE_PREFIX=ring_core_0_17_7_
   OPT_LEVEL = Some("3")
   TARGET = Some("x86_64-apple-darwin")
   HOST = Some("x86_64-unknown-linux-gnu")
   cargo:rerun-if-env-changed=CC_x86_64-apple-darwin
   CC_x86_64-apple-darwin = Some("x86_64-apple-darwin-zigcc")
   running: "x86_64-apple-darwin-zigcc" "--version"
   exit status: 0
   cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
   CRATE_CC_NO_DEFAULTS = None
   DEBUG = Some("false")
   running: "xcrun" "--show-sdk-platform-version" "--sdk" "macosx"
   cargo:rerun-if-env-changed=CFLAGS_x86_64-apple-darwin
   CFLAGS_x86_64-apple-darwin = None
   cargo:rerun-if-env-changed=CFLAGS_x86_64_apple_darwin
   CFLAGS_x86_64_apple_darwin = None
   cargo:rerun-if-env-changed=TARGET_CFLAGS
   TARGET_CFLAGS = None
   cargo:rerun-if-env-changed=CFLAGS
   CFLAGS = None
   running: "x86_64-apple-darwin-zigcc" "--version"
   exit status: 0
   running: "xcrun" "--show-sdk-platform-version" "--sdk" "macosx"
   running: "x86_64-apple-darwin-zigcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "--target=x86_64-apple-darwin" "-mmacosx-version-min=10.7" "-I" "include" "-I" "/build/source/target/x86_64-apple-darwin/release/build/ring-e988c0c94f7e5625/out" "-Wall" "-Wextra" "-fvisibility=hidden" "-std=c1x" "-pedantic" "-Wall" "-Wextra" "-Wbad-function-cast" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wnested-externs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wstrict-prototypes" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-gfull" "-DNDEBUG" "-o" "/build/source/target/x86_64-apple-darwin/release/build/ring-e988c0c94f7e5625/out/fad98b632b8ce3cc-curve25519.o" "-c" "crypto/curve25519/curve25519.c"
   cargo:warning=error: UnknownOperatingSystem
   exit status: 1
   --- stderr
   error occurred: Command "x86_64-apple-darwin-zigcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "--target=x86_64-apple-darwin" "-mmacosx-version-min=10.7" "-I" "include" "-I" "/build/source/target/x86_64-apple-darwin/release/build/ring-e988c0c94f7e5625/out" "-Wall" "-Wextra" "-fvisibility=hidden" "-std=c1x" "-pedantic" "-Wall" "-Wextra" "-Wbad-function-cast" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wnested-externs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wstrict-prototypes" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-gfull" "-DNDEBUG" "-o" "/build/source/target/x86_64-apple-darwin/release/build/ring-e988c0c94f7e5625/out/fad98b632b8ce3cc-curve25519.o" "-c" "crypto/curve25519/curve25519.c" with args "x86_64-apple-darwin-zigcc" did not execute successfully (status code exit status: 1).

Refs https://github.com/bytecodealliance/wit-deps/pull/118 For reference, the zigcc script is defined at https://github.com/rvolosatovs/nixify/blob/3e34d28daa53c41ae615360f4c106cc1771ae869/lib/rust/mkAttrs.nix#L297-L312

About this issue

  • Original URL
  • State: closed
  • Created 5 months ago
  • Reactions: 1
  • Comments: 26 (5 by maintainers)

Commits related to this issue

Most upvoted comments

Small note here, since I was already setting the -target (parsed from cargo target) to zig cc anyway, simply reordering the parameters slightly and setting the parsed -target last seems to have done the trick https://github.com/rvolosatovs/nixify/pull/218/commits/35d7d4e6618190d6c4538c646a0e6b087ad2aea6

The right-most zig cc flag seems to override any previously supplied-values

Agree that this is a zig cc issue, I found https://github.com/ziglang/zig/issues/4911 for fixing exactly this.

removing from zig-cc

Agree that this is a zig cc issue, I found https://github.com/ziglang/zig/issues/4911 for fixing exactly this.

Just string-replacing for the time being and waiting for a fix upstream sounds good to me, closing

I dont actually know which PR introduced the passing of --target on macOS platforms. I need to look into that tomorrow.

Thank you for the side-by-side text @rvolosatovs. It will make bisecting this easier.

Side-by-side: 1.0.83:

wit-deps-deps> [ring 0.17.7] running: "aarch64-apple-darwin-zigcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-arch" "arm64" "-I" "include" "-I" "/build/source/target/aarch64-apple-darwin/release/build/ring-c65e1d5876d1356a/out" "-Wall" "-Wextra" "-fvisibility=hidden" "-std=c1x" "-pedantic" "-Wall" "-Wextra" "-Wbad-function-cast" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wnested-externs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wstrict-prototypes" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-gfull" "-DNDEBUG" "-o" "/build/source/target/aarch64-apple-darwin/release/build/ring-c65e1d5876d1356a/out/crypto/curve25519/curve25519.o" "-c" "crypto/curve25519/curve25519.c"

1.0.85:

wit-deps-deps> [ring 0.17.7] running: "aarch64-apple-darwin-zigcc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=arm64-apple-darwin" "-mmacosx-version-min=11.0" "-I" "include" "-I" "/build/source/target/aarch64-apple-darwin/release/build/ring-d03b2a83dd1bf3bb/out" "-Wall" "-Wextra" "-fvisibility=hidden" "-std=c1x" "-pedantic" "-Wall" "-Wextra" "-Wbad-function-cast" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wnested-externs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wstrict-prototypes" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-gfull" "-DNDEBUG" "-o" "/build/source/target/aarch64-apple-darwin/release/build/ring-d03b2a83dd1bf3bb/out/fad98b632b8ce3cc-curve25519.o" "-c" "crypto/curve25519/curve25519.c"

I am not sure if that’s the only issue, but I’m quite sure Zig would not be too happy about the --target=arm64-apple-darwin, at the very least I know I had to translate that to aarch64-macos (https://github.com/rvolosatovs/nixify/blob/3e34d28daa53c41ae615360f4c106cc1771ae869/lib/rust/mkAttrs.nix#L299-L300)

I’m curious why --target is was not set in 1.0.83, but appeared in 1.0.85?

I’ve set CARGO_LOG=trace, you can see the full (failing) build log with 1.0.85 here: https://github.com/bytecodealliance/wit-deps/actions/runs/7938238802/job/21676790358

For comparison, this is the same build, that succeeds with 1.0.83: https://github.com/bytecodealliance/wit-deps/actions/runs/7938411356/job/21677189567