Open edmorley opened 2 years ago
The CMakeError.log
file mentioned contains:
Detecting C compiler ABI info failed to compile with the following output:
Change Dir: /Users/emorley/src/testcase-libz-sys-cross-compile/target/x86_64-unknown-linux-musl/debug/build/libz-sys-2b3ea8f924a72b91/out/build/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make -f Makefile cmTC_1760d/fast && /Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/cmTC_1760d.dir/build.make CMakeFiles/cmTC_1760d.dir/build
Building C object CMakeFiles/cmTC_1760d.dir/CMakeCCompilerABI.c.o
/opt/homebrew/bin/x86_64-unknown-linux-musl-gcc -ffunction-sections -fdata-sections -fPIC -m64 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk -v -Wl,-v -std=c11 -o CMakeFiles/cmTC_1760d.dir/CMakeCCompilerABI.c.o -c /opt/homebrew/Cellar/cmake/3.22.3/share/cmake/Modules/CMakeCCompilerABI.c
Using built-in specs.
COLLECT_GCC=/opt/homebrew/bin/x86_64-unknown-linux-musl-gcc
x86_64-unknown-linux-musl-gcc: error: unrecognized command-line option '-arch'
Target: x86_64-unknown-linux-musl
Configured with: /Volumes/build/.build/x86_64-unknown-linux-musl/src/gcc/configure --build=aarch64-build_apple-darwin21.3.0 --host=aarch64-build_apple-darwin21.3.0 --target=x86_64-unknown-linux-musl --prefix=/Volumes/tools/x86_64-unknown-linux-musl --exec_prefix=/Volumes/tools/x86_64-unknown-linux-musl --with-sysroot=/Volumes/tools/x86_64-unknown-linux-musl/x86_64-unknown-linux-musl/sysroot --enable-languages=c,c++,fortran --enable-__cxa_atexit --disable-libmudflap --disable-libgomp --disable-libssp --disable-libquadmath --disable-libquadmath-support --disable-libsanitizer --disable-libmpx --with-gmp=/Volumes/build/.build/x86_64-unknown-linux-musl/buildtools --with-mpfr=/Volumes/build/.build/x86_64-unknown-linux-musl/buildtools --with-mpc=/Volumes/build/.build/x86_64-unknown-linux-musl/buildtools --with-isl=/Volumes/build/.build/x86_64-unknown-linux-musl/buildtools --enable-lto --enable-threads=posix --enable-target-optspace --with-linker-hash-style=both --enable-plugin --enable-gold --disable-nls --disable-multilib --with-local-prefix=/Volumes/tools/x86_64-unknown-linux-musl/x86_64-unknown-linux-musl/sysroot --enable-long-long
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.2.0 (GCC)
make[1]: *** [CMakeFiles/cmTC_1760d.dir/CMakeCCompilerABI.c.o] Error 1
make: *** [cmTC_1760d/fast] Error 2
Determining if the C compiler works failed with the following output:
Change Dir: /Users/emorley/src/testcase-libz-sys-cross-compile/target/x86_64-unknown-linux-musl/debug/build/libz-sys-2b3ea8f924a72b91/out/build/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make -f Makefile cmTC_bd1e5/fast && /Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/cmTC_bd1e5.dir/build.make CMakeFiles/cmTC_bd1e5.dir/build
Building C object CMakeFiles/cmTC_bd1e5.dir/testCCompiler.c.o
/opt/homebrew/bin/x86_64-unknown-linux-musl-gcc -ffunction-sections -fdata-sections -fPIC -m64 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk -std=c11 -o CMakeFiles/cmTC_bd1e5.dir/testCCompiler.c.o -c /Users/emorley/src/testcase-libz-sys-cross-compile/target/x86_64-unknown-linux-musl/debug/build/libz-sys-2b3ea8f924a72b91/out/build/CMakeFiles/CMakeTmp/testCCompiler.c
x86_64-unknown-linux-musl-gcc: error: unrecognized command-line option '-arch'
make[1]: *** [CMakeFiles/cmTC_bd1e5.dir/testCCompiler.c.o] Error 1
make: *** [cmTC_bd1e5/fast] Error 2
And .../out/build/CMakeFiles/3.22.3/CMakeSystem.cmake
contains:
set(CMAKE_HOST_SYSTEM "Darwin-21.4.0")
set(CMAKE_HOST_SYSTEM_NAME "Darwin")
set(CMAKE_HOST_SYSTEM_VERSION "21.4.0")
set(CMAKE_HOST_SYSTEM_PROCESSOR "arm64")
set(CMAKE_SYSTEM "Darwin-21.4.0")
set(CMAKE_SYSTEM_NAME "Darwin")
set(CMAKE_SYSTEM_VERSION "21.4.0")
set(CMAKE_SYSTEM_PROCESSOR "arm64")
set(CMAKE_CROSSCOMPILING "FALSE")
set(CMAKE_SYSTEM_LOADED 1)
Upgrading from CMake 3.22.3 to the newly released 3.23.0 (both installed via brew), doesn't help.
I don't suppose anyone has ideas of what to try next? :-)
Hi :-)
Has anyone seen anything like this before when cross-compiling on an M1 Mac?
This cross-compile configuration works successfully for a variety of other crates, however this is the first crate I'm using that uses CMake, so I'm not sure if it's a
libz-sys
specific problem, or with cross-compiling with CMake and this toolchain in general.Steps to reproduce
brew install messense/macos-cross-toolchains/x86_64-unknown-linux-musl
(to install this cross-compile toolchain)brew install cmake
(sincelibz-sys
requires it)rustup target add x86_64-unknown-linux-musl
cargo new testcase-libz-sys-cross-compile && cd_
cargo build --target x86_64-unknown-linux-musl
Expected
The build completes successfully (like it does on this machine, when not cross-compiling).
Actual
The build fails with:
Environment
libz-sys
: 1.1.5cmake
: 0.1.48pkg-config
: 0.3.24