[libc-commits] [libc] [libc][cmake] move _get_hermetic_test_compile_options to LLVMLibCTestRules.cmake (PR #122549)
Nick Desaulniers via libc-commits
libc-commits at lists.llvm.org
Fri Jan 10 15:32:51 PST 2025
https://github.com/nickdesaulniers created https://github.com/llvm/llvm-project/pull/122549
It's only used in that file, which is more appropriate than
LLVMLibCCompileOptionRules.cmake since it's strictly related to tests.
>From 81bdc906492fa302c26eb200fe95cfe5bbb6e8ef Mon Sep 17 00:00:00 2001
From: Nick Desaulniers <ndesaulniers at google.com>
Date: Fri, 10 Jan 2025 15:31:09 -0800
Subject: [PATCH] [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.
---
.../modules/LLVMLibCCompileOptionRules.cmake | 23 -----------------
libc/cmake/modules/LLVMLibCTestRules.cmake | 25 +++++++++++++++++++
2 files changed, 25 insertions(+), 23 deletions(-)
diff --git a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
index 8dcee1ec422464..785ea049448520 100644
--- a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
+++ b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
@@ -272,26 +272,3 @@ function(_get_common_test_compile_options output_var c_test flags)
endif()
set(${output_var} ${compile_options} PARENT_SCOPE)
endfunction()
-
-function(_get_hermetic_test_compile_options output_var flags)
- _get_common_test_compile_options(compile_options "" "${flags}")
-
- list(APPEND compile_options "-fpie")
- list(APPEND compile_options "-ffreestanding")
- list(APPEND compile_options "-fno-exceptions")
- list(APPEND compile_options "-fno-rtti")
-
- # The GPU build requires overriding the default CMake triple and architecture.
- if(LIBC_TARGET_ARCHITECTURE_IS_AMDGPU)
- list(APPEND compile_options
- -Wno-multi-gpu -nogpulib -mcpu=${LIBC_GPU_TARGET_ARCHITECTURE} -flto
- -mcode-object-version=${LIBC_GPU_CODE_OBJECT_VERSION})
- elseif(LIBC_TARGET_ARCHITECTURE_IS_NVPTX)
- list(APPEND compile_options
- "SHELL:-mllvm -nvptx-emit-init-fini-kernel=false"
- -Wno-multi-gpu --cuda-path=${LIBC_CUDA_ROOT}
- -nogpulib -march=${LIBC_GPU_TARGET_ARCHITECTURE} -fno-use-cxa-atexit)
- endif()
-
- set(${output_var} ${compile_options} PARENT_SCOPE)
-endfunction()
diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake
index 84f3125d557eae..fa9c83440a376f 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -359,6 +359,31 @@ if(NOT MSVC AND NOT LIBC_CC_SUPPORTS_NOSTDLIBPP)
string(STRIP ${LIBGCC_S_LOCATION} LIBGCC_S_LOCATION)
endif()
+function(_get_hermetic_test_compile_options output_var flags)
+ _get_common_test_compile_options(compile_options "" "${flags}")
+
+ list(APPEND compile_options "-fpie")
+ list(APPEND compile_options "-ffreestanding")
+ list(APPEND compile_options "-fno-exceptions")
+ list(APPEND compile_options "-fno-rtti")
+
+ # The GPU build requires overriding the default CMake triple and architecture.
+ if(LIBC_TARGET_ARCHITECTURE_IS_AMDGPU)
+ list(APPEND compile_options
+ -Wno-multi-gpu -nogpulib -mcpu=${LIBC_GPU_TARGET_ARCHITECTURE} -flto
+ -mcode-object-version=${LIBC_GPU_CODE_OBJECT_VERSION})
+ elseif(LIBC_TARGET_ARCHITECTURE_IS_NVPTX)
+ list(APPEND compile_options
+ "SHELL:-mllvm -nvptx-emit-init-fini-kernel=false"
+ -Wno-multi-gpu --cuda-path=${LIBC_CUDA_ROOT}
+ -nogpulib -march=${LIBC_GPU_TARGET_ARCHITECTURE} -fno-use-cxa-atexit)
+ # elseif(explicit_target_triple AND NOT CMAKE_COMPILER_IS_GNUCXX)
+ # list(APPEND compile_options "--target=${explicit_target_triple}")
+ endif()
+
+ set(${output_var} ${compile_options} PARENT_SCOPE)
+endfunction()
+
# DEPRECATED: Use add_hermetic_test instead.
#
# Rule to add an integration test. An integration test is like a unit test
More information about the libc-commits
mailing list