Skip to content

Commit 81bdc90

Browse files
[libc][cmake] move _get_hermetic_test_compile_options to LLVMLibCTestRules.cmake
It's only used in that file, which is more appropriate than LLVMLibCCompileOptionRules.cmake since it's strictly related to tests.
1 parent 0afee85 commit 81bdc90

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed

libc/cmake/modules/LLVMLibCCompileOptionRules.cmake

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -272,26 +272,3 @@ function(_get_common_test_compile_options output_var c_test flags)
272272
endif()
273273
set(${output_var} ${compile_options} PARENT_SCOPE)
274274
endfunction()
275-
276-
function(_get_hermetic_test_compile_options output_var flags)
277-
_get_common_test_compile_options(compile_options "" "${flags}")
278-
279-
list(APPEND compile_options "-fpie")
280-
list(APPEND compile_options "-ffreestanding")
281-
list(APPEND compile_options "-fno-exceptions")
282-
list(APPEND compile_options "-fno-rtti")
283-
284-
# The GPU build requires overriding the default CMake triple and architecture.
285-
if(LIBC_TARGET_ARCHITECTURE_IS_AMDGPU)
286-
list(APPEND compile_options
287-
-Wno-multi-gpu -nogpulib -mcpu=${LIBC_GPU_TARGET_ARCHITECTURE} -flto
288-
-mcode-object-version=${LIBC_GPU_CODE_OBJECT_VERSION})
289-
elseif(LIBC_TARGET_ARCHITECTURE_IS_NVPTX)
290-
list(APPEND compile_options
291-
"SHELL:-mllvm -nvptx-emit-init-fini-kernel=false"
292-
-Wno-multi-gpu --cuda-path=${LIBC_CUDA_ROOT}
293-
-nogpulib -march=${LIBC_GPU_TARGET_ARCHITECTURE} -fno-use-cxa-atexit)
294-
endif()
295-
296-
set(${output_var} ${compile_options} PARENT_SCOPE)
297-
endfunction()

libc/cmake/modules/LLVMLibCTestRules.cmake

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,31 @@ if(NOT MSVC AND NOT LIBC_CC_SUPPORTS_NOSTDLIBPP)
359359
string(STRIP ${LIBGCC_S_LOCATION} LIBGCC_S_LOCATION)
360360
endif()
361361

362+
function(_get_hermetic_test_compile_options output_var flags)
363+
_get_common_test_compile_options(compile_options "" "${flags}")
364+
365+
list(APPEND compile_options "-fpie")
366+
list(APPEND compile_options "-ffreestanding")
367+
list(APPEND compile_options "-fno-exceptions")
368+
list(APPEND compile_options "-fno-rtti")
369+
370+
# The GPU build requires overriding the default CMake triple and architecture.
371+
if(LIBC_TARGET_ARCHITECTURE_IS_AMDGPU)
372+
list(APPEND compile_options
373+
-Wno-multi-gpu -nogpulib -mcpu=${LIBC_GPU_TARGET_ARCHITECTURE} -flto
374+
-mcode-object-version=${LIBC_GPU_CODE_OBJECT_VERSION})
375+
elseif(LIBC_TARGET_ARCHITECTURE_IS_NVPTX)
376+
list(APPEND compile_options
377+
"SHELL:-mllvm -nvptx-emit-init-fini-kernel=false"
378+
-Wno-multi-gpu --cuda-path=${LIBC_CUDA_ROOT}
379+
-nogpulib -march=${LIBC_GPU_TARGET_ARCHITECTURE} -fno-use-cxa-atexit)
380+
# elseif(explicit_target_triple AND NOT CMAKE_COMPILER_IS_GNUCXX)
381+
# list(APPEND compile_options "--target=${explicit_target_triple}")
382+
endif()
383+
384+
set(${output_var} ${compile_options} PARENT_SCOPE)
385+
endfunction()
386+
362387
# DEPRECATED: Use add_hermetic_test instead.
363388
#
364389
# Rule to add an integration test. An integration test is like a unit test

0 commit comments

Comments
 (0)