Skip to content

Commit aa10b5f

Browse files
committed
Address comments.
1 parent b93fceb commit aa10b5f

File tree

4 files changed

+24
-17
lines changed

4 files changed

+24
-17
lines changed

libc/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ add_compile_definitions(LIBC_NAMESPACE=${LIBC_NAMESPACE})
112112

113113
# Flags to pass down to the compiler while building the libc functions.
114114
set(LIBC_COMPILE_OPTIONS_DEFAULT "" CACHE STRING "Architecture to tell clang to optimize for (e.g. -march=... or -mcpu=...)")
115+
set(LIBC_TEST_COMPILE_OPTIONS_DEFAULT "" CACHE STRING "Common compile options for all the tests.")
115116

116117
list(APPEND LIBC_COMPILE_OPTIONS_DEFAULT ${LIBC_COMMON_TUNE_OPTIONS})
117118

libc/cmake/modules/LLVMLibCCompileOptionRules.cmake

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,10 @@ endfunction()
188188
function(_get_common_test_compile_options output_var c_test flags)
189189
_get_compile_options_from_flags(compile_flags ${flags})
190190

191-
set(compile_options ${LIBC_COMPILE_OPTIONS_DEFAULT} ${compile_flags})
191+
set(compile_options
192+
${LIBC_COMPILE_OPTIONS_DEFAULT}
193+
${LIBC_TEST_COMPILE_OPTIONS_DEFAULT}
194+
${compile_flags})
192195

193196
if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
194197
list(APPEND compile_options "-fpie")
@@ -232,9 +235,12 @@ function(_get_common_test_compile_options output_var c_test flags)
232235
endfunction()
233236

234237
function(_get_hermetic_test_compile_options output_var flags)
235-
_get_compile_options_from_flags(compile_flags ${flags})
236-
set(compile_options ${LIBC_COMPILE_OPTIONS_DEFAULT} ${compile_flags}
237-
${flags} -fpie -ffreestanding -fno-exceptions -fno-rtti)
238+
_get_common_test_compile_options(compile_options "" "${flags}")
239+
240+
list(APPEND compile_options "-fpie")
241+
list(APPEND compile_options "-ffreestanding")
242+
list(APPEND compile_options "-fno-exceptions")
243+
list(APPEND compile_options "-fno-rtti")
238244

239245
# The GPU build requires overriding the default CMake triple and architecture.
240246
if(LIBC_TARGET_ARCHITECTURE_IS_AMDGPU)
@@ -248,9 +254,5 @@ function(_get_hermetic_test_compile_options output_var flags)
248254
-nogpulib -march=${LIBC_GPU_TARGET_ARCHITECTURE} -fno-use-cxa-atexit)
249255
endif()
250256

251-
if(LLVM_LIBC_FULL_BUILD)
252-
list(APPEND compile_options "-DLIBC_FULL_BUILD")
253-
endif()
254-
255257
set(${output_var} ${compile_options} PARENT_SCOPE)
256258
endfunction()

libc/cmake/modules/LLVMLibCTestRules.cmake

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,9 @@ function(add_integration_test test_name)
466466
target_include_directories(${fq_build_target_name} SYSTEM PRIVATE ${LIBC_INCLUDE_DIR})
467467
target_include_directories(${fq_build_target_name} PRIVATE ${LIBC_SOURCE_DIR})
468468

469-
_get_hermetic_test_compile_options(compile_options "${INTEGRATION_TEST_COMPILE_OPTIONS}")
470-
target_compile_options(${fq_build_target_name} PRIVATE ${compile_options})
469+
_get_hermetic_test_compile_options(compile_options "")
470+
target_compile_options(${fq_build_target_name} PRIVATE
471+
${compile_options} ${INTEGRATION_TEST_COMPILE_OPTIONS})
471472

472473
if(LIBC_TARGET_ARCHITECTURE_IS_AMDGPU)
473474
target_link_options(${fq_build_target_name} PRIVATE
@@ -639,11 +640,12 @@ function(add_libc_hermetic test_name)
639640
#OUTPUT_NAME ${fq_target_name}
640641
)
641642

642-
_get_hermetic_test_compile_options(compile_options "${HERMETIC_TEST_COMPILE_OPTIONS}")
643643
target_include_directories(${fq_build_target_name} SYSTEM PRIVATE ${LIBC_INCLUDE_DIR})
644644
target_include_directories(${fq_build_target_name} PRIVATE ${LIBC_SOURCE_DIR})
645-
_get_hermetic_test_compile_options(compile_options "${HERMETIC_TEST_COMPILE_OPTIONS}")
646-
target_compile_options(${fq_build_target_name} PRIVATE ${compile_options})
645+
_get_hermetic_test_compile_options(compile_options "")
646+
target_compile_options(${fq_build_target_name} PRIVATE
647+
${compile_options}
648+
${HERMETIC_TEST_COMPILE_OPTIONS})
647649

648650
set(link_libraries "")
649651
foreach(lib IN LISTS HERMETIC_TEST_LINK_LIBRARIES)

libc/test/UnitTest/CMakeLists.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ function(add_unittest_framework_library name)
2323
if(TARGET libc.src.time.clock)
2424
target_compile_definitions(${lib} PRIVATE TARGET_SUPPORTS_CLOCK)
2525
endif()
26-
_get_common_test_compile_options(compile_options "" "")
27-
target_compile_options(${lib} PRIVATE ${compile_options})
2826
endforeach()
29-
_get_hermetic_test_compile_options(compile_options -nostdinc++)
27+
28+
_get_common_test_compile_options(compile_options "" "")
29+
target_compile_options(${name}.unit PRIVATE ${compile_options})
30+
31+
_get_hermetic_test_compile_options(compile_options "")
3032
target_include_directories(${name}.hermetic PRIVATE ${LIBC_BUILD_DIR}/include)
31-
target_compile_options(${name}.hermetic PRIVATE ${compile_options})
33+
target_compile_options(${name}.hermetic PRIVATE ${compile_options} -nostdinc++)
3234

3335
if(TEST_LIB_DEPENDS)
3436
foreach(dep IN ITEMS ${TEST_LIB_DEPENDS})

0 commit comments

Comments
 (0)