Skip to content

Commit

Permalink
Merge #29208: build: Bump clang minimum supported version to 14
Browse files Browse the repository at this point in the history
aaaace2 fuzz: Assume presence of __builtin_*_overflow, without checks (MarcoFalke)
fa223ba Revert "build: Fix undefined reference to __mulodi4" (MarcoFalke)
fa7c751 build: Bump clang minimum supported version to 14 (MarcoFalke)

Pull request description:

  Most supported operating systems ship with clang-14 (or later), so bump the minimum to that and allow new code to drop workarounds for previous clang bugs.

  For reference:
  * https://packages.debian.org/bookworm/clang (`clang-14`)
  * https://packages.ubuntu.com/jammy/clang (`clang-14`)
  * CentOS-like 8/9 Stream: All Clang versions from 15 to 17
  * FreeBSD 12/13: All Clang versions from 15 to 16
  * OpenSuse Tumbleweed ships with https://software.opensuse.org/package/clang (`clang17`); No idea about OpenSuse Leap

  On operating systems where the clang version is not shipped by default, the user would have to use GCC, or install clang in a different way. For example:

  * https://packages.debian.org/bullseye/g++ (g++-10)
  * https://packages.ubuntu.com/focal/g++-10
  * https://apt.llvm.org/, or nix, or guix, or compile clang from source, ...

ACKs for top commit:
  fanquake:
    ACK aaaace2

Tree-SHA512: 81d066b14cc568d27312f1cc814b09540b038a10a0a8e9d71fc9745b024fb6c32a959af673e6819b817ea7cef98da4abfa63dff16cffb7821b40083016b0291f
  • Loading branch information
fanquake committed Jan 12, 2024
2 parents 8c0d1c6 + aaaace2 commit 8c5e4f4
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 71 deletions.
42 changes: 0 additions & 42 deletions build-aux/m4/bitcoin_runtime_lib.m4

This file was deleted.

2 changes: 1 addition & 1 deletion ci/test/00_setup_env_i686_multiprocess.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ export PACKAGES="llvm clang g++-multilib"
export DEP_OPTS="DEBUG=1 MULTIPROCESS=1"
export GOAL="install"
export BITCOIN_CONFIG="--enable-debug CC='clang -m32' CXX='clang++ -m32' \
LDFLAGS='--rtlib=compiler-rt -lgcc_s' CPPFLAGS='-DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE'"
CPPFLAGS='-DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE'"
export BITCOIND=bitcoin-node # Used in functional tests
8 changes: 4 additions & 4 deletions ci/test/00_setup_env_native_nowallet_libbitcoinkernel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
export LC_ALL=C.UTF-8

export CONTAINER_NAME=ci_native_nowallet_libbitcoinkernel
export CI_IMAGE_NAME_TAG="docker.io/debian:bullseye"
# Use minimum supported python3.9 and clang-13, see doc/dependencies.md
export PACKAGES="python3-zmq clang-13 llvm-13 libc++abi-13-dev libc++-13-dev"
export DEP_OPTS="NO_WALLET=1 CC=clang-13 CXX='clang++-13 -stdlib=libc++'"
export CI_IMAGE_NAME_TAG="docker.io/ubuntu:22.04"
# Use minimum supported python3.9 (or best-effort 3.10) and clang-14, see doc/dependencies.md
export PACKAGES="python3-zmq clang-14 llvm-14 libc++abi-14-dev libc++-14-dev"
export DEP_OPTS="NO_WALLET=1 CC=clang-14 CXX='clang++-14 -stdlib=libc++'"
export GOAL="install"
export BITCOIN_CONFIG="--enable-reduce-exports --enable-experimental-util-chainstate --with-experimental-kernel-lib --enable-shared"
2 changes: 0 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1338,8 +1338,6 @@ if test "$enable_fuzz_binary" = "yes"; then
]],[[
*/ int not_main() {
]])])

CHECK_RUNTIME_LIB
fi

