diff --git a/CMakeLists.txt b/CMakeLists.txt index bd7994c01..b9bfbc3c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -180,6 +180,18 @@ find_package(Threads) # - 32-bit mode # - 16-bit mode +# For reproducible build, gate out from the build anything that might +# introduce semantically frivolous jitter, maximizing chance of +# identical object files. +set(WOLFSSL_REPRODUCIBLE_BUILD_HELP_STRING "Enable maximally reproducible build (default: disabled)") +add_option("WOLFSSL_REPRODUCIBLE_BUILD" ${WOLFSSL_REPRODUCIBLE_BUILD_HELP_STRING} "no" "yes;no") + +if(WOLFSSL_REPRODUCIBLE_BUILD) + set(CMAKE_C_ARCHIVE_CREATE " Dqc ") + set(CMAKE_C_ARCHIVE_APPEND " Dq ") + set(CMAKE_C_ARCHIVE_FINISH " -D ") +endif() + # Support for disabling all ASM set(WOLFSSL_ASM_HELP_STRING "Enables option for assembly (default: enabled)") add_option("WOLFSSL_ASM" ${WOLFSSL_ASM_HELP_STRING} "yes" "yes;no")