From 1f4c0b50ee0e206011da261d40dc6f9abd52dd9b Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sat, 8 Feb 2025 19:53:03 +0000 Subject: [PATCH 01/13] merge bitcoin#24460: update ax_cxx_compile_stdcxx to serial 14 --- build-aux/m4/ax_cxx_compile_stdcxx.m4 | 71 ++++++++++++++++++++------- 1 file changed, 52 insertions(+), 19 deletions(-) diff --git a/build-aux/m4/ax_cxx_compile_stdcxx.m4 b/build-aux/m4/ax_cxx_compile_stdcxx.m4 index e0fb05a0e43d..51a35054d08c 100644 --- a/build-aux/m4/ax_cxx_compile_stdcxx.m4 +++ b/build-aux/m4/ax_cxx_compile_stdcxx.m4 @@ -10,14 +10,13 @@ # # Check for baseline language coverage in the compiler for the specified # version of the C++ standard. If necessary, add switches to CXX and -# CXXCPP to enable support. VERSION may be '11' (for the C++11 standard), -# '14' (for the C++14 standard), '17' (for the C++17 standard) or -# '20' (for the C++20 standard) +# CXXCPP to enable support. VERSION may be '11', '14', '17', or '20' for +# the respective C++ standard version. # # The second argument, if specified, indicates whether you insist on an # extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. # -std=c++11). If neither is specified, you get whatever works, with -# preference for an extended mode. +# preference for no added switch, and then for an extended mode. # # The third argument, if specified 'mandatory' or if left unspecified, # indicates that baseline support for the specified C++ standard is @@ -36,25 +35,24 @@ # Copyright (c) 2015 Moritz Klammler # Copyright (c) 2016, 2018 Krzesimir Nowak # Copyright (c) 2019 Enji Cooper +# Copyright (c) 2020 Jason Merrill +# Copyright (c) 2021 Jörn Heusipp # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 11 +#serial 14 dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro dnl (serial version number 13). -dnl Modifications: -dnl Add support for C++20, with no new tests - AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"], [$1], [14], [ax_cxx_compile_alternatives="14 1y"], [$1], [17], [ax_cxx_compile_alternatives="17 1z"], - [$1], [20], [ax_cxx_compile_alternatives="20 2a"], + [$1], [20], [ax_cxx_compile_alternatives="20"], [m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl m4_if([$2], [], [], [$2], [ext], [], @@ -67,6 +65,16 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl AC_LANG_PUSH([C++])dnl ac_success=no + m4_if([$2], [], [dnl + AC_CACHE_CHECK(whether $CXX supports C++$1 features by default, + ax_cv_cxx_compile_cxx$1, + [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], + [ax_cv_cxx_compile_cxx$1=yes], + [ax_cv_cxx_compile_cxx$1=no])]) + if test x$ax_cv_cxx_compile_cxx$1 = xyes; then + ac_success=yes + fi]) + m4_if([$2], [noext], [], [dnl if test x$ac_success = xno; then for alternative in ${ax_cxx_compile_alternatives}; do @@ -145,7 +153,6 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11], _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 ) - dnl Test body for checking C++14 support m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14], @@ -153,25 +160,21 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14], _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 ) +dnl Test body for checking C++17 support + m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17], _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 _AX_CXX_COMPILE_STDCXX_testbody_new_in_17 ) +dnl Test body for checking C++20 support -dnl Test body for checking C++20 support: R modification m4_define([_AX_CXX_COMPILE_STDCXX_testbody_20], -#ifndef __cplusplus -#error "This is not a C++ compiler" -dnl value from 2020-01-14 draft, clang 11 has 202002L -#elif __cplusplus < 201703L -#error "This is not a C++20 compiler" -#else _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 _AX_CXX_COMPILE_STDCXX_testbody_new_in_17 -#endif + _AX_CXX_COMPILE_STDCXX_testbody_new_in_20 ) @@ -272,7 +275,7 @@ namespace cxx11 } int - test(const int c, volatile int v) // 'volatile is deprecated in C++20' + test(const int c, volatile int v) { static_assert(is_same::value == true, ""); static_assert(is_same::value == false, ""); @@ -970,3 +973,33 @@ namespace cxx17 #endif // __cplusplus < 201703L ]]) + + +dnl Tests for new features in C++20 + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_20], [[ + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 202002L + +#error "This is not a C++20 compiler" + +#else + +#include + +namespace cxx20 +{ + +// As C++20 supports feature test macros in the standard, there is no +// immediate need to actually test for feature availability on the +// Autoconf side. + +} // namespace cxx20 + +#endif // __cplusplus < 202002L + +]]) From 84d6a7c516e4b2108d6d5c5c03de0e000245a716 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sat, 8 Feb 2025 19:19:13 +0000 Subject: [PATCH 02/13] merge bitcoin#27672: Print error message when FUZZ is missing --- ci/test/04_install.sh | 6 +++++- src/fs.h | 2 +- src/test/fuzz/fuzz.cpp | 27 +++++++++++++++++++++------ 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/ci/test/04_install.sh b/ci/test/04_install.sh index d6f74f0f872a..393e7a7d2891 100755 --- a/ci/test/04_install.sh +++ b/ci/test/04_install.sh @@ -85,7 +85,11 @@ if [ "$RUN_FUZZ_TESTS" = "true" ] || [ "$RUN_UNIT_TESTS" = "true" ] || [ "$RUN_U if [ ! -d "${DIR_QA_ASSETS}" ]; then DOCKER_EXEC git clone --depth=1 https://github.com/bitcoin-core/qa-assets "${DIR_QA_ASSETS}" fi - + ( + DOCKER_EXEC cd "${DIR_QA_ASSETS}" + DOCKER_EXEC echo "Using qa-assets repo from commit ..." + DOCKER_EXEC git log -1 + ) export DIR_FUZZ_IN=${DIR_QA_ASSETS}/fuzz_seed_corpus/ fi diff --git a/src/fs.h b/src/fs.h index c37e4a6a5225..d50a65c8a08d 100644 --- a/src/fs.h +++ b/src/fs.h @@ -8,7 +8,7 @@ #include #include -#include +#include // IWYU pragma: export #include #include #include diff --git a/src/test/fuzz/fuzz.cpp b/src/test/fuzz/fuzz.cpp index ee91b15ed006..a8bdc3d6d1ba 100644 --- a/src/test/fuzz/fuzz.cpp +++ b/src/test/fuzz/fuzz.cpp @@ -14,12 +14,17 @@ #include #include +#include +#include +#include #include #include #include +#include #include #include #include +#include #include #if defined(PROVIDE_FUZZ_MAIN_FUNCTION) && defined(__AFL_FUZZ_INIT) @@ -79,13 +84,13 @@ void initialize() return WrappedGetAddrInfo(name, false); }; - bool should_abort{false}; + bool should_exit{false}; if (std::getenv("PRINT_ALL_FUZZ_TARGETS_AND_ABORT")) { for (const auto& t : FuzzTargets()) { if (std::get<2>(t.second)) continue; std::cout << t.first << std::endl; } - should_abort = true; + should_exit = true; } if (const char* out_path = std::getenv("WRITE_ALL_FUZZ_TARGETS_AND_ABORT")) { std::cout << "Writing all fuzz target names to '" << out_path << "'." << std::endl; @@ -94,13 +99,23 @@ void initialize() if (std::get<2>(t.second)) continue; out_stream << t.first << std::endl; } - should_abort = true; + should_exit= true; + } + if (should_exit){ + std::exit(EXIT_SUCCESS); + } + if (const auto* env_fuzz{std::getenv("FUZZ")}) { + // To allow for easier fuzz executable binary modification, + static std::string g_copy{env_fuzz}; // create copy to avoid compiler optimizations, and + g_fuzz_target = g_copy.c_str(); // strip string after the first null-char. + } else { + std::cerr << "Must select fuzz target with the FUZZ env var." << std::endl; + std::cerr << "Hint: Set the PRINT_ALL_FUZZ_TARGETS_AND_ABORT=1 env var to see all compiled targets." << std::endl; + std::exit(EXIT_FAILURE); } - Assert(!should_abort); - g_fuzz_target = Assert(std::getenv("FUZZ")); const auto it = FuzzTargets().find(g_fuzz_target); if (it == FuzzTargets().end()) { - std::cerr << "No fuzzer for " << g_fuzz_target << "." << std::endl; + std::cerr << "No fuzz target compiled for " << g_fuzz_target << "." << std::endl; std::exit(EXIT_FAILURE); } Assert(!g_test_one_input); From 28e93f533f9e4e73dde714a37b35b7610a7d8363 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Fri, 26 May 2023 10:45:31 +0200 Subject: [PATCH 03/13] merge bitcoin#27766: Change LIMIT_TO_MESSAGE_TYPE from a compile-time to a run-time setting --- src/test/fuzz/process_message.cpp | 114 ++++-------------------------- src/test/util/setup_common.h | 2 +- 2 files changed, 14 insertions(+), 102 deletions(-) diff --git a/src/test/fuzz/process_message.cpp b/src/test/fuzz/process_message.cpp index 132fb71f4f35..0e79a8efb7f4 100644 --- a/src/test/fuzz/process_message.cpp +++ b/src/test/fuzz/process_message.cpp @@ -2,15 +2,16 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include -#include #include #include #include +#include #include -#include #include