if test "$enable_wallet" != "no"; then
Expand Down
2 changes: 1 addition & 1 deletion doc/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ You can find installation instructions in the `build-*.md` file for your platfor
| --- | --- |
| [Autoconf](https://www.gnu.org/software/autoconf/) | [2.69](https://github.com/bitcoin/bitcoin/pull/17769) |
| [Automake](https://www.gnu.org/software/automake/) | [1.13](https://github.com/bitcoin/bitcoin/pull/18290) |
| [Clang](https://clang.llvm.org) | [13.0](https://github.com/bitcoin/bitcoin/pull/28210) |
| [Clang](https://clang.llvm.org) | [14.0](https://github.com/bitcoin/bitcoin/pull/29208) |
| [GCC](https://gcc.gnu.org) | [10.1](https://github.com/bitcoin/bitcoin/pull/28348) |
| [Python](https://www.python.org) (scripts, tests) | [3.9](https://github.com/bitcoin/bitcoin/pull/28211) |
| [systemtap](https://sourceware.org/systemtap/) ([tracing](tracing.md))| N/A |
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.test.include
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ if ENABLE_FUZZ_BINARY
test_fuzz_fuzz_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BOOST_CPPFLAGS)
test_fuzz_fuzz_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
test_fuzz_fuzz_LDADD = $(FUZZ_SUITE_LD_COMMON)
test_fuzz_fuzz_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS) $(RUNTIME_LDFLAGS)
test_fuzz_fuzz_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS)
test_fuzz_fuzz_SOURCES = \
$(FUZZ_WALLET_SRC) \
test/fuzz/addition_overflow.cpp \
Expand Down
10 changes: 0 additions & 10 deletions src/test/fuzz/addition_overflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@
#include <string>
#include <vector>

#if defined(__has_builtin)
#if __has_builtin(__builtin_add_overflow)
#define HAVE_BUILTIN_ADD_OVERFLOW
#endif
#elif defined(__GNUC__)
#define HAVE_BUILTIN_ADD_OVERFLOW
#endif

namespace {
template <typename T>
void TestAdditionOverflow(FuzzedDataProvider& fuzzed_data_provider)
Expand All @@ -32,14 +24,12 @@ void TestAdditionOverflow(FuzzedDataProvider& fuzzed_data_provider)
assert(is_addition_overflow_custom == AdditionOverflow(j, i));
assert(maybe_add == CheckedAdd(j, i));
assert(sat_add == SaturatingAdd(j, i));
#if defined(HAVE_BUILTIN_ADD_OVERFLOW)
T result_builtin;
const bool is_addition_overflow_builtin = __builtin_add_overflow(i, j, &result_builtin);
assert(is_addition_overflow_custom == is_addition_overflow_builtin);
if (!is_addition_overflow_custom) {
assert(i + j == result_builtin);
}
#endif
if (is_addition_overflow_custom) {
assert(sat_add == std::numeric_limits<T>::min() || sat_add == std::numeric_limits<T>::max());
} else {
Expand Down
10 changes: 0 additions & 10 deletions src/test/fuzz/multiplication_overflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#if defined(HAVE_CONFIG_H)
#include <config/bitcoin-config.h>
#endif

#include <test/fuzz/FuzzedDataProvider.h>
#include <test/fuzz/fuzz.h>
#include <test/fuzz/util.h>
Expand All @@ -21,18 +17,12 @@ void TestMultiplicationOverflow(FuzzedDataProvider& fuzzed_data_provider)
const T i = fuzzed_data_provider.ConsumeIntegral<T>();
const T j = fuzzed_data_provider.ConsumeIntegral<T>();
const bool is_multiplication_overflow_custom = MultiplicationOverflow(i, j);
#if defined(HAVE_BUILTIN_MUL_OVERFLOW)
T result_builtin;
const bool is_multiplication_overflow_builtin = __builtin_mul_overflow(i, j, &result_builtin);
assert(is_multiplication_overflow_custom == is_multiplication_overflow_builtin);
if (!is_multiplication_overflow_custom) {
assert(i * j == result_builtin);
}
#else
if (!is_multiplication_overflow_custom) {
(void)(i * j);
}
#endif
}
} // namespace

Expand Down

0 comments on commit 8c5e4f4

Please sign in to comment.