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

Fail to cross compilation on Linux for Mac #25

Open
viirya opened this issue Jun 6, 2022 · 1 comment
Open

Fail to cross compilation on Linux for Mac #25

viirya opened this issue Jun 6, 2022 · 1 comment

Comments

@viirya
Copy link

viirya commented Jun 6, 2022

Hi,

I'm working on cross-compilation of a project on Linux for Mac binaries. Got an error currently:

error: failed to run custom build command for `lz4-sys v1.9.2`

Caused by:
  process didn't exit successfully: `/opt/core/target/release/build/lz4-sys-635d53f76c21d05f/build-script-build` (exit status: 1)
  --- stdout
  TARGET = Some("aarch64-apple-darwin")
  HOST = Some("x86_64-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("true")
  CARGO_CFG_TARGET_FEATURE = Some("aes,crc,dit,dotprod,dpb,dpb2,fcma,fhm,flagm,fp16,frintts,jsconv,llvm14-builtins-abi,lor,lse,neon,paca,pacg,pan,pmuv3,ras,rcpc,rcpc2,rdm,sb,sha2,sha3,ssbs,v8.1a,v8.2a,v8.3a,v8.4a,vh")
  running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-arch" "arm64" "-Wall" "-Wextra" "-o" "/opt/core/target/aarch64-apple-darwin/release/build/lz4-sys-6a23633e37c16f77/out/liblz4/lib/lz4.o" "-c" "liblz4/lib/lz4.c"
  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
  running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-arch" "arm64" "-Wall" "-Wextra" "-o" "/opt/core/target/aarch64-apple-darwin/release/build/lz4-sys-6a23633e37c16f77/out/liblz4/lib/lz4frame.o" "-c" "liblz4/lib/lz4frame.c"
  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

So based on https://stackoverflow.com/questions/4391192/why-do-i-get-cc1plus-error-unrecognized-command-line-option-arch, seems -arch is only for Xcode's gcc. Not sure if lz4-sys's custom build script is able to make some change to fix that?

@viirya
Copy link
Author

viirya commented Jun 7, 2022

After installing osxcross toolchain, x86_64-apple-darwin can be cross-built. But aarch64-apple-darwin still fails with an error:

  = note: ld: in /lz4-rs/target/aarch64-apple-darwin/debug/deps/liblz4_sys-8410d92b71c4cdc8.rlib(lz4frame.o), archive member 'lz4frame.o' with length 72128 is not mach-o or llvm bitcode for architecture arm64
          clang-12: error: linker command failed with exit code 1 (use -v to see invocation)

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

1 participant