[compiler-rt] [compiler-rt] Initial support for builtins on GPU targets (PR #95304)
Joseph Huber via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 12 14:41:06 PDT 2024
================
@@ -388,6 +394,30 @@ macro(construct_compiler_rt_default_triple)
set(COMPILER_RT_DEFAULT_TARGET_ARCH "i386")
endif()
+ # If we are directly targeting a GPU we need to check that the compiler is
+ # compatible and pass some default arguments.
+ if(COMPILER_RT_DEFAULT_TARGET_ONLY)
+ if("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "amdgcn|nvptx")
+ # Ensure the compiler is a valid clang when building the GPU target.
+ set(req_ver "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}")
+ if(LLVM_VERSION_MAJOR AND NOT (CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang" AND
+ ${CMAKE_CXX_COMPILER_VERSION} VERSION_EQUAL "${req_ver}"))
+ message(FATAL_ERROR "Cannot build compiler-rt for GPU. CMake compiler "
+ "'${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}' "
+ " is not 'Clang ${req_ver}'.")
+ endif()
+ set(COMPILER_RT_GPU_TARGET TRUE)
+ endif()
+
+ # Pass the necessary flags to make flag detection work.
+ if("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "amdgcn")
+ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nogpulib")
+ elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "nvptx")
+ # FIXME: This doesn't work with no CUDA installation.
+ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -march=sm_75")
+ endif()
+ endif()
----------------
jhuber6 wrote:
What's the difference? I thought this was the one place that checked the default argument.
https://github.com/llvm/llvm-project/pull/95304
More information about the llvm-commits
mailing list