File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -424,6 +424,18 @@ macro(construct_compiler_rt_default_triple)
424424 endif ()
425425 endif ()
426426
427+ # Try to locate the GPU loader utility for GPU unit tests.
428+ if (COMPILER_RT_GPU_BUILD AND NOT COMPILER_RT_EMULATOR)
429+ get_filename_component (_compiler_path "${CMAKE_C_COMPILER} " DIRECTORY )
430+ find_program (COMPILER_RT_EMULATOR
431+ NAMES llvm-gpu-loader NO_DEFAULT_PATH
432+ PATHS ${LLVM_BINARY_DIR} /bin ${_compiler_path} )
433+ if (COMPILER_RT_EMULATOR)
434+ message (STATUS "Found GPU loader for testing: ${COMPILER_RT_EMULATOR} " )
435+ endif ()
436+ unset (_compiler_path)
437+ endif ()
438+
427439 # Determine if test target triple is specified explicitly, and doesn't match the
428440 # default.
429441 if (NOT COMPILER_RT_DEFAULT_TARGET_TRIPLE STREQUAL LLVM_TARGET_TRIPLE)
Original file line number Diff line number Diff line change 11# This file sets up a CMakeCache for GPU builds of compiler-rt. This supports
22# amdgcn and nvptx builds targeting the builtins and profile libraries.
33
4- set (COMPILER_RT_INCLUDE_TESTS OFF CACHE BOOL "" )
4+ set (COMPILER_RT_INCLUDE_TESTS ON CACHE BOOL "" )
55set (COMPILER_RT_HAS_SAFESTACK OFF CACHE BOOL "" )
66set (COMPILER_RT_DEFAULT_TARGET_ONLY ON CACHE BOOL "" )
77
Original file line number Diff line number Diff line change @@ -98,7 +98,8 @@ if(COMPILER_RT_CAN_EXECUTE_TESTS)
9898 compiler_rt_test_runtime (${sanitizer} )
9999 endforeach ()
100100 endif ()
101- if (COMPILER_RT_BUILD_PROFILE AND COMPILER_RT_HAS_PROFILE)
101+ if (COMPILER_RT_BUILD_PROFILE AND COMPILER_RT_HAS_PROFILE
102+ AND NOT COMPILER_RT_GPU_BUILD)
102103 compiler_rt_test_runtime (profile )
103104 endif ()
104105 if (COMPILER_RT_BUILD_CTX_PROFILE)
Original file line number Diff line number Diff line change @@ -49,6 +49,19 @@ foreach(arch ${BUILTIN_TEST_ARCH})
4949 set (BUILTINS_TEST_TARGET_ARCH ${arch} )
5050 string (TOLOWER "-${arch} -${OS_NAME} " BUILTINS_TEST_CONFIG_SUFFIX)
5151 get_test_cc_for_arch (${arch} BUILTINS_TEST_TARGET_CC BUILTINS_TEST_TARGET_CFLAGS )
52+
53+ if (COMPILER_RT_GPU_BUILD)
54+ if ("${arch} " MATCHES "amdgcn" )
55+ list (APPEND BUILTINS_TEST_TARGET_CFLAGS
56+ -Wno-multi-gpu -flto -mcpu=native -nogpulib -startfiles -stdlib)
57+ elseif ("${arch} " MATCHES "nvptx" )
58+ list (APPEND BUILTINS_TEST_TARGET_CFLAGS
59+ -Wno-multi-gpu -flto -march=native -nogpulib -startfiles -stdlib)
60+ endif ()
61+ list (APPEND BUILTINS_TEST_TARGET_CFLAGS --target=${COMPILER_RT_DEFAULT_TARGET_TRIPLE} )
62+ string (REPLACE ";" " " BUILTINS_TEST_TARGET_CFLAGS "${BUILTINS_TEST_TARGET_CFLAGS} " )
63+ endif ()
64+
5265 if (${arch} STREQUAL "armhf" )
5366 list (APPEND BUILTINS_TEST_TARGET_CFLAGS -fomit-frame-pointer -DCOMPILER_RT_ARMHF_TARGET)
5467 string (REPLACE ";" " " BUILTINS_TEST_TARGET_CFLAGS "${BUILTINS_TEST_TARGET_CFLAGS} " )
Original file line number Diff line number Diff line change @@ -158,7 +158,7 @@ def get_libgcc_file_name():
158158
159159# FIXME: Right now we don't compile the C99 complex builtins when using
160160# clang-cl. Fix that.
161- if not is_msvc :
161+ if not is_msvc and config . target_arch not in ( "amdgcn" , "nvptx64" ) :
162162 config .available_features .add ("c99-complex" )
163163
164164builtins_is_msvc = get_required_attr (config , "builtins_is_msvc" )
Original file line number Diff line number Diff line change @@ -987,6 +987,8 @@ def is_windows_lto_supported():
987987
988988
989989def target_page_size ():
990+ if config .target_arch in ("amdgcn" , "nvptx64" ):
991+ return 4096
990992 try :
991993 proc = subprocess .Popen (
992994 f"{ emulator or '' } python3" ,
You can’t perform that action at this time.
0 commit comments