[libc] Fix libc build on NVPTX using wrong linker flag

Summary:
Ugly hacks abound, we can't actually test linker flags correctly
generically because not everyone has `nvlink` as a binary on their
machine which would then result in every single flag being unsupported.
This is the only 'linker flag' check we have, so just hard code it off.
This commit is contained in:
Joseph Huber 2025-09-19 18:20:44 -05:00
parent 4a9fdda988
commit 9542d0a0c6

View File

@ -144,6 +144,14 @@ if( LLVM_ENABLE_ASSERTIONS )
endif()
endif()
# If we are targeting a GPU architecture in a runtimes build we want to ignore
# all the standard flag handling.
if("${LLVM_RUNTIMES_TARGET}" MATCHES "^amdgcn" OR
"${LLVM_RUNTIMES_TARGET}" MATCHES "^nvptx64")
return()
endif()
if(LLVM_ENABLE_EXPENSIVE_CHECKS)
# When LLVM_ENABLE_EXPENSIVE_CHECKS is ON, LLVM will intercept errors
# using assert(). An explicit check is performed here.
@ -1141,7 +1149,7 @@ if (UNIX AND
endif()
# lld doesn't print colored diagnostics when invoked from Ninja
if (UNIX AND CMAKE_GENERATOR MATCHES "Ninja")
if (UNIX AND CMAKE_GENERATOR MATCHES "Ninja" AND NOT "${LLVM_RUNTIMES_TARGET}" MATCHES "^nvptx64")
include(CheckLinkerFlag)
check_linker_flag(CXX "-Wl,--color-diagnostics" LINKER_SUPPORTS_COLOR_DIAGNOSTICS)
append_if(LINKER_SUPPORTS_COLOR_DIAGNOSTICS "-Wl,--color-diagnostics"