[libc] Use ${libc_opt_high_flag} instead of -O3 (#123233)

This is preferable since `${libc_opt_high_flag}` will be set correctly
for the compiler used.
This commit is contained in:
Petr Hosek 2025-02-07 13:36:06 -08:00 committed by GitHub
parent 427b24a408
commit 6dbe542290
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 22 additions and 20 deletions

View File

@ -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})

View File

@ -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(

View File

@ -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.
)

View File

@ -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(

View File

@ -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

View File

@ -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(

View File

@ -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

View File

@ -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