Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FindRust: support gnullvm #552

Merged
merged 2 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmake/Corrosion.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ function(_corrosion_add_library_target)
set(is_windows TRUE)
if(Rust_CARGO_TARGET_ENV STREQUAL "msvc")
set(is_windows_msvc TRUE)
elseif(Rust_CARGO_TARGET_ENV STREQUAL "gnu")
elseif(Rust_CARGO_TARGET_ENV STREQUAL "gnu" OR Rust_CARGO_TARGET_ENV STREQUAL "gnullvm")
set(is_windows_gnu TRUE)
endif()
elseif(Rust_CARGO_TARGET_OS STREQUAL "darwin")
Expand Down
24 changes: 20 additions & 4 deletions cmake/FindRust.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -686,13 +686,29 @@ if (NOT Rust_CARGO_TARGET_CACHED)
set(_CARGO_ABI msvc)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU"
OR "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU"
OR "${CMAKE_CXX_COMPILER_TARGET}" MATCHES "-gnu$"
OR "${CMAKE_C_COMPILER_TARGET}" MATCHES "-gnu$"
OR (NOT CMAKE_CROSSCOMPILING AND "${Rust_DEFAULT_HOST_TARGET}" MATCHES "-gnu$")
OR (NOT CMAKE_CROSSCOMPILING
AND NOT DEFINED CMAKE_CXX_COMPILER_ID
AND NOT DEFINED CMAKE_C_COMPILER_ID
AND "${Rust_DEFAULT_HOST_TARGET}" MATCHES "-gnu$"
)
)
set(_CARGO_ABI gnu)
elseif(("${CMAKE_C_COMPILER_ID}" MATCHES "Clang$" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang$")
AND ("${CMAKE_CXX_COMPILER_TARGET}" MATCHES "-gnu(llvm)?$"
OR "${CMAKE_C_COMPILER_TARGET}" MATCHES "-gnu(llvm)?$")
)
if("${Rust_VERSION}" VERSION_GREATER_EQUAL "1.79")
set(_CARGO_ABI gnullvm)
else()
message(WARNING "Your selected C/C++ compilers suggest you want to use the -gnullvm"
" rust targets, however your Rust compiler version is ${Rust_VERSION}, which is"
" before the promotion of the gnullvm target to tier2."
" Please either use a more recent rust compiler or manually choose a target "
" triple by specifying `Rust_CARGO_TARGET` manually."
)
endif()
elseif(NOT "${CMAKE_CROSSCOMPILING}" AND "${Rust_DEFAULT_HOST_TARGET}" MATCHES "-msvc$")
# We first check if the gnu branch matches to ensure this fallback is only used
# We first check if the gnu branches match to ensure this fallback is only used
# if no compiler is enabled.
set(_CARGO_ABI msvc)
else()
Expand Down