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

Failure to cross-compile for Windows on macOS with cargo-zigbuild #512

Open
djc opened this issue Sep 3, 2024 · 9 comments
Open

Failure to cross-compile for Windows on macOS with cargo-zigbuild #512

djc opened this issue Sep 3, 2024 · 9 comments
Assignees
Labels
build problem Build failure

Comments

@djc
Copy link

djc commented Sep 3, 2024

Problem:

When working on Windows aspects of rustup, I like to use cargo-zigbuild to check the Windows build locally. However, since switching rustup to aws-lc-rs (currently at 1.8.1) I am unable to build rustup with cargo-zigbuild, even with NO_ASM=1.

Sorry, this is probably a bit outlandish, but hoping there might be a solution somehow!

Relevant details

AWS-LC for Rust versions or commit: 1.8.1

System information: for linux, below info can be collected by running uname -srvmp

  • CPU architecture: Apple M1 Max
  • OS: macOS Sonoma 14.6.1
  • zig 0.13.0 from Homebrew and cargo-zigbuild 0.19.1

Build log:

djc-2021 windows-registry rustup $ AWS_LC_SYS_NO_ASM=1 cargo-zigbuild clippy --no-default-features --features reqwest-rustls-tls --all-targets --target=x86_64-pc-windows-gnu
    Checking mio v1.0.2
    Checking socket2 v0.5.7
    Checking anstyle-wincon v3.0.4
    Checking anstyle-query v1.1.1
   Compiling aws-lc-sys v0.20.1
    Checking http-body-util v0.1.2
    Checking fs_at v0.2.1
   Compiling rustup v1.27.1 (/Users/djc/src/rustup)
    Checking retry v2.0.0
    Checking home v0.5.9
    Checking proptest v1.5.0
    Checking anstream v0.6.15
    Checking remove_dir_all v0.8.3
    Checking tokio v1.40.0
    Checking clap_builder v4.5.15
    Checking snapbox-macros v0.3.10
    Checking snapbox v0.6.17
    Checking trycmd v0.15.7
    Checking clap v4.5.16
    Checking clap_complete v4.5.24
    Checking tower v0.4.13
    Checking hyper v1.4.1
    Checking async-compression v0.4.12
    Checking tokio-socks v0.5.2
    Checking tokio-util v0.7.11
    Checking tokio-stream v0.1.15
    Checking tokio-retry v0.3.0
    Checking hyper-util v0.1.7
The following warnings were emitted during compilation:

warning: [email protected]: CMAKE environment variable set: cmake
warning: [email protected]: Generating bindings - external bindgen. Platform: x86_64-pc-windows-gnu
warning: [email protected]: CMAKE_TOOLCHAIN_FILE environment variable set: /Users/djc/Library/Caches/cargo-zigbuild/0.18.4/cmake/x86_64-pc-windows-gnu-toolchain.cmake

error: failed to run custom build command for `aws-lc-sys v0.20.1`

