From 7c716e98bf624451ddcf307d6cb910b33904839b Mon Sep 17 00:00:00 2001 From: Russell Greene Date: Sun, 6 Oct 2024 00:20:05 -0600 Subject: [PATCH 1/8] clang,windows: fix passing link flags when using clang in GNU frontend mode on windows --- cmake/FindRust.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmake/FindRust.cmake b/cmake/FindRust.cmake index d24c3678..7ecbb867 100644 --- a/cmake/FindRust.cmake +++ b/cmake/FindRust.cmake @@ -184,7 +184,13 @@ function(_corrosion_determine_libs_new target_triple out_libs out_flags) # Flags start with / for MSVC if (lib MATCHES "^/" AND ${target_triple} MATCHES "msvc$") - list(APPEND flag_list "${lib}") + # Windows GNU uses the compiler to invoke the linker, so -Wl, prefix is needed + # https://gitlab.kitware.com/cmake/cmake/-/blob/9bed4f4d817f139f0c2e050d7420e1e247949fe4/Modules/Platform/Windows-GNU.cmake#L156 + if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU") + list(APPEND flag_list "-Wl,${lib}") + else() + list(APPEND flag_list "${lib}") + endif() else() # Strip leading `-l` (unix) and potential .lib suffix (windows) string(REGEX REPLACE "^-l" "" "stripped_lib" "${lib}") From aa8effa3ea62d7e6b25bba08a4add2fc2bd961ed Mon Sep 17 00:00:00 2001 From: Russell Greene Date: Sun, 6 Oct 2024 12:03:38 -0600 Subject: [PATCH 2/8] initial attempt at CI --- .github/workflows/test.yaml | 5 +++++ CMakePresets.json | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 7f218126..61a9f219 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -61,6 +61,7 @@ jobs: compiler: - cl - clang-cl + - clang include: - os: windows-2022 vs_version: vs-2022 @@ -79,6 +80,10 @@ jobs: arch: i686 - compiler: clang-cl arch: aarch64 + - compiler: clang + arch: i686 + - compiler: clang + arch: aarch64 steps: - uses: actions/checkout@v4 diff --git a/CMakePresets.json b/CMakePresets.json index 4a3bae55..1be20298 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -200,6 +200,10 @@ "name": "ninja-x86_64-pc-windows-msvc-clang-cl", "inherits": ["ninja", "x86_64-pc-windows-msvc", "clang-cl"] }, + { + "name": "ninja-x86_64-pc-windows-msvc-clang", + "inherits": ["ninja", "x86_64-pc-windows-msvc", "clang"] + }, { "name": "ninja-i686-pc-windows-msvc-cl", "inherits": ["ninja", "i686-pc-windows-msvc", "cl", "windows-10-cross"] @@ -208,6 +212,10 @@ "name": "ninja-i686-pc-windows-msvc-clang-cl", "inherits": ["ninja", "i686-pc-windows-msvc", "clang-cl", "windows-10-cross"] }, + { + "name": "ninja-i686-pc-windows-msvc-clang", + "inherits": ["ninja", "i686-pc-windows-msvc", "clang", "windows-10-cross"] + }, { "name": "ninja-aarch64-pc-windows-msvc-cl", "inherits": ["ninja", "aarch64-pc-windows-msvc", "cl", "windows-10-cross"] @@ -216,6 +224,10 @@ "name": "ninja-aarch64-pc-windows-msvc-clang-cl", "inherits": ["ninja", "aarch64-pc-windows-msvc", "clang-cl", "windows-10-cross"] }, + { + "name": "ninja-aarch64-pc-windows-msvc-clang", + "inherits": ["ninja", "aarch64-pc-windows-msvc", "clang", "windows-10-cross"] + }, { "name": "ninja-x86_64-pc-windows-gnullvm", "inherits": ["ninja", "windows-only", "clang"], From 3f8cf4b7bda21322788076a0fcdc30a7a5890e6f Mon Sep 17 00:00:00 2001 From: Russell Greene Date: Sun, 6 Oct 2024 12:11:40 -0600 Subject: [PATCH 3/8] bump rust in CI --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 61a9f219..8a013e14 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -66,7 +66,7 @@ jobs: - os: windows-2022 vs_version: vs-2022 cmake: 3.22.6 - - rust: 1.54.0 + - rust: 1.80.0 # Add variable mapping for ilammy/msvc-dev-cmd action - arch: x86_64 msvc_dev_arch: amd64 From 9ef8a809ce82231e84a8260a2199202ddf2e0359 Mon Sep 17 00:00:00 2001 From: Russell Greene Date: Sun, 6 Oct 2024 12:11:48 -0600 Subject: [PATCH 4/8] Revert "clang,windows: fix passing link flags when using clang in GNU frontend mode on windows" This reverts commit 7c716e98bf624451ddcf307d6cb910b33904839b. --- cmake/FindRust.cmake | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/cmake/FindRust.cmake b/cmake/FindRust.cmake index 7ecbb867..d24c3678 100644 --- a/cmake/FindRust.cmake +++ b/cmake/FindRust.cmake @@ -184,13 +184,7 @@ function(_corrosion_determine_libs_new target_triple out_libs out_flags) # Flags start with / for MSVC if (lib MATCHES "^/" AND ${target_triple} MATCHES "msvc$") - # Windows GNU uses the compiler to invoke the linker, so -Wl, prefix is needed - # https://gitlab.kitware.com/cmake/cmake/-/blob/9bed4f4d817f139f0c2e050d7420e1e247949fe4/Modules/Platform/Windows-GNU.cmake#L156 - if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU") - list(APPEND flag_list "-Wl,${lib}") - else() - list(APPEND flag_list "${lib}") - endif() + list(APPEND flag_list "${lib}") else() # Strip leading `-l` (unix) and potential .lib suffix (windows) string(REGEX REPLACE "^-l" "" "stripped_lib" "${lib}") From 7ec6c1fb71e02617dda6645f681100bd85723062 Mon Sep 17 00:00:00 2001 From: Russell Greene Date: Sun, 6 Oct 2024 12:17:35 -0600 Subject: [PATCH 5/8] bump again? --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 8a013e14..c7d5b4cf 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -66,7 +66,7 @@ jobs: - os: windows-2022 vs_version: vs-2022 cmake: 3.22.6 - - rust: 1.80.0 + - rust: 1.81.0 # Add variable mapping for ilammy/msvc-dev-cmd action - arch: x86_64 msvc_dev_arch: amd64 From 9b3ea1c916cbfc16dc1941785c75cda8aeed2930 Mon Sep 17 00:00:00 2001 From: Russell Greene Date: Sun, 6 Oct 2024 12:27:59 -0600 Subject: [PATCH 6/8] Reapply "clang,windows: fix passing link flags when using clang in GNU frontend mode on windows" This reverts commit 9ef8a809ce82231e84a8260a2199202ddf2e0359. --- cmake/FindRust.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmake/FindRust.cmake b/cmake/FindRust.cmake index d24c3678..7ecbb867 100644 --- a/cmake/FindRust.cmake +++ b/cmake/FindRust.cmake @@ -184,7 +184,13 @@ function(_corrosion_determine_libs_new target_triple out_libs out_flags) # Flags start with / for MSVC if (lib MATCHES "^/" AND ${target_triple} MATCHES "msvc$") - list(APPEND flag_list "${lib}") + # Windows GNU uses the compiler to invoke the linker, so -Wl, prefix is needed + # https://gitlab.kitware.com/cmake/cmake/-/blob/9bed4f4d817f139f0c2e050d7420e1e247949fe4/Modules/Platform/Windows-GNU.cmake#L156 + if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU") + list(APPEND flag_list "-Wl,${lib}") + else() + list(APPEND flag_list "${lib}") + endif() else() # Strip leading `-l` (unix) and potential .lib suffix (windows) string(REGEX REPLACE "^-l" "" "stripped_lib" "${lib}") From 8ba88ba6673e64aaaf3f4a40253d4df951ef8039 Mon Sep 17 00:00:00 2001 From: Russell Greene Date: Sun, 6 Oct 2024 12:28:29 -0600 Subject: [PATCH 7/8] reset version --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c7d5b4cf..61a9f219 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -66,7 +66,7 @@ jobs: - os: windows-2022 vs_version: vs-2022 cmake: 3.22.6 - - rust: 1.81.0 + - rust: 1.54.0 # Add variable mapping for ilammy/msvc-dev-cmd action - arch: x86_64 msvc_dev_arch: amd64 From 940e3fdd7f9ef37616f566a5c458940146584586 Mon Sep 17 00:00:00 2001 From: Russell Greene Date: Sun, 6 Oct 2024 12:31:40 -0600 Subject: [PATCH 8/8] hopefully fix interaction with #537 --- cmake/FindRust.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/FindRust.cmake b/cmake/FindRust.cmake index 7ecbb867..51a4b16b 100644 --- a/cmake/FindRust.cmake +++ b/cmake/FindRust.cmake @@ -202,7 +202,7 @@ function(_corrosion_determine_libs_new target_triple out_libs out_flags) # We leave it up to the C/C++ executable that links in the Rust static-library # to determine which version of the msvc runtime library it should select. list(FILTER libs_list EXCLUDE REGEX "^msvcrtd?") - list(FILTER flag_list EXCLUDE REGEX "^/defaultlib:msvcrtd?") + list(FILTER flag_list EXCLUDE REGEX "^(-Wl,)?/defaultlib:msvcrtd?") else() message(DEBUG "Determining required native libraries - failed: Regex match failure.") message(DEBUG "`native-static-libs` not found in: `${cargo_build_error_message}`")