diff --git a/libc/cmake/modules/LLVMLibCObjectRules.cmake b/libc/cmake/modules/LLVMLibCObjectRules.cmake --- a/libc/cmake/modules/LLVMLibCObjectRules.cmake +++ b/libc/cmake/modules/LLVMLibCObjectRules.cmake @@ -20,8 +20,8 @@ function(add_object_library target_name) cmake_parse_arguments( "ADD_OBJECT" - "" # No option arguments - "" # Single value arguments + "" # No optional arguments + "CXX_STANDARD" # Single value arguments "SRCS;HDRS;COMPILE_OPTIONS;DEPENDS" # Multivalue arguments ${ARGN} ) @@ -53,6 +53,14 @@ add_dependencies(${fq_target_name} ${fq_deps_list}) endif() + if(ADD_OBJECT_CXX_STANDARD) + set_target_properties( + ${fq_target_name} + PROPERTIES + CXX_STANDARD ${ADD_OBJECT_CXX_STANDARD} + ) + endif() + set_target_properties( ${fq_target_name} PROPERTIES @@ -80,7 +88,7 @@ cmake_parse_arguments( "ADD_ENTRYPOINT_OBJ" "ALIAS;REDIRECTED" # Optional argument - "NAME" # Single value arguments + "NAME;CXX_STANDARD" # Single value arguments "SRCS;HDRS;DEPENDS;COMPILE_OPTIONS" # Multi value arguments ${ARGN} ) @@ -184,6 +192,14 @@ target_include_directories(${fq_target_name} PRIVATE ${include_dirs}) add_dependencies(${fq_target_name} ${full_deps_list}) + if(ADD_ENTRYPOINT_OBJ_CXX_STANDARD) + set_target_properties( + ${fq_target_name} ${internal_target_name} + PROPERTIES + CXX_STANDARD ${ADD_ENTRYPOINT_OBJ_CXX_STANDARD} + ) + endif() + set_target_properties( ${fq_target_name} PROPERTIES diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake --- a/libc/cmake/modules/LLVMLibCTestRules.cmake +++ b/libc/cmake/modules/LLVMLibCTestRules.cmake @@ -73,7 +73,7 @@ cmake_parse_arguments( "LIBC_UNITTEST" "NO_RUN_POSTBUILD" # Optional arguments - "SUITE" # Single value arguments + "SUITE;CXX_STANDARD" # Single value arguments "SRCS;HDRS;DEPENDS;COMPILE_OPTIONS;LINK_OPTIONS" # Multi-value arguments "NO_LIBC_UNITTEST_TEST_MAIN" ${ARGN} @@ -139,6 +139,13 @@ PRIVATE ${LIBC_UNITTEST_COMPILE_OPTIONS} ) endif() + if(LIBC_UNITTEST_CXX_STANDARD) + set_target_properties( + ${fq_target_name} + PROPERTIES + CXX_STANDARD ${LIBC_UNITTEST_CXX_STANDARD} + ) + endif() target_link_libraries(${fq_target_name} PRIVATE ${link_object_files}) if(LIBC_UNITTEST_LINK_OPTIONS) diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt --- a/libc/src/math/generic/CMakeLists.txt +++ b/libc/src/math/generic/CMakeLists.txt @@ -44,8 +44,7 @@ libc.include.errno libc.include.math libc.src.errno.__errno_location - COMPILE_OPTIONS - -Wno-c++17-extensions + CXX_STANDARD 17 ) add_object_library( @@ -56,8 +55,7 @@ sincosf_data.cpp DEPENDS .math_utils - COMPILE_OPTIONS - -Wno-c++17-extensions + CXX_STANDARD 17 ) add_entrypoint_object( @@ -70,9 +68,9 @@ .sincosf_utils libc.include.math libc.src.errno.__errno_location + CXX_STANDARD 17 COMPILE_OPTIONS -O3 - -Wno-c++17-extensions ) add_entrypoint_object( @@ -86,9 +84,9 @@ libc.include.math libc.src.errno.__errno_location libc.src.__support.FPUtil.fputil + CXX_STANDARD 17 COMPILE_OPTIONS -O3 - -Wno-c++17-extensions ) add_entrypoint_object( @@ -101,9 +99,9 @@ .sincosf_utils libc.include.math libc.src.errno.__errno_location + CXX_STANDARD 17 COMPILE_OPTIONS -O3 - -Wno-c++17-extensions ) add_entrypoint_object( @@ -662,8 +660,7 @@ common_constants.h SRCS common_constants.cpp - COMPILE_OPTIONS - -Wno-c++17-extensions + CXX_STANDARD 17 ) add_entrypoint_object( @@ -675,9 +672,9 @@ DEPENDS .common_constants libc.src.__support.FPUtil.fputil + CXX_STANDARD 17 COMPILE_OPTIONS -O3 - -Wno-c++17-extensions ) add_entrypoint_object( @@ -689,9 +686,9 @@ DEPENDS .common_constants libc.src.__support.FPUtil.fputil - COMPILE_OPTIONS + CXX_STANDARD 17 + COMPILE_OPTIONS -O3 - -Wno-c++17-extensions ) add_entrypoint_object( @@ -703,6 +700,7 @@ DEPENDS .common_constants libc.src.__support.FPUtil.fputil + CXX_STANDARD 17 COMPILE_OPTIONS -O3 ) @@ -860,9 +858,9 @@ DEPENDS libc.src.__support.FPUtil.fputil libc.src.__support.FPUtil.sqrt + CXX_STANDARD 17 COMPILE_OPTIONS -O3 - -Wno-c++17-extensions ) add_entrypoint_object( @@ -874,9 +872,9 @@ DEPENDS libc.src.__support.FPUtil.fputil libc.src.__support.FPUtil.sqrt + CXX_STANDARD 17 COMPILE_OPTIONS -O3 - -Wno-c++17-extensions ) add_entrypoint_object( @@ -888,9 +886,9 @@ DEPENDS libc.src.__support.FPUtil.fputil libc.src.__support.FPUtil.sqrt + CXX_STANDARD 17 COMPILE_OPTIONS -O3 - -Wno-c++17-extensions ) add_entrypoint_object( diff --git a/libc/src/math/generic/logf.cpp b/libc/src/math/generic/logf.cpp --- a/libc/src/math/generic/logf.cpp +++ b/libc/src/math/generic/logf.cpp @@ -49,9 +49,6 @@ namespace __llvm_libc { -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wc++17-extensions" - // Lookup table for log(f) = log(1 + n*2^(-7)) where n = 0..127. static constexpr double LOG_F[128] = { 0x0.0000000000000p+0, 0x1.fe02a6b106788p-8, 0x1.fc0a8b0fc03e3p-7, @@ -178,6 +175,4 @@ return static_cast(r); } -#pragma clang diagnostic pop - } // namespace __llvm_libc diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt --- a/libc/test/src/math/CMakeLists.txt +++ b/libc/test/src/math/CMakeLists.txt @@ -1006,9 +1006,9 @@ DEPENDS libc.src.__support.FPUtil.fputil libc.src.__support.FPUtil.generic.sqrt + CXX_STANDARD 17 COMPILE_OPTIONS -O3 - -Wno-c++17-extensions ) add_fp_unittest( @@ -1021,9 +1021,9 @@ DEPENDS libc.src.__support.FPUtil.fputil libc.src.__support.FPUtil.generic.sqrt + CXX_STANDARD 17 COMPILE_OPTIONS -O3 - -Wno-c++17-extensions ) add_fp_unittest( @@ -1036,9 +1036,9 @@ DEPENDS libc.src.__support.FPUtil.fputil libc.src.__support.FPUtil.generic.sqrt + CXX_STANDARD 17 COMPILE_OPTIONS -O3 - -Wno-c++17-extensions ) add_fp_unittest( @@ -1097,8 +1097,7 @@ libc.include.math libc.src.math.hypotf libc.src.__support.FPUtil.fputil - COMPILE_OPTIONS - -Wno-c++17-extensions + CXX_STANDARD 17 ) add_fp_unittest( @@ -1112,8 +1111,7 @@ libc.include.math libc.src.math.hypot libc.src.__support.FPUtil.fputil - COMPILE_OPTIONS - -Wno-c++17-extensions + CXX_STANDARD 17 ) add_fp_unittest( diff --git a/libc/test/src/math/differential_testing/CMakeLists.txt b/libc/test/src/math/differential_testing/CMakeLists.txt --- a/libc/test/src/math/differential_testing/CMakeLists.txt +++ b/libc/test/src/math/differential_testing/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_parse_arguments( "DIFF" "" # No optional arguments - "SUITE" # Single value arguments + "SUITE;CXX_STANDARD" # Single value arguments "SRCS;HDRS;DEPENDS;COMPILE_OPTIONS" # Multi-value arguments ${ARGN} ) @@ -53,6 +53,14 @@ set_target_properties(${fq_target_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + + if(DIFF_CXX_STANDARD) + set_target_properties( + ${fq_target_name} + PROPERTIES + CXX_STANDARD ${DIFF_CXX_STANDARD} + ) + endif() add_dependencies( ${fq_target_name} @@ -415,9 +423,9 @@ DEPENDS .binary_op_single_output_diff libc.src.math.hypotf + CXX_STANDARD 17 COMPILE_OPTIONS -fno-builtin - -Wno-c++17-extensions ) add_diff_binary( @@ -427,7 +435,7 @@ DEPENDS .binary_op_single_output_diff libc.src.math.hypot + CXX_STANDARD 17 COMPILE_OPTIONS -fno-builtin - -Wno-c++17-extensions ) diff --git a/libc/utils/MPFRWrapper/CMakeLists.txt b/libc/utils/MPFRWrapper/CMakeLists.txt --- a/libc/utils/MPFRWrapper/CMakeLists.txt +++ b/libc/utils/MPFRWrapper/CMakeLists.txt @@ -3,6 +3,14 @@ MPFRUtils.cpp MPFRUtils.h ) + add_compile_options( + -O3 + ) + set_target_properties( + libcMPFRWrapper + PROPERTIES + CXX_STANDARD 17 + ) add_dependencies(libcMPFRWrapper libc.src.__support.CPP.standalone_cpp libc.src.__support.FPUtil.fputil LibcUnitTest) if(EXISTS ${LLVM_LIBC_MPFR_INSTALL_PATH}) target_include_directories(libcMPFRWrapper PUBLIC ${LLVM_LIBC_MPFR_INSTALL_PATH}/include)