Caused by:
  process didn't exit successfully: `/Users/djc/src/rustup/target/debug/build/aws-lc-sys-de2b353b9b14d4bc/build-script-main` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=AWS_LC_SYS_NO_PREFIX
  cargo:rerun-if-env-changed=AWS_LC_SYS_INTERNAL_BINDGEN
  cargo:rerun-if-env-changed=AWS_LC_SYS_EXTERNAL_BINDGEN
  cargo:rerun-if-env-changed=AWS_LC_SYS_NO_ASM
  cargo:rerun-if-env-changed=AWS_LC_SYS_CMAKE_BUILDER
  cargo:rerun-if-env-changed=AWS_LC_SYS_STATIC
  cargo:rerun-if-env-changed=CMAKE
  cargo:rerun-if-env-changed=CMAKE
  cargo:warning=CMAKE environment variable set: cmake
  cargo:warning=Generating bindings - external bindgen. Platform: x86_64-pc-windows-gnu
  cargo:rerun-if-env-changed=AWS_LC_SYS_INCLUDES
  cargo:rustc-cfg=use_bindgen_generated
  cargo:rerun-if-env-changed=AWS_LC_SYS_STATIC
  cargo:rerun-if-env-changed=CMAKE_TOOLCHAIN_FILE
  cargo:rerun-if-env-changed=CMAKE_TOOLCHAIN_FILE_x86_64_pc_windows_gnu
  cargo:warning=CMAKE_TOOLCHAIN_FILE environment variable set: /Users/djc/Library/Caches/cargo-zigbuild/0.18.4/cmake/x86_64-pc-windows-gnu-toolchain.cmake
  CMAKE_TOOLCHAIN_FILE_x86_64-pc-windows-gnu = None
  CMAKE_TOOLCHAIN_FILE_x86_64_pc_windows_gnu = Some("/Users/djc/Library/Caches/cargo-zigbuild/0.18.4/cmake/x86_64-pc-windows-gnu-toolchain.cmake")
  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 = Some("cmake")
  running: cd "/Users/djc/src/rustup/target/x86_64-pc-windows-gnu/debug/build/aws-lc-sys-9889d1ef9e5c597a/out/build" && CMAKE_PREFIX_PATH="" "cmake" "/Users/djc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-lc-sys-0.20.1" "-DBUILD_SHARED_LIBS=0" "-DCMAKE_BUILD_TYPE=debug" "-DBORINGSSL_PREFIX=aws_lc_0_20_1_" "-DBORINGSSL_PREFIX_HEADERS=/Users/djc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-lc-sys-0.20.1/generated-include" "-DBUILD_TESTING=OFF" "-DBUILD_LIBSSL=OFF" "-DDISABLE_PERL=ON" "-DDISABLE_GO=ON" "-DOPENSSL_NO_ASM=1" "-DCMAKE_TOOLCHAIN_FILE=/Users/djc/Library/Caches/cargo-zigbuild/0.18.4/cmake/x86_64-pc-windows-gnu-toolchain.cmake" "-DCMAKE_INSTALL_PREFIX=/Users/djc/src/rustup/target/x86_64-pc-windows-gnu/debug/build/aws-lc-sys-9889d1ef9e5c597a/out" "-DCMAKE_C_FLAGS= --target=x86_64-pc-windows-gnu -ffunction-sections -fdata-sections -m64 --target=x86_64-pc-windows-gnu" "-DCMAKE_CXX_FLAGS= --target=x86_64-pc-windows-gnu -ffunction-sections -fdata-sections -m64 --target=x86_64-pc-windows-gnu" "-DCMAKE_ASM_FLAGS= --target=x86_64-pc-windows-gnu -ffunction-sections -fdata-sections -m64 --target=x86_64-pc-windows-gnu" "--no-warn-unused-cli"
  Not searching for unused variables given on the command line.
  -- Go not found. Disabling some code generation and using pre-generated code in generated-src/
  -- Perl not found. Disabling some code generation and using pre-generated code in generated-src/
  -- stdalign_check.c probe is positive, enabling AWS_LC_STDALIGN_AVAILABLE
  -- builtin_swap_check.c probe is positive, enabling AWS_LC_BUILTIN_SWAP_SUPPORTED
  -- /Users/djc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-lc-sys-0.20.1/aws-lc/generated-src/win-generic/crypto/ assembly files do not exist.
  -- Configuring done (1.7s)
  -- Generating done (0.1s)
  -- Build files have been written to: /Users/djc/src/rustup/target/x86_64-pc-windows-gnu/debug/build/aws-lc-sys-9889d1ef9e5c597a/out/build
  running: cd "/Users/djc/src/rustup/target/x86_64-pc-windows-gnu/debug/build/aws-lc-sys-9889d1ef9e5c597a/out/build" && MAKEFLAGS="-j --jobserver-fds=8,9 --jobserver-auth=8,9" "cmake" "--build" "." "--target" "install" "--config" "Debug"
  [  0%] Built target boringssl_prefix_symbols
  [  0%] Building C object aws-lc/crypto/fipsmodule/CMakeFiles/fipsmodule.dir/bcm.c.obj
  [  0%] Building C object aws-lc/crypto/fipsmodule/CMakeFiles/fipsmodule.dir/fips_shared_support.c.obj
  [  1%] Building C object aws-lc/crypto/fipsmodule/CMakeFiles/fipsmodule.dir/cpucap/cpucap.c.obj
  [  1%] Building C object aws-lc/crypto/CMakeFiles/crypto_objects.dir/asn1/a_bitstr.c.obj
  [  2%] Building C object aws-lc/crypto/CMakeFiles/crypto_objects.dir/asn1/a_bool.c.obj
  [  2%] Building C object aws-lc/crypto/CMakeFiles/crypto_objects.dir/asn1/a_dup.c.obj
  [  2%] Building C object aws-lc/crypto/CMakeFiles/crypto_objects.dir/asn1/a_d2i_fp.c.obj
  [  3%] Building C object aws-lc/crypto/CMakeFiles/crypto_objects.dir/asn1/a_int.c.obj
  [  3%] Building C object aws-lc/crypto/CMakeFiles/crypto_objects.dir/asn1/a_i2d_fp.c.obj
  [  4%] Building C object aws-lc/crypto/CMakeFiles/crypto_objects.dir/asn1/a_gentm.c.obj
  [  4%] Building C object aws-lc/crypto/CMakeFiles/crypto_objects.dir/asn1/a_mbstr.c.obj
  [  4%] Building C object aws-lc/crypto/CMakeFiles/crypto_objects.dir/asn1/a_object.c.obj

  --- stderr
  AWS_LC_SYS_NO_ASM=1
  CMake Deprecation Warning at CMakeLists.txt:4 (cmake_minimum_required):
    Compatibility with CMake < 3.5 will be removed from a future version of
    CMake.

    Update the VERSION argument <min> value or use a ...<max> suffix to tell
    CMake that the project does not need compatibility with older versions.


  CMake Deprecation Warning at aws-lc/CMakeLists.txt:1 (cmake_minimum_required):
    Compatibility with CMake < 3.5 will be removed from a future version of
    CMake.

    Update the VERSION argument <min> value or use a ...<max> suffix to tell
    CMake that the project does not need compatibility with older versions.


  In file included from <built-in>:404:
  <command line>:12:9: error: '_WIN32_WINNT' macro redefined [-Werror,-Wmacro-redefined]
     12 | #define _WIN32_WINNT _WIN32_WINNT_WIN7
        |         ^
  <command line>:2:9: note: previous definition is here
      2 | #define _WIN32_WINNT 0x0603
        |         ^
  In file included from <built-in>:404:
  <command line>:12:9: error: '_WIN32_WINNT' macro redefined [-Werror,-Wmacro-redefined]
     12 | #define _WIN32_WINNT _WIN32_WINNT_WIN7
        |         ^
  <command line>:2:9: note: previous definition is here
      2 | #define _WIN32_WINNT 0x0603
        |         ^
  In file included from <built-in>:404:
  <command line>:12:9: error: '_WIN32_WINNT' macro redefined [-Werror,-Wmacro-redefined]
     12 | #define _WIN32_WINNT _WIN32_WINNT_WIN7
        |         ^
  <command line>:2:9: note: previous definition is here
      2 | #define _WIN32_WINNT 0x0603
        |         ^
  In file included from <built-in>:404:
  <command line>:12:9: error: '_WIN32_WINNT' macro redefined [-Werror,-Wmacro-redefined]
     12 | #define _WIN32_WINNT _WIN32_WINNT_WIN7
        |         ^
  <command line>:2:9: note: previous definition is here
      2 | #define _WIN32_WINNT 0x0603
        |         ^
  1 error generated.
  In file included from <built-in>:404:
  <command line>:12:9: error: '_WIN32_WINNT' macro redefined [-Werror,-Wmacro-redefined]
     12 | #define _WIN32_WINNT _WIN32_WINNT_WIN7
        |         ^
  <command line>:2:9: note: previous definition is here
      2 | #define _WIN32_WINNT 0x0603
        |         ^
  gmake[2]: *** [aws-lc/crypto/fipsmodule/CMakeFiles/fipsmodule.dir/build.make:92: aws-lc/crypto/fipsmodule/CMakeFiles/fipsmodule.dir/fips_shared_support.c.obj] Error 1
  gmake[2]: *** Waiting for unfinished jobs....
  In file included from <built-in>:404:
  <command line>:12:9: error: '_WIN32_WINNT' macro redefined [-Werror,-Wmacro-redefined]
     12 | #define _WIN32_WINNT _WIN32_WINNT_WIN7
        |         ^
  <command line>:2:9: note: previous definition is here
      2 | #define _WIN32_WINNT 0x0603
        |         ^
  In file included from <built-in>:404:
  <command line>:12:9: error: '_WIN32_WINNT' macro redefined [-Werror,-Wmacro-redefined]
     12 | #define _WIN32_WINNT _WIN32_WINNT_WIN7
        |         ^
  <command line>:2:9: note: previous definition is here
      2 | #define _WIN32_WINNT 0x0603
        |         ^
  In file included from In file included from <built-in><built-in>::404404:
  :
  <command line><command line>::1212::99::  error: error: '_WIN32_WINNT' macro redefined [-Werror,-Wmacro-redefined]'_WIN32_WINNT' macro redefined [-Werror,-Wmacro-redefined]

     12 | #define _WIN32_WINNT _WIN32_WINNT_WIN7
        |         ^
  <command line>:2:9: note: previous definition is here
      2 | #define _WIN32_WINNT 0x0603
        |         ^
     12 | #define _WIN32_WINNT _WIN32_WINNT_WIN7
        |         ^
  <command line>:2:9: note: previous definition is here
      2 | #define _WIN32_WINNT 0x0603
        |         ^
  In file included from <built-in>:404:
  <command line>:12:9: error: '_WIN32_WINNT' macro redefined [-Werror,-Wmacro-redefined]
     12 | #define _WIN32_WINNT _WIN32_WINNT_WIN7
        |         ^
  <command line>:2:9: note: previous definition is here
      2 | #define _WIN32_WINNT 0x0603
        |         ^
  1 error generated.
  gmake[2]: *** [aws-lc/crypto/fipsmodule/CMakeFiles/fipsmodule.dir/build.make:107: aws-lc/crypto/fipsmodule/CMakeFiles/fipsmodule.dir/cpucap/cpucap.c.obj] Error 1
  In file included from /Users/djc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-lc-sys-0.20.1/aws-lc/crypto/fipsmodule/bcm.c:41:
  /Users/djc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-lc-sys-0.20.1/aws-lc/crypto/fipsmodule/../internal.h:145:10: fatal error: 'pthread.h' file not found
    145 | #include <pthread.h>
        |          ^~~~~~~~~~~
  1 error generated.
  gmake[2]: *** [aws-lc/crypto/CMakeFiles/crypto_objects.dir/build.make:122: aws-lc/crypto/CMakeFiles/crypto_objects.dir/asn1/a_dup.c.obj] Error 1
  gmake[2]: *** Waiting for unfinished jobs....
  1 error generated.
  1 error generated.
  In file included from /Users/djc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-lc-sys-0.20.1/aws-lc/crypto/asn1/a_int.c:67:
  /Users/djc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-lc-sys-0.20.1/aws-lc/crypto/asn1/../internal.h:145:10: fatal error: 'pthread.h' file not found
    145 | #include <pthread.h>
        |          ^~~~~~~~~~~
  In file included from /Users/djc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-lc-sys-0.20.1/aws-lc/crypto/asn1/a_bitstr.c:65:
  /Users/djc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-lc-sys-0.20.1/aws-lc/crypto/asn1/../internal.h:145:10: fatal error: 'pthread.h' file not found
    145 | #include <pthread.h>
        |          ^~~~~~~~~~~
  gmake[2]: *** [aws-lc/crypto/CMakeFiles/crypto_objects.dir/build.make:107: aws-lc/crypto/CMakeFiles/crypto_objects.dir/asn1/a_d2i_fp.c.obj] Error 1
  1 error generated.
  gmake[2]: *** [aws-lc/crypto/CMakeFiles/crypto_objects.dir/build.make:152: aws-lc/crypto/CMakeFiles/crypto_objects.dir/asn1/a_i2d_fp.c.obj] Error 1
  gmake[2]: *** [aws-lc/crypto/CMakeFiles/crypto_objects.dir/build.make:92: aws-lc/crypto/CMakeFiles/crypto_objects.dir/asn1/a_bool.c.obj] Error 1
  1 error generated.
  2 errors generated.
  2 errors generated.
  gmake[2]: *** [aws-lc/crypto/CMakeFiles/crypto_objects.dir/build.make:137: aws-lc/crypto/CMakeFiles/crypto_objects.dir/asn1/a_gentm.c.obj] Error 1
  gmake[2]: *** [aws-lc/crypto/CMakeFiles/crypto_objects.dir/build.make:77: aws-lc/crypto/CMakeFiles/crypto_objects.dir/asn1/a_bitstr.c.obj] Error 1
  gmake[2]: *** [aws-lc/crypto/CMakeFiles/crypto_objects.dir/build.make:167: aws-lc/crypto/CMakeFiles/crypto_objects.dir/asn1/a_int.c.obj] Error 1
  In file included from <built-in>:404:
  <command line>:12:9: error: '_WIN32_WINNT' macro redefined [-Werror,-Wmacro-redefined]
     12 | #define _WIN32_WINNT _WIN32_WINNT_WIN7
        |         ^
  <command line>:2:9: note: previous definition is here
      2 | #define _WIN32_WINNT 0x0603
        |         ^
  In file included from <built-in>:404:
  <command line>:12:9: error: '_WIN32_WINNT' macro redefined [-Werror,-Wmacro-redefined]
     12 | #define _WIN32_WINNT _WIN32_WINNT_WIN7
        |         ^
  <command line>:2:9: note: previous definition is here
      2 | #define _WIN32_WINNT 0x0603
        |         ^
  1 error generated.
  gmake[2]: *** [aws-lc/crypto/CMakeFiles/crypto_objects.dir/build.make:182: aws-lc/crypto/CMakeFiles/crypto_objects.dir/asn1/a_mbstr.c.obj] Error 1
  In file included from /Users/djc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-lc-sys-0.20.1/aws-lc/crypto/asn1/a_object.c:68:
  /Users/djc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-lc-sys-0.20.1/aws-lc/crypto/asn1/../internal.h:145:10: fatal error: 'pthread.h' file not found
    145 | #include <pthread.h>
        |          ^~~~~~~~~~~
  2 errors generated.
  gmake[2]: *** [aws-lc/crypto/CMakeFiles/crypto_objects.dir/build.make:197: aws-lc/crypto/CMakeFiles/crypto_objects.dir/asn1/a_object.c.obj] Error 1
  gmake[1]: *** [CMakeFiles/Makefile2:204: aws-lc/crypto/CMakeFiles/crypto_objects.dir/all] Error 2
  gmake[1]: *** Waiting for unfinished jobs....
  2 errors generated.
  gmake[2]: *** [aws-lc/crypto/fipsmodule/CMakeFiles/fipsmodule.dir/build.make:77: aws-lc/crypto/fipsmodule/CMakeFiles/fipsmodule.dir/bcm.c.obj] Error 1
  gmake[1]: *** [CMakeFiles/Makefile2:258: aws-lc/crypto/fipsmodule/CMakeFiles/fipsmodule.dir/all] Error 2
  gmake: *** [Makefile:136: all] Error 2
  thread 'main' panicked at /Users/djc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cmake-0.1.51/src/lib.rs:1100:5:

  command did not execute successfully, got: exit status: 2

  build script failed, must exit now
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@justsmth
Copy link
Contributor

justsmth commented Sep 3, 2024

I've started looking into this. I can reproduce the same failure locally compiling directly from my aws-lc-sys directory:

❯ AWS_LC_SYS_NO_ASM=1 cargo-zigbuild build --no-default-features --target=x86_64-pc-windows-gnu
   Compiling jobserver v0.1.32
   Compiling libc v0.2.155
   Compiling cc v1.0.105
   Compiling cmake v0.1.50
   Compiling aws-lc-sys v0.21.0 (/Users/justsmth/repos/aws-lc-rs/aws-lc-sys)
The following warnings were emitted during compilation:

warning: [email protected]: CMAKE environment variable set: cmake
warning: [email protected]: CMAKE_TOOLCHAIN_FILE environment variable set: /Users/justsmth/Library/Caches/cargo-zigbuild/0.19.1/cmake/x86_64-pc-windows-gnu-toolchain.cmake

error: failed to run custom build command for `aws-lc-sys v0.21.0 (/Users/justsmth/repos/aws-lc-rs/aws-lc-sys)`

Caused by:
  process didn't exit successfully: `/Users/justsmth/repos/aws-lc-rs/target/debug/build/aws-lc-sys-a4cf7e5b15bd5bbf/build-script-main` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=AWS_LC_SYS_NO_PREFIX
  cargo:rerun-if-env-changed=AWS_LC_SYS_INTERNAL_BINDGEN
  cargo:rerun-if-env-changed=AWS_LC_SYS_EXTERNAL_BINDGEN
  cargo:rerun-if-env-changed=AWS_LC_SYS_NO_ASM
  cargo:rerun-if-env-changed=AWS_LC_SYS_PREBUILT_NASM
  cargo:rustc-cfg=x86_64_pc_windows_gnu
  cargo:rerun-if-env-changed=AWS_LC_SYS_CMAKE_BUILDER
  cargo:rerun-if-env-changed=AWS_LC_SYS_STATIC
  cargo:rerun-if-env-changed=CMAKE
  cargo:rerun-if-env-changed=CMAKE
  cargo:warning=CMAKE environment variable set: cmake
  cargo:rerun-if-env-changed=AWS_LC_SYS_STATIC
  cargo:rerun-if-env-changed=CMAKE_TOOLCHAIN_FILE
  cargo:rerun-if-env-changed=CMAKE_TOOLCHAIN_FILE_x86_64_pc_windows_gnu
  cargo:warning=CMAKE_TOOLCHAIN_FILE environment variable set: /Users/justsmth/Library/Caches/cargo-zigbuild/0.19.1/cmake/x86_64-pc-windows-gnu-toolchain.cmake
  CMAKE_TOOLCHAIN_FILE_x86_64-pc-windows-gnu = None
  CMAKE_TOOLCHAIN_FILE_x86_64_pc_windows_gnu = Some("/Users/justsmth/Library/Caches/cargo-zigbuild/0.19.1/cmake/x86_64-pc-windows-gnu-toolchain.cmake")
  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 = Some("cmake")
  running: cd "/Users/justsmth/repos/aws-lc-rs/target/x86_64-pc-windows-gnu/debug/build/aws-lc-sys-908713b0ed70e44b/out/build" && CMAKE_PREFIX_PATH="" "cmake" "/Users/justsmth/repos/aws-lc-rs/aws-lc-sys" "-DBUILD_SHARED_LIBS=0" "-DCMAKE_BUILD_TYPE=debug" "-DBORINGSSL_PREFIX=aws_lc_0_21_0_" "-DBORINGSSL_PREFIX_HEADERS=/Users/justsmth/repos/aws-lc-rs/aws-lc-sys/generated-include" "-DBUILD_TESTING=OFF" "-DBUILD_LIBSSL=OFF" "-DDISABLE_PERL=ON" "-DDISABLE_GO=ON" "-DOPENSSL_NO_ASM=1" "-DCMAKE_TOOLCHAIN_FILE=/Users/justsmth/Library/Caches/cargo-zigbuild/0.19.1/cmake/x86_64-pc-windows-gnu-toolchain.cmake" "-DCMAKE_INSTALL_PREFIX=/Users/justsmth/repos/aws-lc-rs/target/x86_64-pc-windows-gnu/debug/build/aws-lc-sys-908713b0ed70e44b/out" "-DCMAKE_C_FLAGS= --target=x86_64-pc-windows-gnu -ffunction-sections -fdata-sections -m64 --target=x86_64-pc-windows-gnu" "-DCMAKE_CXX_FLAGS= --target=x86_64-pc-windows-gnu -ffunction-sections -fdata-sections -m64 --target=x86_64-pc-windows-gnu" "-DCMAKE_ASM_FLAGS= --target=x86_64-pc-windows-gnu -ffunction-sections -fdata-sections -m64 --target=x86_64-pc-windows-gnu" "--no-warn-unused-cli"
  Not searching for unused variables given on the command line.
  -- The C compiler identification is Clang 18.1.6
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - failed
  -- Check for working C compiler: /Users/justsmth/Library/Caches/cargo-zigbuild/0.19.1/zigcc-x86_64-pc-windows-gnu-7a53.sh
  -- Check for working C compiler: /Users/justsmth/Library/Caches/cargo-zigbuild/0.19.1/zigcc-x86_64-pc-windows-gnu-7a53.sh - works
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- Go not found. Disabling some code generation and using pre-generated code in generated-src/
  -- Perl not found. Disabling some code generation and using pre-generated code in generated-src/
  -- stdalign_check.c probe is positive, enabling AWS_LC_STDALIGN_AVAILABLE
  -- builtin_swap_check.c probe is positive, enabling AWS_LC_BUILTIN_SWAP_SUPPORTED
  -- Check if the system is big endian
  -- Searching 16 bit integer
  -- Looking for sys/types.h
  -- Looking for sys/types.h - found
  -- Looking for stdint.h
  -- Looking for stdint.h - found
  -- Looking for stddef.h
  -- Looking for stddef.h - found
  -- Check size of unsigned short
  -- Check size of unsigned short - done
  -- Searching 16 bit integer - Using unsigned short
  -- Check if the system is big endian - little endian
  -- /Users/justsmth/repos/aws-lc-rs/aws-lc-sys/aws-lc/generated-src/win-generic/crypto/ assembly files do not exist.
  -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
  -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
  -- Looking for pthread_create in pthreads
  -- Looking for pthread_create in pthreads - not found
  -- Looking for pthread_create in pthread
  -- Looking for pthread_create in pthread - not found
  -- Check if compiler accepts -pthread
  -- Check if compiler accepts -pthread - no
  -- Found Threads: TRUE
  -- Configuring done (30.8s)
  -- Generating done (0.1s)
  -- Build files have been written to: /Users/justsmth/repos/aws-lc-rs/target/x86_64-pc-windows-gnu/debug/build/aws-lc-sys-908713b0ed70e44b/out/build
  running: cd "/Users/justsmth/repos/aws-lc-rs/target/x86_64-pc-windows-gnu/debug/build/aws-lc-sys-908713b0ed70e44b/out/build" && MAKEFLAGS="-j --jobserver-fds=8,9 --jobserver-auth=8,9" "cmake" "--build" "." "--target" "install" "--config" "Debug"
  [  0%] Built target boringssl_prefix_symbols
  [  0%] Building C object aws-lc/crypto/fipsmodule/CMakeFiles/fipsmodule.dir/bcm.c.obj

  --- stderr
  AWS_LC_SYS_NO_ASM=1
  CMake Deprecation Warning at CMakeLists.txt:4 (cmake_minimum_required):
    Compatibility with CMake < 3.5 will be removed from a future version of
    CMake.

    Update the VERSION argument <min> value or use a ...<max> suffix to tell
    CMake that the project does not need compatibility with older versions.


  CMake Deprecation Warning at aws-lc/CMakeLists.txt:1 (cmake_minimum_required):
    Compatibility with CMake < 3.5 will be removed from a future version of
    CMake.

    Update the VERSION argument <min> value or use a ...<max> suffix to tell
    CMake that the project does not need compatibility with older versions.


  gmake: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
  In file included from <built-in>:404:
  <command line>:12:9: error: '_WIN32_WINNT' macro redefined [-Werror,-Wmacro-redefined]
     12 | #define _WIN32_WINNT _WIN32_WINNT_WIN7
        |         ^
  <command line>:2:9: note: previous definition is here
      2 | #define _WIN32_WINNT 0x0603
        |         ^
  In file included from /Users/justsmth/repos/aws-lc-rs/aws-lc-sys/aws-lc/crypto/fipsmodule/bcm.c:41:
  /Users/justsmth/repos/aws-lc-rs/aws-lc-sys/aws-lc/crypto/fipsmodule/../internal.h:145:10: fatal error: 'pthread.h' file not found
    145 | #include <pthread.h>
        |          ^~~~~~~~~~~
  2 errors generated.
  gmake[2]: *** [aws-lc/crypto/fipsmodule/CMakeFiles/fipsmodule.dir/build.make:77: aws-lc/crypto/fipsmodule/CMakeFiles/fipsmodule.dir/bcm.c.obj] Error 1
  gmake[1]: *** [CMakeFiles/Makefile2:258: aws-lc/crypto/fipsmodule/CMakeFiles/fipsmodule.dir/all] Error 2
  gmake: *** [Makefile:136: all] Error 2
  thread 'main' panicked at /Users/justsmth/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cmake-0.1.50/src/lib.rs:1098:5:

  command did not execute successfully, got: exit status: 2

  build script failed, must exit now
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@justsmth
Copy link
Contributor

