-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[compiler-rt] Initial support for builtins on GPU targets #95304
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,6 +146,7 @@ macro(test_target_arch arch def) | |
endmacro() | ||
|
||
macro(detect_target_arch) | ||
check_symbol_exists(__AMDGPU__ "" __AMDGPU) | ||
check_symbol_exists(__arm__ "" __ARM) | ||
check_symbol_exists(__AVR__ "" __AVR) | ||
check_symbol_exists(__aarch64__ "" __AARCH64) | ||
|
@@ -154,6 +155,7 @@ macro(detect_target_arch) | |
check_symbol_exists(__loongarch__ "" __LOONGARCH) | ||
check_symbol_exists(__mips__ "" __MIPS) | ||
check_symbol_exists(__mips64__ "" __MIPS64) | ||
check_symbol_exists(__NVPTX__ "" __NVPTX) | ||
check_symbol_exists(__powerpc__ "" __PPC) | ||
check_symbol_exists(__powerpc64__ "" __PPC64) | ||
check_symbol_exists(__powerpc64le__ "" __PPC64LE) | ||
|
@@ -164,7 +166,9 @@ macro(detect_target_arch) | |
check_symbol_exists(__wasm32__ "" __WEBASSEMBLY32) | ||
check_symbol_exists(__wasm64__ "" __WEBASSEMBLY64) | ||
check_symbol_exists(__ve__ "" __VE) | ||
if(__ARM) | ||
if(__AMDGPU) | ||
add_default_target_arch(amdgcn) | ||
elseif(__ARM) | ||
add_default_target_arch(arm) | ||
elseif(__AVR) | ||
add_default_target_arch(avr) | ||
|
@@ -192,6 +196,8 @@ macro(detect_target_arch) | |
add_default_target_arch(mips64) | ||
elseif(__MIPS) | ||
add_default_target_arch(mips) | ||
elseif(__NVPTX) | ||
add_default_target_arch(nvptx64) | ||
elseif(__PPC64) # must be checked before __PPC | ||
add_default_target_arch(powerpc64) | ||
elseif(__PPC64LE) | ||
|
@@ -388,6 +394,21 @@ 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) | ||
|
||
# Pass the necessary flags to make flag detection work. | ||
if("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "amdgcn") | ||
set(COMPILER_RT_GPU_BUILD ON) | ||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nogpulib") | ||
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "nvptx") | ||
set(COMPILER_RT_GPU_BUILD ON) | ||
set(CMAKE_REQUIRED_FLAGS | ||
"${CMAKE_REQUIRED_FLAGS} -flto -c -Wno-unused-command-line-argument") | ||
endif() | ||
endif() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this be extracted somehow? I suspect that we need this in base-config-ix.cmake as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the difference? I thought this was the one place that checked the default argument. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think for a regular build (not cross compiling directly) it will be fine since it will just use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Specifying There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True, but I'm just going off of the expected case where the compiler has an implicit |
||
|
||
# Determine if test target triple is specified explicitly, and doesn't match the | ||
# default. | ||
if(NOT COMPILER_RT_DEFAULT_TARGET_TRIPLE STREQUAL LLVM_TARGET_TRIPLE) | ||
|
@@ -466,6 +487,10 @@ function(get_compiler_rt_target arch variable) | |
endif() | ||
endif() | ||
set(target "${arch}${triple_suffix}") | ||
elseif("${arch}" MATCHES "^amdgcn") | ||
set(target "amdgcn-amd-amdhsa") | ||
elseif("${arch}" MATCHES "^nvptx") | ||
set(target "nvptx64-nvidia-cuda") | ||
else() | ||
set(target "${arch}${triple_suffix}") | ||
endif() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# This file sets up a CMakeCache for GPU builds of compiler-rt. This supports | ||
# amdgcn and nvptx builds targeting the builtins library. | ||
|
||
set(COMPILER_RT_INCLUDE_TESTS OFF CACHE BOOL "") | ||
set(COMPILER_RT_HAS_SAFESTACK OFF CACHE BOOL "") | ||
|
||
set(COMPILER_RT_BUILD_BUILTINS ON CACHE BOOL "") | ||
set(COMPILER_RT_BAREMETAL_BUILD ON CACHE BOOL "") | ||
set(COMPILER_RT_BUILD_CRT OFF CACHE BOOL "") | ||
set(COMPILER_RT_BUILD_SANITIZERS OFF CACHE BOOL "") | ||
set(COMPILER_RT_BUILD_XRAY OFF CACHE BOOL "") | ||
set(COMPILER_RT_BUILD_LIBFUZZER OFF CACHE BOOL "") | ||
set(COMPILER_RT_BUILD_PROFILE OFF CACHE BOOL "") | ||
set(COMPILER_RT_BUILD_MEMPROF OFF CACHE BOOL "") | ||
set(COMPILER_RT_BUILD_XRAY_NO_PREINIT OFF CACHE BOOL "") | ||
set(COMPILER_RT_BUILD_ORC OFF CACHE BOOL "") | ||
set(COMPILER_RT_BUILD_GWP_ASAN OFF CACHE BOOL "") | ||
set(COMPILER_RT_BUILD_SCUDO_SANTDALONE_WITH_LLVM_LIBC OFF CACHE BOOL "") |
Uh oh!
There was an error while loading. Please reload this page.