diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake index 5709a11b1a20..ffbdb40cd509 100644 --- a/libc/cmake/modules/LLVMLibCTestRules.cmake +++ b/libc/cmake/modules/LLVMLibCTestRules.cmake @@ -223,6 +223,8 @@ function(create_libc_unittest fq_target_name) _get_common_test_compile_options(compile_options "${LIBC_UNITTEST_C_TEST}" "${LIBC_UNITTEST_FLAGS}") + # TODO: Ideally we would have a separate function for link options. + set(link_options ${compile_options}) list(APPEND compile_options ${LIBC_UNITTEST_COMPILE_OPTIONS}) if(SHOW_INTERMEDIATE_OBJECTS) @@ -277,7 +279,7 @@ function(create_libc_unittest fq_target_name) target_include_directories(${fq_build_target_name} SYSTEM PRIVATE ${LIBC_INCLUDE_DIR}) target_include_directories(${fq_build_target_name} PRIVATE ${LIBC_SOURCE_DIR}) target_compile_options(${fq_build_target_name} PRIVATE ${compile_options}) - target_link_options(${fq_build_target_name} PRIVATE ${compile_options}) + target_link_options(${fq_build_target_name} PRIVATE ${link_options}) if(NOT LIBC_UNITTEST_CXX_STANDARD) set(LIBC_UNITTEST_CXX_STANDARD ${CMAKE_CXX_STANDARD}) diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt index 0e57051807b3..14e63d6cc139 100644 --- a/libc/src/math/generic/CMakeLists.txt +++ b/libc/src/math/generic/CMakeLists.txt @@ -534,7 +534,7 @@ add_entrypoint_object( libc.src.__support.macros.optimization libc.src.__support.macros.properties.types COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} ) add_entrypoint_object( diff --git a/libc/test/src/__support/CMakeLists.txt b/libc/test/src/__support/CMakeLists.txt index aeb8edf305d0..8d175e857fcd 100644 --- a/libc/test/src/__support/CMakeLists.txt +++ b/libc/test/src/__support/CMakeLists.txt @@ -234,7 +234,7 @@ add_libc_test( libc.src.stdlib.srand libc.src.string.memset COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} UNIT_TEST_ONLY # Aligned Allocation is not supported in hermetic builds. ) diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt index bbcdf2363c1e..f000ff6f3cf4 100644 --- a/libc/test/src/math/CMakeLists.txt +++ b/libc/test/src/math/CMakeLists.txt @@ -1597,7 +1597,7 @@ add_fp_unittest( libc.src.math.sqrtf libc.src.__support.FPUtil.generic.sqrt COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} ) add_fp_unittest( @@ -1613,7 +1613,7 @@ add_fp_unittest( libc.src.math.sqrt libc.src.__support.FPUtil.generic.sqrt COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} ) add_fp_unittest( @@ -1629,7 +1629,7 @@ add_fp_unittest( libc.src.math.sqrtl libc.src.__support.FPUtil.generic.sqrt COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} ) add_fp_unittest( diff --git a/libc/test/src/math/exhaustive/CMakeLists.txt b/libc/test/src/math/exhaustive/CMakeLists.txt index 423c3b7a8bfd..b1927dbc19a3 100644 --- a/libc/test/src/math/exhaustive/CMakeLists.txt +++ b/libc/test/src/math/exhaustive/CMakeLists.txt @@ -305,7 +305,7 @@ add_fp_unittest( SRCS hypotf_test.cpp COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} DEPENDS .exhaustive_test libc.src.math.hypotf diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt index e0cb531b4042..f3ecba3737e3 100644 --- a/libc/test/src/math/smoke/CMakeLists.txt +++ b/libc/test/src/math/smoke/CMakeLists.txt @@ -2993,7 +2993,7 @@ add_fp_unittest( DEPENDS libc.src.__support.FPUtil.generic.sqrt COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} ) add_fp_unittest( @@ -3007,7 +3007,7 @@ add_fp_unittest( DEPENDS libc.src.__support.FPUtil.generic.sqrt COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} ) add_fp_unittest( @@ -3021,7 +3021,7 @@ add_fp_unittest( DEPENDS libc.src.__support.FPUtil.generic.sqrt COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} ) add_fp_unittest( @@ -3038,7 +3038,7 @@ add_fp_unittest( libc.src.math.sqrtf128 libc.src.__support.FPUtil.generic.sqrt COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} ) add_fp_unittest( diff --git a/libc/test/src/stdfix/CMakeLists.txt b/libc/test/src/stdfix/CMakeLists.txt index 90d20438edb4..e4d4fc5b5255 100644 --- a/libc/test/src/stdfix/CMakeLists.txt +++ b/libc/test/src/stdfix/CMakeLists.txt @@ -14,7 +14,7 @@ foreach(suffix IN ITEMS hr r lr hk k lk) SRCS abs${suffix}_test.cpp COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} DEPENDS libc.src.stdfix.abs${suffix} libc.src.__support.fixed_point.fx_bits @@ -31,7 +31,7 @@ foreach(suffix IN ITEMS uhr ur ulr uhk uk) SRCS sqrt${suffix}_test.cpp COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} DEPENDS libc.src.stdfix.sqrt${suffix} libc.src.__support.CPP.bit @@ -52,7 +52,7 @@ foreach(suffix IN ITEMS hr r lr hk k lk uhr ur ulr uhk uk ulk) SRCS round${suffix}_test.cpp COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} DEPENDS libc.src.stdfix.round${suffix} libc.src.__support.fixed_point.fx_bits @@ -67,7 +67,7 @@ foreach(suffix IN ITEMS hr r lr hk k lk uhr ur ulr uhk uk ulk) SRCS ${suffix}bits_test.cpp COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} DEPENDS libc.src.stdfix.${suffix}bits libc.src.__support.CPP.bit @@ -84,7 +84,7 @@ add_libc_test( SRCS uhksqrtus_test.cpp COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} DEPENDS libc.src.stdfix.uhksqrtus libc.src.__support.CPP.bit @@ -103,7 +103,7 @@ add_libc_test( SRCS uksqrtui_test.cpp COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} DEPENDS libc.src.stdfix.uksqrtui libc.src.__support.CPP.bit @@ -122,7 +122,7 @@ add_libc_test( SRCS exphk_test.cpp COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} DEPENDS libc.src.stdfix.exphk libc.src.math.exp @@ -140,7 +140,7 @@ add_libc_test( SRCS expk_test.cpp COMPILE_OPTIONS - -O3 + ${libc_opt_high_flag} DEPENDS libc.src.stdfix.expk libc.src.math.exp diff --git a/libc/utils/MPFRWrapper/CMakeLists.txt b/libc/utils/MPFRWrapper/CMakeLists.txt index f7df9146c8d4..9ff7fa109ff9 100644 --- a/libc/utils/MPFRWrapper/CMakeLists.txt +++ b/libc/utils/MPFRWrapper/CMakeLists.txt @@ -34,7 +34,7 @@ if(LIBC_TESTS_CAN_USE_MPFR) _get_common_test_compile_options(compile_options "" "") # mpfr/gmp headers do not work with -ffreestanding flag. list(REMOVE_ITEM compile_options "-ffreestanding") - target_compile_options(libcMPFRWrapper PRIVATE -O3 ${compile_options}) + target_compile_options(libcMPFRWrapper PRIVATE ${libc_opt_high_flag} ${compile_options}) add_dependencies( libcMPFRWrapper libcMPCommon