rust-cross / cargo-xwin

Cross compile Cargo project to Windows MSVC target with ease
Other
357 stars 30 forks source link

Unable to build for aarch64-pc-windows-msvc target with ring 0.17.5 dependency #76

Open ancwrd1 opened 1 year ago

ancwrd1 commented 1 year ago

As far as I understand ring 0.17 supports aarch64-cp-windows-msvc target, however when trying to build it with xwin I get the following error:

error: failed to run custom build command for `ring v0.17.5`

Caused by:
  process didn't exit successfully: `/tmp/test-ring/target/debug/build/ring-2031b15c66896d66/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=RING_PREGENERATE_ASM
  cargo:rustc-env=RING_CORE_PREFIX=ring_core_0_17_5_
  OPT_LEVEL = Some("0")
  TARGET = Some("aarch64-pc-windows-msvc")
  HOST = Some("x86_64-unknown-linux-gnu")
  cargo:rerun-if-env-changed=CC_aarch64-pc-windows-msvc
  CC_aarch64-pc-windows-msvc = None
  cargo:rerun-if-env-changed=CC_aarch64_pc_windows_msvc
  CC_aarch64_pc_windows_msvc = Some("clang-cl")
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  CARGO_CFG_TARGET_FEATURE = Some("crt-static,neon")
  DEBUG = Some("true")
  cargo:rerun-if-env-changed=CFLAGS_aarch64-pc-windows-msvc
  CFLAGS_aarch64-pc-windows-msvc = None
  cargo:rerun-if-env-changed=CFLAGS_aarch64_pc_windows_msvc
  CFLAGS_aarch64_pc_windows_msvc = Some("--target=aarch64-pc-windows-msvc -Wno-unused-command-line-argument -fuse-ld=lld-link /imsvc/home/user/.cache/cargo-xwin/xwin/crt/include /imsvc/home/user/.cache/cargo-xwin/xwin/sdk/include/ucrt /imsvc/home/user/.cache/cargo-xwin/xwin/sdk/include/um /imsvc/home/user/.cache/cargo-xwin/xwin/sdk/include/shared  ")

  --- stderr
  running "clang" "-O0" "--target=aarch64-pc-windows-msvc" "-ffunction-sections" "-fdata-sections" "-g" "-fno-omit-frame-pointer" "--target=aarch64-pc-windows-msvc" "--target=aarch64-pc-windows-msvc" "-Wno-unused-command-line-argument" "-fuse-ld=lld-link" "/imsvc/home/user/.cache/cargo-xwin/xwin/crt/include" "/imsvc/home/user/.cache/cargo-xwin/xwin/sdk/include/ucrt" "/imsvc/home/user/.cache/cargo-xwin/xwin/sdk/include/um" "/imsvc/home/user/.cache/cargo-xwin/xwin/sdk/include/shared" "-I" "include" "-I" "/tmp/test-ring/target/aarch64-pc-windows-msvc/debug/build/ring-8705dbada3a9c548/out" "-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" "-g3" "-DNDEBUG" "-c" "-o/tmp/test-ring/target/aarch64-pc-windows-msvc/debug/build/ring-8705dbada3a9c548/out/aesv8-armx-win64.o" "/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ring-0.17.5/pregenerated/aesv8-armx-win64.S"
  clang: error: no such file or directory: '/imsvc/home/user/.cache/cargo-xwin/xwin/crt/include'
  clang: error: no such file or directory: '/imsvc/home/user/.cache/cargo-xwin/xwin/sdk/include/ucrt'
  clang: error: no such file or directory: '/imsvc/home/user/.cache/cargo-xwin/xwin/sdk/include/um'
  clang: error: no such file or directory: '/imsvc/home/user/.cache/cargo-xwin/xwin/sdk/include/shared'
  thread 'main' panicked at /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ring-0.17.5/build.rs:676:9:
  execution failed
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
messense commented 1 year ago

Looks like /home/user/.cache/cargo-xwin/xwin/ directory has been deleted by something.

messense commented 1 year ago

Anyway, can you try delete the whole /home/user/.cache/cargo-xwin directory and re-run? I suspect it might have something to do with #74.

ancwrd1 commented 1 year ago

Tried cleaning it up but without much success. If I look at the command line output:

...
running "clang" "-O3" "--target=aarch64-pc-windows-msvc"
...
"/imsvc/home/dmitry/.cache/cargo-xwin/xwin/sdk/include/ucrt"

It seems that there is a mix of gnu-style and msvc-style arguments which is probably a cause of the issue because the leading slash is not recognized as an option.

ancwrd1 commented 1 year ago

Simple to reproduce:

cargo init test-ring
cd test-ring
cargo add ring
cargo xwin build --target aarch64-pc-windows-msvc
messense commented 1 year ago

https://github.com/briansmith/ring/blob/a9b88826e7826a6f9422680fb6240f75511cf2c7/build.rs#L580

I'm not sure what we can do here, ring forces clang instead of supporting both clang and clang-cl.

https://github.com/rust-cross/cargo-xwin/blob/e851cd59d6db5a2b531d6145327306c5f7d14fc2/src/common.rs#L149-L152

ancwrd1 commented 1 year ago

But then I am wondering why does it work for x86_64?

ancwrd1 commented 1 year ago

Ah, sorry, I see the code in the ring specifically for AARCH64...