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

Compile error on Mac M1 #22

Open
unixsurfer opened this issue Feb 12, 2023 · 3 comments
Open

Compile error on Mac M1 #22

unixsurfer opened this issue Feb 12, 2023 · 3 comments

Comments

@unixsurfer
Copy link

I am trying to build https://github.com/starship/starship on my Mac Air M1 with:

docker run --rm  --volume "${PWD}":/root/src --workdir /root/src joseluisq/rust-linux-darwin-builder:1.67.1 sh -c "cargo build --release --target aarch64-apple-darwin"

but it fails with below

warning: cc: error: arm64: No such file or directory
warning: cc: error: unrecognized command-line option '-arch'; did you mean '-march='?
error: failed to run custom build command for `sha1-asm v0.5.1`

Caused by:
  process didn't exit successfully: `/root/src/target/release/build/sha1-asm-2010612ad33992cd/build-script-build` (exit status: 1)
  --- stdout
  TARGET = Some("aarch64-apple-darwin")
  OPT_LEVEL = Some("3")
  HOST = Some("aarch64-unknown-linux-gnu")
  CC_aarch64-apple-darwin = None
  CC_aarch64_apple_darwin = None
  TARGET_CC = None
  CC = None
  CROSS_COMPILE = None
  CFLAGS_aarch64-apple-darwin = None
  CFLAGS_aarch64_apple_darwin = None
  TARGET_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  CARGO_CFG_TARGET_FEATURE = Some("aes,crc,dit,dotprod,dpb,dpb2,fcma,fhm,flagm,fp16,frintts,jsconv,lor,lse,neon,paca,pacg,pan,pmuv3,ras,rcpc,rcpc2,rdm,sb,sha2,sha3,ssbs,vh")
  running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-arch" "arm64" "-Wall" "-Wextra" "-march=armv8-a+crypto" "-c" "-o" "/root/src/target/aarch64-apple-darwin/release/build/sha1-asm-9f091d7d0969abf5/out/src/aarch64_apple.o" "-c" "src/aarch64_apple.S"
  cargo:warning=cc: error: arm64: No such file or directory
  cargo:warning=cc: error: unrecognized command-line option '-arch'; did you mean '-march='?
  exit status: 1
  --- stderr
 error occurred: Command "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-arch" "arm64" "-Wall" "-Wextra" "-march=armv8-a+crypto" "-c" "-o" "/root/src/target/aarch64-apple-darwin/release/build/sha1-asm-9f091d7d0969abf5/out/src/aarch64_apple.o" "-c" "src/aarch64_apple.S" with args "cc" did not execute successfully (status code exit status: 1)

On my Linux machine I don't have that problem, I can build the cmd tool and run it fine on my Mac.

@joseluisq
Copy link
Owner

Since the project has sys crates I tried out this on an M1 but without success getting the same error.

$ CC=o64-clang CXX=o64-clang++ cargo build --release --target aarch64-apple-darwin
   Compiling sha1-asm v0.5.1
   Compiling libz-ng-sys v1.1.8
   Compiling prodash v23.0.0
   Compiling walkdir v2.3.2
The following warnings were emitted during compilation:

warning: error: unknown target CPU 'armv8-a+crypto'
warning: note: valid target CPU values are: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, icelake-client, icelake-server, tigerlake, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, x86-64

error: failed to run custom build command for `sha1-asm v0.5.1`

Caused by:
  process didn't exit successfully: `/root/src/target/release/build/sha1-asm-2010612ad33992cd/build-script-build` (exit status: 1)
  --- stdout
  TARGET = Some("aarch64-apple-darwin")
  OPT_LEVEL = Some("3")
  HOST = Some("aarch64-unknown-linux-gnu")
  CC_aarch64-apple-darwin = None
  CC_aarch64_apple_darwin = None
  TARGET_CC = None
  CC = Some("o64-clang")
  CFLAGS_aarch64-apple-darwin = None
  CFLAGS_aarch64_apple_darwin = None
  TARGET_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  running: "o64-clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=arm64-apple-darwin" "-Wall" "-Wextra" "-march=armv8-a+crypto" "-c" "-o" "/root/src/target/aarch64-apple-darwin/release/build/sha1-asm-9f091d7d0969abf5/out/src/aarch64_apple.o" "-c" "src/aarch64_apple.S"
  cargo:warning=error: unknown target CPU 'armv8-a+crypto'
  cargo:warning=note: valid target CPU values are: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, icelake-client, icelake-server, tigerlake, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, x86-64
  exit status: 1

  --- stderr
  error occurred: Command "o64-clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=arm64-apple-darwin" "-Wall" "-Wextra" "-march=armv8-a+crypto" "-c" "-o" "/root/src/target/aarch64-apple-darwin/release/build/sha1-asm-9f091d7d0969abf5/out/src/aarch64_apple.o" "-c" "src/aarch64_apple.S" with args "o64-clang" did not execute successfully (status code exit status: 1).

warning: build failed, waiting for other jobs to finish...
error: failed to run custom build command for `libz-ng-sys v1.1.8`

