Skip to content

Commit

Permalink
Leave choosing msvcrt up to the C/C++ CMake code (#537)
Browse files Browse the repository at this point in the history
* Leave choosing `msvcrt` up to the C/C++ CMake code

It's difficult for Corrosion to correctly choose the right
msvcrt version. CMake has a target property for it, and we
also don't know which build configurations the user CMake
code expectes to be Debug related.

The previous code actually already removed the linking
against `msvcrt` in all cases except "Debug" builds.
This was not intentional, but indicates that removing
the library entirely from the link list, and leaving
it up to the C/C++ code to link it in, should work
well in practice.

Co-authored-by: kotoriのねこ <[email protected]>
  • Loading branch information
jschwe and Billyzou0741326 authored Jun 23, 2024
1 parent c1c9824 commit b45275c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cmake/FindRust.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,10 @@ function(_corrosion_determine_libs_new target_triple out_libs out_flags)
endif()
endforeach()
set(libs_list "${stripped_lib_list}")
# Special case `msvcrt` to link with the debug version in Debug mode.
list(TRANSFORM libs_list REPLACE "^msvcrt$" "\$<\$<CONFIG:Debug>:msvcrtd>")
# 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?")
else()
message(DEBUG "Determining required native libraries - failed: Regex match failure.")
message(DEBUG "`native-static-libs` not found in: `${cargo_build_error_message}`")
Expand Down

0 comments on commit b45275c

Please sign in to comment.