From 37884d0114e5e26d62cdc14bd99495479d4737dc Mon Sep 17 00:00:00 2001 From: Justin Smith Date: Mon, 1 Jul 2024 09:41:08 -0400 Subject: [PATCH] Windows treat link warnings as error --- .github/workflows/cross.yml | 6 ++++++ aws-lc-sys/builder/cmake_builder.rs | 8 +++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cross.yml b/.github/workflows/cross.yml index 8a0c845731f..fc293a32dea 100644 --- a/.github/workflows/cross.yml +++ b/.github/workflows/cross.yml @@ -116,6 +116,8 @@ jobs: cargo-xwin: if: github.repository_owner == 'aws' runs-on: ubuntu-latest + env: + RUSTFLAGS: '-Clink-arg=/WX' steps: - name: Install build dependencies run: | @@ -142,6 +144,8 @@ jobs: if: github.repository_owner == 'aws' name: ${{ matrix.target }} runs-on: windows-latest + env: + RUSTFLAGS: '-Clink-arg=/WX' strategy: fail-fast: false matrix: @@ -180,6 +184,8 @@ jobs: if: github.repository_owner == 'aws' name: aarch64-pc-windows-msvc runs-on: windows-latest + env: + RUSTFLAGS: '-Clink-arg=/WX' steps: - uses: actions/checkout@v3 with: diff --git a/aws-lc-sys/builder/cmake_builder.rs b/aws-lc-sys/builder/cmake_builder.rs index f6e52f91556..fc867a35c1f 100644 --- a/aws-lc-sys/builder/cmake_builder.rs +++ b/aws-lc-sys/builder/cmake_builder.rs @@ -68,15 +68,16 @@ impl CmakeBuilder { fn get_cmake_config(&self) -> cmake::Config { let mut cmake_cfg = cmake::Config::new(&self.manifest_dir); - // See issue: https://github.com/aws/aws-lc-rs/issues/453 - cmake_cfg.static_crt(true); + if cargo_env("CARGO_ENCODED_RUSTFLAGS").contains("-Ctarget-feature=+crt-static") { + // See issue: https://github.com/aws/aws-lc-rs/issues/453 + cmake_cfg.static_crt(true); + } cmake_cfg } #[allow(clippy::too_many_lines)] fn prepare_cmake_build(&self) -> cmake::Config { let mut cmake_cfg = self.get_cmake_config(); - if OutputLibType::default() == OutputLibType::Dynamic { cmake_cfg.define("BUILD_SHARED_LIBS", "1"); } else { @@ -91,6 +92,7 @@ impl CmakeBuilder { cmake_cfg.define("CMAKE_BUILD_TYPE", "release"); } } else if target_os() == "windows" { + // See issue: https://github.com/aws/aws-lc-rs/issues/453 cmake_cfg.define("CMAKE_BUILD_TYPE", "relwithdebinfo"); } else { cmake_cfg.define("CMAKE_BUILD_TYPE", "debug");