Skip to content

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

Open
@djc

Description

@djc

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions