From 9542d0a0c661be92db950514b5dc9c5ea6d953af Mon Sep 17 00:00:00 2001 From: Joseph Huber Date: Fri, 19 Sep 2025 18:20:44 -0500 Subject: [PATCH] [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. --- llvm/cmake/modules/HandleLLVMOptions.cmake | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake index ba82f72df4f1..7e10baea90e8 100644 --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake @@ -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"