From ad2bb89ed7c83bd387da664cdc31350717728738 Mon Sep 17 00:00:00 2001 From: Micah Snyder Date: Wed, 10 Jul 2024 18:33:55 -0400 Subject: [PATCH] Windows: fix build issue with newer version of Rust Newer versions of Rust appear to include '/defaultlib:msvcrt' in the list of native static libs when you run '--print=native-static-libs'. MSVC doesn't know what to do with this when passed as a linker dependency. Since msvcrt.lib is ALSO listed, the solution seems to be to strip this item from the list. --- cmake/FindRust.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/FindRust.cmake b/cmake/FindRust.cmake index ffa86e33f1..bb47e8b004 100644 --- a/cmake/FindRust.cmake +++ b/cmake/FindRust.cmake @@ -428,6 +428,10 @@ foreach(LINE ${LINE_LIST}) endif() string(REPLACE "native-static-libs: " "" LINE "${LINE}") + + # Some Rust versions have a defaultlib:msvcrt; in the output, which we don't want. + string(REGEX REPLACE " /defaultlib:msvcrt" "" LINE "${LINE}") + string(REGEX REPLACE " " "" LINE "${LINE}") string(REGEX REPLACE " " ";" LINE "${LINE}")