cloudflare / boring

BoringSSL bindings for the Rust programming language.
367 stars 114 forks source link

[boring-sys] Failed to cross-compile from Linux to Windows #71

Open avently opened 2 years ago

avently commented 2 years ago

Hello. Trying to build an app with boring-sys for Windows using x86_64-pc-windows-gnu target from Manjaro (based on Archlinux). I have mingw packages installed (mingw-w64-gcc, mingw-w64-binutils, mingw-w64-crt, mingw-w64-headers, mingw-w64-winpthreads). Tried with rust stable (rustc 1.60.0) and nightly. Result is the same.

I don't know what I can do here from my side in order to successfully build the app. Could you please suggest my next steps?

cargo build --release --target x86_64-pc-windows-gnu
   Compiling boring-sys v2.0.0
error: failed to run custom build command for `boring-sys v2.0.0`

Caused by:
  process didn't exit successfully: `/mnt/Build/cargo/release/build/boring-sys-ae341c073d555390/build-script-build` (exit status: 101)
  --- stdout
  CMAKE_TOOLCHAIN_FILE_x86_64-pc-windows-gnu = None
  CMAKE_TOOLCHAIN_FILE_x86_64_pc_windows_gnu = None
  TARGET_CMAKE_TOOLCHAIN_FILE = None
  CMAKE_TOOLCHAIN_FILE = None
  CMAKE_GENERATOR_x86_64-pc-windows-gnu = None
  CMAKE_GENERATOR_x86_64_pc_windows_gnu = None
  TARGET_CMAKE_GENERATOR = None
  CMAKE_GENERATOR = None
  CMAKE_PREFIX_PATH_x86_64-pc-windows-gnu = None
  CMAKE_PREFIX_PATH_x86_64_pc_windows_gnu = None
  TARGET_CMAKE_PREFIX_PATH = None
  CMAKE_PREFIX_PATH = None
  CMAKE_x86_64-pc-windows-gnu = None
  CMAKE_x86_64_pc_windows_gnu = None
  TARGET_CMAKE = None
  CMAKE = None
  running: "cmake" "/home/dev/.cargo/registry/src/github.com-1ecc6299db9ec823/boring-sys-2.0.0/deps/boringssl" "-DCMAKE_SYSTEM_NAME=Windows" "-DCMAKE_RC_COMPILER=/bin/x86_64-w64-mingw32-windres" "-DCMAKE_INSTALL_PREFIX=/mnt/Build/cargo/x86_64-pc-windows-gnu/release/build/boring-sys-339cd2bb124cb955/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -m64" "-DCMAKE_C_COMPILER=/bin/x86_64-w64-mingw32-gcc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -m64" "-DCMAKE_CXX_COMPILER=/bin/x86_64-w64-mingw32-g++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -m64" "-DCMAKE_ASM_COMPILER=/bin/x86_64-w64-mingw32-gcc" "-DCMAKE_BUILD_TYPE=Release"
  -- Configuring incomplete, errors occurred!
  See also "/mnt/Build/cargo/x86_64-pc-windows-gnu/release/build/boring-sys-339cd2bb124cb955/out/build/CMakeFiles/CMakeOutput.log".

  --- stderr
  CMake Error at CMakeLists.txt:65 (elseif):
    given arguments:

      "STREQUAL" "x86_64"

    Unknown arguments specified

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

  build script failed, must exit now', /home/dev/.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

Attaching CMakeOutput.log as well:

CMakeOutput.log

Line 65 of CMakeList (from the error above) this one:

62: if(OPENSSL_NO_ASM)
63:  add_definitions(-DOPENSSL_NO_ASM)
64:   set(ARCH "generic")
65: elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
66:   set(ARCH "x86_64")
67: elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "amd64")
68:   set(ARCH "x86_64")
69: elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64")
70:   # cmake reports AMD64 on Windows, but we might be building for 32-bit.
71:   if(CMAKE_SIZEOF_VOID_P EQUAL 8)
72:    set(ARCH "x86_64")
73:   else()
74:     set(ARCH "x86")
75:   endif()
avently commented 2 years ago

For reproducing you can build your lib using project cross: cross build --release --target x86_64-pc-windows-gnu

Same problem with other targets. This situation actually stops from using boring-sys as well as libraries that depends on it. I would really appretiate if you find a time for making more main targets supported like linux arm64 (+arm), windows (+arm64). Because the one possible lib that gives enough functionality is BoringSSL.