Caused by:
  process didn't exit successfully: `/root/src/target/release/build/libz-ng-sys-b3a8d0bb5434e96e/build-script-build_zng` (exit status: 101)
  --- stdout
  CMAKE_TOOLCHAIN_FILE_aarch64-apple-darwin = None
  CMAKE_TOOLCHAIN_FILE_aarch64_apple_darwin = None
  TARGET_CMAKE_TOOLCHAIN_FILE = None
  CMAKE_TOOLCHAIN_FILE = None
  CMAKE_GENERATOR_aarch64-apple-darwin = None
  CMAKE_GENERATOR_aarch64_apple_darwin = None
  TARGET_CMAKE_GENERATOR = None
  CMAKE_GENERATOR = None
  CMAKE_PREFIX_PATH_aarch64-apple-darwin = None
  CMAKE_PREFIX_PATH_aarch64_apple_darwin = None
  TARGET_CMAKE_PREFIX_PATH = None
  CMAKE_PREFIX_PATH = None
  CMAKE_aarch64-apple-darwin = None
  CMAKE_aarch64_apple_darwin = None
  TARGET_CMAKE = None
  CMAKE = None
  running: "cmake" "/root/.cargo/registry/src/github.com-1ecc6299db9ec823/libz-ng-sys-1.1.8/src/zlib-ng" "-DBUILD_SHARED_LIBS=OFF" "-DZLIB_COMPAT=OFF" "-DZLIB_ENABLE_TESTS=OFF" "-DWITH_GZFILEOP=ON" "-DCMAKE_INSTALL_PREFIX=/root/src/target/aarch64-apple-darwin/release/build/libz-ng-sys-e9f281b46d0dead0/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC --target=arm64-apple-darwin" "-DCMAKE_C_COMPILER=/usr/local/osxcross/target/bin/o64-clang" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC --target=arm64-apple-darwin" "-DCMAKE_CXX_COMPILER=/usr/local/osxcross/target/bin/o64-clang++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC --target=arm64-apple-darwin" "-DCMAKE_ASM_COMPILER=/usr/local/osxcross/target/bin/o64-clang" "-DCMAKE_BUILD_TYPE=Release"
  -- Using CMake version 3.18.4
  -- ZLIB_HEADER_VERSION: 1.2.11
  -- ZLIBNG_HEADER_VERSION: 2.1.0.devel
  -- The C compiler identification is Clang 11.0.1
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - failed
  -- Check for working C compiler: /usr/local/osxcross/target/bin/o64-clang
  -- Check for working C compiler: /usr/local/osxcross/target/bin/o64-clang - broken
  -- Configuring incomplete, errors occurred!
  See also "/root/src/target/aarch64-apple-darwin/release/build/libz-ng-sys-e9f281b46d0dead0/out/build/CMakeFiles/CMakeOutput.log".
  See also "/root/src/target/aarch64-apple-darwin/release/build/libz-ng-sys-e9f281b46d0dead0/out/build/CMakeFiles/CMakeError.log".

  --- stderr
  CMake Error at /usr/share/cmake-3.18/Modules/CMakeTestCCompiler.cmake:66 (message):
    The C compiler

      "/usr/local/osxcross/target/bin/o64-clang"

    is not able to compile a simple test program.

    It fails with the following output:

      Change Dir: /root/src/target/aarch64-apple-darwin/release/build/libz-ng-sys-e9f281b46d0dead0/out/build/CMakeFiles/CMakeTmp

      Run Build Command(s):/usr/bin/gmake cmTC_9e45f/fast && /usr/bin/gmake  -f CMakeFiles/cmTC_9e45f.dir/build.make CMakeFiles/cmTC_9e45f.dir/build
      gmake[1]: Entering directory '/root/src/target/aarch64-apple-darwin/release/build/libz-ng-sys-e9f281b46d0dead0/out/build/CMakeFiles/CMakeTmp'
      Building C object CMakeFiles/cmTC_9e45f.dir/testCCompiler.c.o
      /usr/local/osxcross/target/bin/o64-clang   -ffunction-sections -fdata-sections -fPIC --target=arm64-apple-darwin  -std=c11 -o CMakeFiles/cmTC_9e45f.dir/testCCompiler.c.o -c /root/src/target/aarch64-apple-darwin/release/build/libz-ng-sys-e9f281b46d0dead0/out/build/CMakeFiles/CMakeTmp/testCCompiler.c
      Linking C executable cmTC_9e45f
      /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_9e45f.dir/link.txt --verbose=1
      /usr/local/osxcross/target/bin/o64-clang  -ffunction-sections -fdata-sections -fPIC --target=arm64-apple-darwin  CMakeFiles/cmTC_9e45f.dir/testCCompiler.c.o -o cmTC_9e45f
      /usr/bin/ld: unrecognized option '-dynamic'
      /usr/bin/ld: use the --help option for usage information
      clang: error: linker command failed with exit code 1 (use -v to see invocation)
      gmake[1]: *** [CMakeFiles/cmTC_9e45f.dir/build.make:106: cmTC_9e45f] Error 1
      gmake[1]: Leaving directory '/root/src/target/aarch64-apple-darwin/release/build/libz-ng-sys-e9f281b46d0dead0/out/build/CMakeFiles/CMakeTmp'
      gmake: *** [Makefile:140: cmTC_9e45f/fast] Error 2

    CMake will not be able to correctly generate this project.
  Call Stack (most recent call first):
    CMakeLists.txt:37 (project)

  thread 'main' panicked at '
  command did not execute successfully, got: exit status: 1

  build script failed, must exit now', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.48/src/lib.rs:975:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

But no idea. Maybe it is a misconfiguration issue or we need to build zlib-ng dependency from source.

@unixsurfer
Copy link
Author

Thanks @joseluisq for getting back to me. I have no clue as well:-(

@joseluisq
Copy link
Owner

joseluisq commented Aug 25, 2023

@unixsurfer you can try this with the latest image. I think that should work.

Valid for aarch64-apple-darwin or x86_64-apple-darwin

docker run --rm  --volume "${PWD}":/root/src \
    --workdir /root/src joseluisq/rust-linux-darwin-builder:1.71.1 \
        sh -c "LIBZ_SYS_STATIC=0 CC=o64-clang CXX=o64-clang++ cargo build --release --target aarch64-apple-darwin"

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