justsmth commented Sep 3, 2024

I can reproduce (roughly) the same error building AWS-LC directly using the following CMake toolchain file:

set(CMAKE_ASM_COMPILER "zig")
set(CMAKE_ASM_COMPILER_ARG1 "cc")
set(CMAKE_C_COMPILER "zig")
set(CMAKE_C_COMPILER_ARG1 "cc")
set(CMAKE_CXX_COMPILER "zig")
set(CMAKE_CXX_COMPILER_ARG1 "c++")

set(CMAKE_SYSTEM_NAME "Windows")
set(CMAKE_SYSTEM_PROCESSOR "x86_64")
set(CMAKE_ASM_COMPILER_TARGET "x86_64-windows-gnu")
set(CMAKE_C_COMPILER_TARGET "x86_64-windows-gnu")
set(CMAKE_CXX_COMPILER_TARGET "x86_64-windows-gnu")

@justsmth
Copy link
Contributor

justsmth commented Sep 3, 2024

This seems to be related: ziglang/zig#10989

@justsmth
Copy link
Contributor

justsmth commented Sep 3, 2024

Ok, I've got a patch here that when applied to aws-lc allows this build to succeed:

❯ AWS_LC_SYS_NO_ASM=1 cargo-zigbuild build --no-default-features --target=x86_64-pc-windows-gnu
   Compiling libc v0.2.155
   Compiling once_cell v1.19.0
   Compiling fs_extra v1.3.0
   Compiling dunce v1.0.4
   Compiling paste v1.0.15
   Compiling jobserver v0.1.32
   Compiling cc v1.0.105
   Compiling cmake v0.1.50
   Compiling aws-lc-sys v0.21.0 (/Users/justsmth/repos/aws-lc-rs/aws-lc-sys)
warning: [email protected]: CMAKE environment variable set: cmake
warning: [email protected]: CMAKE_TOOLCHAIN_FILE environment variable set: /Users/justsmth/Library/Caches/cargo-zigbuild/0.19.1/cmake/x86_64-pc-windows-gnu-toolchain.cmake
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 2m 27s

I might be able to get a change like this made upstream, but it'll need some more careful thought/testing.

@justsmth justsmth self-assigned this Sep 3, 2024
@justsmth justsmth added the build problem Build failure label Sep 3, 2024
@justsmth
Copy link
Contributor

justsmth commented Sep 4, 2024

Another issue I found relating AWS-LC supporting the Zig compiler is this one: ziglang/zig#10411

I'm currently running into this error condition on my Mac.

@justsmth
Copy link
Contributor

justsmth commented Sep 5, 2024

AWS-LC's CMake configuration depends on CMAKE_SIZEOF_VOID_P, which currently doesn't work properly with the zig compiler. This should be fixed in zig's next release.

@rami3l
Copy link

rami3l commented Sep 5, 2024

@justsmth Thanks a lot for your investigation so far!

Another issue I found relating AWS-LC supporting the Zig compiler is this one: ziglang/zig#10411

I'm currently running into this error condition on my Mac.

Is this why we need to disable ASM in the build so far? If so, that wouldn't be that much of a problem, since we're just using cargo zigbuild for compilation checks on macOS: we're not currently planning to use this in our CI/CD whatsoever.

@justsmth
Copy link
Contributor

justsmth commented Sep 5, 2024

Is this why we need to disable ASM in the build so far?

That issue is part of the problem, but I think there's more to it. I even get this error when building AWS-LC with the OPENSSL_NO_ASM flag set.

If it helps, I've got a Cmake toolchain file that seems to work for me on my ARM64 Mac. (It builds with the assembly enabled.) I've pushed the toolchain file and some other "Work In Progress" changes onto this branch.

@rami3l
Copy link

rami3l commented Sep 8, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build problem Build failure
Projects
None yet
Development

No branches or pull requests

3 participants