From 5edd857d11f932a6d09c8c96657786707cc8a3b3 Mon Sep 17 00:00:00 2001 From: Andrei Malashkin Date: Fri, 29 Nov 2024 18:00:43 +0100 Subject: [PATCH] precompile some headers --- crypto3/benchmarks/CMakeLists.txt | 3 ++ crypto3/libs/blueprint/test/CMakeLists.txt | 5 +++ crypto3/libs/containers/test/CMakeLists.txt | 35 +++++++++---------- crypto3/libs/hash/CMakeLists.txt | 12 +++++++ crypto3/libs/hash/test/CMakeLists.txt | 3 +- .../libs/marshalling/zk/test/CMakeLists.txt | 1 + crypto3/libs/random/test/CMakeLists.txt | 2 +- crypto3/libs/transpiler/test/CMakeLists.txt | 20 ++++++----- crypto3/libs/zk/test/CMakeLists.txt | 4 +-- .../parallel-containers/test/CMakeLists.txt | 4 +-- .../libs/parallel-math/test/CMakeLists.txt | 2 +- .../libs/parallel-zk/test/CMakeLists.txt | 1 + 12 files changed, 58 insertions(+), 34 deletions(-) diff --git a/crypto3/benchmarks/CMakeLists.txt b/crypto3/benchmarks/CMakeLists.txt index c1f19f6dde..1a3f5b847a 100644 --- a/crypto3/benchmarks/CMakeLists.txt +++ b/crypto3/benchmarks/CMakeLists.txt @@ -49,6 +49,9 @@ macro(define_benchmark benchmark) target_compile_options(${full_name} PRIVATE "-fconstexpr-ops-limit=4294967295") endif() + if(NOT ${full_name} STREQUAL "algebra_curves_benchmark") + target_precompile_headers(${full_name} REUSE_FROM algebra_curves_benchmark) + endif() endmacro() set(BENCHMARK_NAMES diff --git a/crypto3/libs/blueprint/test/CMakeLists.txt b/crypto3/libs/blueprint/test/CMakeLists.txt index d75ccf83b2..9a74fa7f22 100644 --- a/crypto3/libs/blueprint/test/CMakeLists.txt +++ b/crypto3/libs/blueprint/test/CMakeLists.txt @@ -54,6 +54,7 @@ macro(define_blueprint_test test) crypto3::algebra crypto3::zk crypto3::random + crypto3::hash ) set_target_properties(${full_test_name} PROPERTIES CXX_STANDARD 17) @@ -72,6 +73,10 @@ macro(define_blueprint_test test) elseif(target_type STREQUAL "STATIC_LIB") endif() + + if(NOT ${full_test_name} STREQUAL "blueprint_test_plonk_component_test") + target_precompile_headers(${full_test_name} REUSE_FROM blueprint_test_plonk_component_test) + endif() endmacro() set(COMMON_TEST_FILES diff --git a/crypto3/libs/containers/test/CMakeLists.txt b/crypto3/libs/containers/test/CMakeLists.txt index 7cfa9f335b..17dbe6e079 100644 --- a/crypto3/libs/containers/test/CMakeLists.txt +++ b/crypto3/libs/containers/test/CMakeLists.txt @@ -25,41 +25,40 @@ include(CMTest) -cm_test_link_libraries(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} - - ${CMAKE_WORKSPACE_NAME}::algebra - ${CMAKE_WORKSPACE_NAME}::hash - - Boost::unit_test_framework - Boost::random - ) - macro(define_storage_test test) get_filename_component(test_name ${test} NAME) - set(target_name ${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME}_${test_name}_test) + set(full_test_name ${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME}_${test_name}_test) - while(TARGET ${target_name}) + while(TARGET ${full_test_name}) get_filename_component(TEST_DIRECTORY ${test} DIRECTORY) get_filename_component(PARENT_DIR ${TEST_DIRECTORY} DIRECTORY) - set(target_name ${PARENT_DIR}_${target_name}) + set(full_test_name ${PARENT_DIR}_${full_test_name}) endwhile() - cm_test(NAME ${target_name} SOURCES ${test}.cpp) + cm_test(NAME ${full_test_name} SOURCES ${test}.cpp) - target_include_directories(${target_name} PRIVATE + target_include_directories(${full_test_name} PRIVATE "$" "$" ${Boost_INCLUDE_DIRS}) - set_target_properties(${target_name} PROPERTIES CXX_STANDARD 17) + target_link_libraries(${full_test_name} + ${CMAKE_WORKSPACE_NAME}::containers + ${CMAKE_WORKSPACE_NAME}::algebra + ${CMAKE_WORKSPACE_NAME}::hash + + Boost::unit_test_framework + Boost::random + ) + + set_target_properties(${full_test_name} PROPERTIES CXX_STANDARD 17) if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - target_compile_options(${target_name} PRIVATE "-fconstexpr-steps=2147483647" "-ftemplate-backtrace-limit=0") + target_compile_options(${full_test_name} PRIVATE "-fconstexpr-steps=2147483647" "-ftemplate-backtrace-limit=0") elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - target_compile_options(${target_name} PRIVATE "-fconstexpr-ops-limit=4294967295" "-ftemplate-backtrace-limit=0") + target_compile_options(${full_test_name} PRIVATE "-fconstexpr-ops-limit=4294967295" "-ftemplate-backtrace-limit=0") endif() - endmacro() set(TESTS_NAMES diff --git a/crypto3/libs/hash/CMakeLists.txt b/crypto3/libs/hash/CMakeLists.txt index d82f08095c..998f14851a 100644 --- a/crypto3/libs/hash/CMakeLists.txt +++ b/crypto3/libs/hash/CMakeLists.txt @@ -129,6 +129,18 @@ add_library(${CMAKE_WORKSPACE_NAME}::${CURRENT_PROJECT_NAME} ALIAS ${CMAKE_WORKS set_target_properties(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} PROPERTIES EXPORT_NAME ${CURRENT_PROJECT_NAME}) +target_precompile_headers(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} + INTERFACE + "$" + "$" + ) + +if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + target_compile_options(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} INTERFACE "${ARGV2}" "-fconstexpr-steps=2147483647" "-ftemplate-backtrace-limit=0") +elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_compile_options(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} INTERFACE "${ARGV2}" "-fconstexpr-ops-limit=4294967295" "-ftemplate-backtrace-limit=0") +endif() + target_link_libraries(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} INTERFACE ${${CURRENT_PROJECT_NAME}_INTERFACE_LIBRARIES} ${CMAKE_WORKSPACE_NAME}::multiprecision diff --git a/crypto3/libs/hash/test/CMakeLists.txt b/crypto3/libs/hash/test/CMakeLists.txt index 018eab2ca6..757d76c2b0 100644 --- a/crypto3/libs/hash/test/CMakeLists.txt +++ b/crypto3/libs/hash/test/CMakeLists.txt @@ -44,9 +44,11 @@ macro(define_hash_test name) target_compile_options(${test_name} PRIVATE "-fconstexpr-ops-limit=4294967295") endif() + target_precompile_headers(${test_name} REUSE_FROM _cm_internal_tests-crypto3-hash-test) endmacro() set(TESTS_NAMES + "tiger" "blake2b" "crc" "keccak" @@ -57,7 +59,6 @@ set(TESTS_NAMES "sha2" "sha3" "static_digest" - "tiger" "poseidon" "hash_to_curve" ) diff --git a/crypto3/libs/marshalling/zk/test/CMakeLists.txt b/crypto3/libs/marshalling/zk/test/CMakeLists.txt index 459e8264d4..3fad65602d 100644 --- a/crypto3/libs/marshalling/zk/test/CMakeLists.txt +++ b/crypto3/libs/marshalling/zk/test/CMakeLists.txt @@ -46,6 +46,7 @@ macro(define_marshalling_test test) target_compile_options(${full_test_name} PRIVATE "-fconstexpr-ops-limit=4294967295") endif() + target_precompile_headers(${full_test_name} REUSE_FROM _cm_internal_tests-crypto3-hash-test) endmacro() set(TESTS_NAMES diff --git a/crypto3/libs/random/test/CMakeLists.txt b/crypto3/libs/random/test/CMakeLists.txt index 0d3fdd0a9e..81fbb6fde6 100644 --- a/crypto3/libs/random/test/CMakeLists.txt +++ b/crypto3/libs/random/test/CMakeLists.txt @@ -32,7 +32,7 @@ macro(define_random_test test) elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") target_compile_options(${full_test_name} PRIVATE "-fconstexpr-ops-limit=4294967295") endif() - + target_precompile_headers(${full_test_name} REUSE_FROM _cm_internal_tests-crypto3-hash-test) endmacro() # TODO(uncomment the failing tests once they pass) diff --git a/crypto3/libs/transpiler/test/CMakeLists.txt b/crypto3/libs/transpiler/test/CMakeLists.txt index 3bcab249de..60a7cd201c 100644 --- a/crypto3/libs/transpiler/test/CMakeLists.txt +++ b/crypto3/libs/transpiler/test/CMakeLists.txt @@ -21,32 +21,34 @@ cm_test_link_libraries(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} add_custom_target(compile_and_run_transpiler_tests) macro(define_transpiler_test name) - cm_test(NAME transpiler_${name}_test SOURCES ${name}.cpp) + set(full_test_name transpiler_${name}_test) + cm_test(NAME ${full_test_name} SOURCES ${name}.cpp) if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - target_compile_options(transpiler_${name}_test PRIVATE "-fconstexpr-steps=2147483647") + target_compile_options(${full_test_name} PRIVATE "-fconstexpr-steps=2147483647") endif() - target_include_directories(transpiler_${name}_test PRIVATE + target_include_directories(${full_test_name} PRIVATE "$" "$" ${Boost_INCLUDE_DIRS}) - set_target_properties(transpiler_${name}_test PROPERTIES CXX_STANDARD 17) + set_target_properties(${full_test_name} PROPERTIES CXX_STANDARD 17) get_target_property(target_type Boost::unit_test_framework TYPE) if(target_type STREQUAL "SHARED_LIB") - target_compile_definitions(transpiler_${name}_test PRIVATE BOOST_TEST_DYN_LINK) + target_compile_definitions(${full_test_name} PRIVATE BOOST_TEST_DYN_LINK) elseif(target_type STREQUAL "STATIC_LIB") endif() - add_custom_target(transpiler_${name}_test_run - COMMAND $ - DEPENDS transpiler_${name}_test $ + add_custom_target(${full_test_name}_run + COMMAND $ + DEPENDS ${full_test_name} $ ) - add_dependencies(compile_and_run_transpiler_tests transpiler_${name}_test_run) + add_dependencies(compile_and_run_transpiler_tests ${full_test_name}_run) + target_precompile_headers(${full_test_name} REUSE_FROM _cm_internal_tests-crypto3-hash-test) endmacro() set(TESTS_NAMES diff --git a/crypto3/libs/zk/test/CMakeLists.txt b/crypto3/libs/zk/test/CMakeLists.txt index dc8641ecfa..912edc2f82 100644 --- a/crypto3/libs/zk/test/CMakeLists.txt +++ b/crypto3/libs/zk/test/CMakeLists.txt @@ -43,12 +43,12 @@ macro(define_zk_test test) elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") target_compile_options(${full_test_name} PRIVATE "-fconstexpr-ops-limit=4294967295") endif() - + target_precompile_headers(${full_test_name} REUSE_FROM _cm_internal_tests-crypto3-hash-test) endmacro() set(TESTS_NAMES - "commitment/lpc" "commitment/fri" + "commitment/lpc" "commitment/kzg" "commitment/fold_polynomial" "commitment/pedersen" diff --git a/parallel-crypto3/libs/parallel-containers/test/CMakeLists.txt b/parallel-crypto3/libs/parallel-containers/test/CMakeLists.txt index 6451bb7284..34549c3abf 100644 --- a/parallel-crypto3/libs/parallel-containers/test/CMakeLists.txt +++ b/parallel-crypto3/libs/parallel-containers/test/CMakeLists.txt @@ -69,12 +69,12 @@ macro(define_storage_test test) endif() - if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") target_compile_options(${target_name} PRIVATE "-fconstexpr-steps=2147483647" "-ftemplate-backtrace-limit=0") elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") target_compile_options(${target_name} PRIVATE "-fconstexpr-ops-limit=4294967295" "-ftemplate-backtrace-limit=0") endif() - + target_precompile_headers(${target_name} REUSE_FROM _cm_internal_tests-actor-containers-test) endmacro() set(TESTS_NAMES diff --git a/parallel-crypto3/libs/parallel-math/test/CMakeLists.txt b/parallel-crypto3/libs/parallel-math/test/CMakeLists.txt index 525e1f6b90..d60164d52a 100644 --- a/parallel-crypto3/libs/parallel-math/test/CMakeLists.txt +++ b/parallel-crypto3/libs/parallel-math/test/CMakeLists.txt @@ -35,7 +35,7 @@ macro(define_math_test name) ${Boost_INCLUDE_DIRS}) set_target_properties(${test_name} PROPERTIES CXX_STANDARD 17) - +# target_precompile_headers(${full_test_name} REUSE_FROM _cm_internal_tests-actor-math-test) endmacro() set(TESTS_NAMES diff --git a/parallel-crypto3/libs/parallel-zk/test/CMakeLists.txt b/parallel-crypto3/libs/parallel-zk/test/CMakeLists.txt index 158be5e776..e4e640bf72 100644 --- a/parallel-crypto3/libs/parallel-zk/test/CMakeLists.txt +++ b/parallel-crypto3/libs/parallel-zk/test/CMakeLists.txt @@ -45,6 +45,7 @@ macro(define_zk_test test) target_compile_options(${full_test_name} PRIVATE "-fconstexpr-ops-limit=4294967295") endif() + target_precompile_headers(${full_test_name} REUSE_FROM _cm_internal_tests-actor-zk-test) endmacro() set(TESTS_NAMES