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"], diff --git a/cmake/FindRust.cmake b/cmake/FindRust.cmake index d24c3678..51a4b16b 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}") @@ -196,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}`")