This is logs for aarch64-unknown-linux-musl target:

tons of lines like: 
  /cargo/registry/src/github.com-1ecc6299db9ec823/boring-sys-2.0.0/deps/boringssl/src/crypto/hrss/asm/poly_rq_mul.S:8448: Error: unknown mnemonic `vmovdqu' -- `vmovdqu 968(%rdi)
,%ymm11'
  /cargo/registry/src/github.com-1ecc6299db9ec823/boring-sys-2.0.0/deps/boringssl/src/crypto/hrss/asm/poly_rq_mul.S:8449: Error: unknown mnemonic `vpaddw' -- `vpaddw 2496(%rsp),
%ymm11,%ymm11'
  /cargo/registry/src/github.com-1ecc6299db9ec823/boring-sys-2.0.0/deps/boringssl/src/crypto/hrss/asm/poly_rq_mul.S:8450: Error: unknown mnemonic `vpand' -- `vpand mask_mod8192(
%rip),%ymm11,%ymm11'
  /cargo/registry/src/github.com-1ecc6299db9ec823/boring-sys-2.0.0/deps/boringssl/src/crypto/hrss/asm/poly_rq_mul.S:8451: Error: unknown mnemonic `vmovdqu' -- `vmovdqu %ymm11,96
8(%rdi)'
  /cargo/registry/src/github.com-1ecc6299db9ec823/boring-sys-2.0.0/deps/boringssl/src/crypto/hrss/asm/poly_rq_mul.S:8452: Error: unknown mnemonic `vmovdqu' -- `vmovdqu 1320(%rdi
),%ymm11'
  /cargo/registry/src/github.com-1ecc6299db9ec823/boring-sys-2.0.0/deps/boringssl/src/crypto/hrss/asm/poly_rq_mul.S:8453: Error: unknown mnemonic `vpaddw' -- `vpaddw 2752(%rsp),
%ymm11,%ymm11'
  /cargo/registry/src/github.com-1ecc6299db9ec823/boring-sys-2.0.0/deps/boringssl/src/crypto/hrss/asm/poly_rq_mul.S:8454: Error: unknown mnemonic `vpand' -- `vpand mask_mod8192(
%rip),%ymm11,%ymm11'
  /cargo/registry/src/github.com-1ecc6299db9ec823/boring-sys-2.0.0/deps/boringssl/src/crypto/hrss/asm/poly_rq_mul.S:8455: Error: unknown mnemonic `vmovdqu' -- `vmovdqu %ymm11,13
20(%rdi)'
  /cargo/registry/src/github.com-1ecc6299db9ec823/boring-sys-2.0.0/deps/boringssl/src/crypto/hrss/asm/poly_rq_mul.S:8456: Error: operand 1 must be an integer register -- `mov %r
8,%rsp'
  /cargo/registry/src/github.com-1ecc6299db9ec823/boring-sys-2.0.0/deps/boringssl/src/crypto/hrss/asm/poly_rq_mul.S:8457: Error: unknown mnemonic `pop' -- `pop %r12'
  /cargo/registry/src/github.com-1ecc6299db9ec823/boring-sys-2.0.0/deps/boringssl/src/crypto/hrss/asm/poly_rq_mul.S:8458: Error: bad register expression
  /cargo/registry/src/github.com-1ecc6299db9ec823/boring-sys-2.0.0/deps/boringssl/src/crypto/hrss/asm/poly_rq_mul.S:8459: Error: unknown mnemonic `pop' -- `pop %rbp'
  /cargo/registry/src/github.com-1ecc6299db9ec823/boring-sys-2.0.0/deps/boringssl/src/crypto/hrss/asm/poly_rq_mul.S:8460: Error: bad register expression
  /cargo/registry/src/github.com-1ecc6299db9ec823/boring-sys-2.0.0/deps/boringssl/src/crypto/hrss/asm/poly_rq_mul.S:8461: Error: bad register expression
  make[3]: *** [CMakeFiles/crypto.dir/src/crypto/hrss/asm/poly_rq_mul.S.o] Error 1
  make[3]: *** Waiting for unfinished jobs....
  make[2]: *** [CMakeFiles/crypto.dir/all] Error 2
  make[2]: *** Waiting for unfinished jobs....
  make[1]: *** [CMakeFiles/bssl.dir/rule] Error 2
  make: *** [bssl] Error 2
  thread 'main' panicked at '
  command did not execute successfully, got: exit status: 2