Skip to content

Commit 87c918a

Browse files
Merge #6138: backport: merge bitcoin#22840, bitcoin#22937, bitcoin#23446, bitcoin#23522, bitcoin#24026, bitcoin#24104, bitcoin#24167, bitcoin#20744, partial bitcoin#23469, bitcoin#24169 (replace boost::filesystem with std::filesystem)
0f23920 partial bitcoin#24169: Add --enable-c++20 option (Kittywhiskers Van Gogh) a3b7926 merge bitcoin#20744: Use std::filesystem. Remove Boost Filesystem & System (Kittywhiskers Van Gogh) be7ac49 merge bitcoin#24167: consistently use fsbridge:: for ifstream / ofstream (Kittywhiskers Van Gogh) 7ffea43 merge bitcoin#24104: Make compatible with boost 1.78 (Kittywhiskers Van Gogh) 7c270e6 merge bitcoin#24026: Block unsafe std::string fs::path conversion copy_file calls (Kittywhiskers Van Gogh) b0d2484 merge bitcoin#23522: Improve fs::PathToString documentation (Kittywhiskers Van Gogh) 20d359b partial bitcoin#23469: Remove Boost build note from build-unix.md (Kittywhiskers Van Gogh) 193f6fd merge bitcoin#23446: Mention that BerkeleyDB is for legacy wallet in build-unix (Kittywhiskers Van Gogh) ecfac10 merge bitcoin#22937: Forbid calling unsafe fs::path(std::string) constructor and fs::path::string() method (Kittywhiskers Van Gogh) 23fe7e2 chore: dashify symbols in some unit tests (Kittywhiskers Van Gogh) 28b96a0 merge bitcoin#22840: fix unoptimized libraries in depends (Kittywhiskers Van Gogh) Pull request description: ## Additional Information * Depends on #6085 * Depends on #6137 * Dependency for #6150 ## Breaking Changes None observed. ## Checklist: - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas **(note: N/A)** - [x] I have added or updated relevant unit/integration/functional/e2e tests - [x] I have made corresponding changes to the documentation **(note: N/A)** - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: knst: utACK 0f23920 PastaPastaPasta: utACK 0f23920 Tree-SHA512: 4b8f0ae55185ece27d8084a5339196b7ed993c8138f4c59a0db3e16729d4edf4a59a68a8c7309c32df57734c07182821c4878b55c253da5df763204ad7158426
2 parents a9979eb + 0f23920 commit 87c918a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+668
-664
lines changed

build-aux/m4/ax_boost_filesystem.m4

Lines changed: 0 additions & 118 deletions
This file was deleted.

build-aux/m4/l_filesystem.m4

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
dnl Copyright (c) 2022 The Bitcoin Core developers
2+
dnl Distributed under the MIT software license, see the accompanying
3+
dnl file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
# GCC 8.1 and earlier requires -lstdc++fs
6+
# Clang 8.0.0 (libc++) and earlier requires -lc++fs
7+
8+
m4_define([_CHECK_FILESYSTEM_testbody], [[
9+
#include <filesystem>
10+
11+
namespace fs = std::filesystem;
12+
13+
int main() {
14+
(void)fs::current_path().root_name();
15+
return 0;
16+
}
17+
]])
18+
19+
AC_DEFUN([CHECK_FILESYSTEM], [
20+
21+
AC_LANG_PUSH(C++)
22+
23+
AC_MSG_CHECKING([whether std::filesystem can be used without link library])
24+
25+
AC_LINK_IFELSE([AC_LANG_SOURCE([_CHECK_FILESYSTEM_testbody])],[
26+
AC_MSG_RESULT([yes])
27+
],[
28+
AC_MSG_RESULT([no])
29+
SAVED_LIBS="$LIBS"
30+
LIBS="$SAVED_LIBS -lstdc++fs"
31+
AC_MSG_CHECKING([whether std::filesystem needs -lstdc++fs])
32+
AC_LINK_IFELSE([AC_LANG_SOURCE([_CHECK_FILESYSTEM_testbody])],[
33+
AC_MSG_RESULT([yes])
34+
],[
35+
AC_MSG_RESULT([no])
36+
AC_MSG_CHECKING([whether std::filesystem needs -lc++fs])
37+
LIBS="$SAVED_LIBS -lc++fs"
38+
AC_LINK_IFELSE([AC_LANG_SOURCE([_CHECK_FILESYSTEM_testbody])],[
39+
AC_MSG_RESULT([yes])
40+
],[
41+
AC_MSG_FAILURE([cannot figure out how to use std::filesystem])
42+
])
43+
])
44+
])
45+
46+
AC_LANG_POP
47+
])

ci/test/00_setup_env_native_asan.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
export LC_ALL=C.UTF-8
88

9-
export PACKAGES="clang llvm python3-zmq qtbase5-dev qttools5-dev-tools libevent-dev bsdmainutils libboost-dev libboost-filesystem-dev libboost-test-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libqrencode-dev"
9+
export PACKAGES="clang llvm python3-zmq qtbase5-dev qttools5-dev-tools libevent-dev bsdmainutils libboost-dev libboost-test-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libqrencode-dev"
1010
export NO_DEPENDS=1
1111
export TEST_RUNNER_EXTRA="--timeout-factor=4" # Increase timeout because sanitizers slow down
1212
export FUNCTIONAL_TESTS_CONFIG="--exclude wallet_multiwallet.py" # Temporarily suppress ASan heap-use-after-free (see issue #14163)

ci/test/00_setup_env_native_fuzz.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
export LC_ALL=C.UTF-8
88

99
export CONTAINER_NAME=ci_native_fuzz
10-
export PACKAGES="clang llvm python3 libevent-dev bsdmainutils libboost-dev libboost-filesystem-dev libboost-test-dev"
10+
export PACKAGES="clang llvm python3 libevent-dev bsdmainutils libboost-dev libboost-test-dev"
1111
export DEP_OPTS="NO_UPNP=1 DEBUG=1"
1212
export CPPFLAGS="-DDEBUG_LOCKORDER -DARENA_DEBUG"
1313
export CXXFLAGS="-Werror -Wno-unused-command-line-argument -Wno-unused-value -Wno-deprecated-builtins"

ci/test/00_setup_env_native_fuzz_with_valgrind.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
export LC_ALL=C.UTF-8
88

99
export CONTAINER_NAME=ci_native_fuzz_valgrind
10-
export PACKAGES="clang llvm python3 libevent-dev bsdmainutils libboost-dev libboost-system-dev libboost-filesystem-dev libboost-test-dev valgrind"
10+
export PACKAGES="clang llvm python3 libevent-dev bsdmainutils libboost-dev libboost-test-dev valgrind"
1111
export NO_DEPENDS=1
1212
export RUN_UNIT_TESTS=false
1313
export RUN_FUNCTIONAL_TESTS=false

ci/test/00_setup_env_native_ubsan.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
export LC_ALL=C.UTF-8
99

1010
export CONTAINER_NAME=ci_native_ubsan
11-
export PACKAGES="clang-16 llvm-16 python3-zmq qtbase5-dev qttools5-dev-tools libevent-dev bsdmainutils libboost-filesystem-dev libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libqrencode-dev"
11+
export PACKAGES="clang-16 llvm-16 python3-zmq qtbase5-dev qttools5-dev-tools libevent-dev bsdmainutils libboost-test-dev libboost-thread-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev libqrencode-dev"
1212
export DEP_OPTS="NO_UPNP=1 DEBUG=1"
1313
export GOAL="install"
1414
export BITCOIN_CONFIG="--enable-zmq --enable-reduce-exports --enable-crash-hooks --with-sanitizers=undefined CC=clang-16 CXX=clang++-16"

ci/test/00_setup_env_native_valgrind.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
export LC_ALL=C.UTF-8
88

9-
export PACKAGES="valgrind clang llvm python3-zmq libevent-dev bsdmainutils libboost-dev libboost-system-dev libboost-filesystem-dev libboost-test-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev"
9+
export PACKAGES="valgrind clang llvm python3-zmq libevent-dev bsdmainutils libboost-dev libboost-test-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev"
1010
export USE_VALGRIND=1
1111
export NO_DEPENDS=1
1212
export TEST_RUNNER_EXTRA="--exclude rpc_bind --timeout-factor=4" # Excluded for now, see https://github.com/bitcoin/bitcoin/issues/17765#issuecomment-602068547

configure.ac

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,19 @@ AC_ARG_ENABLE([c++20],
7272
[use_cxx20=$enableval],
7373
[use_cxx20=no])
7474

75-
dnl Require C++17 or C++20 compiler (no GNU extensions)
76-
if test "x$use_cxx20" = xyes; then
77-
AX_CXX_COMPILE_STDCXX([20], [noext], [mandatory])
78-
else
75+
dnl Require C++17 compiler (no GNU extensions)
76+
if test "$use_cxx20" = "no"; then
7977
AX_CXX_COMPILE_STDCXX([17], [noext], [mandatory])
78+
else
79+
AX_CXX_COMPILE_STDCXX([20], [noext], [mandatory])
8080
fi
8181

8282
dnl Check if -latomic is required for <std::atomic>
8383
CHECK_ATOMIC
8484

85+
dnl check if additional link flags are required for std::filesystem
86+
CHECK_FILESYSTEM
87+
8588
dnl Unless the user specified OBJCXX, force it to be the same as CXX. This ensures
8689
dnl that we get the same -std flags for both.
8790
m4_ifdef([AC_PROG_OBJCXX],[
@@ -1472,8 +1475,6 @@ dnl and will generate warnings with newer compilers.
14721475
dnl See: https://github.com/boostorg/container_hash/issues/22.
14731476
BOOST_CPPFLAGS="$BOOST_CPPFLAGS -DBOOST_NO_CXX98_FUNCTION_BASE"
14741477

1475-
AX_BOOST_FILESYSTEM
1476-
14771478
dnl Opt-in to Boost Process
14781479
if test "x$boost_process" != xno; then
14791480
AC_MSG_CHECKING(for Boost Process)
@@ -1488,7 +1489,7 @@ if test x$suppress_external_warnings != xno; then
14881489
BOOST_CPPFLAGS=SUPPRESS_WARNINGS($BOOST_CPPFLAGS)
14891490
fi
14901491

1491-
BOOST_LIBS="$BOOST_LDFLAGS $BOOST_SYSTEM_LIB $BOOST_FILESYSTEM_LIB"
1492+
BOOST_LIBS="$BOOST_LDFLAGS"
14921493
fi
14931494

14941495
dnl Check for reduced exports

contrib/valgrind.supp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,6 @@
118118
fun:__wcsnlen_sse4_1
119119
fun:wcsnrtombs
120120
}
121-
{
122-
Suppress wcsnrtombs warning (remove after removing boost::fs)
123-
Memcheck:Cond
124-
...
125-
fun:_ZN5boost10filesystem6detail11unique_pathERKNS0_4pathEPNS_6system10error_codeE
126-
}
127121
{
128122
Suppress boost warning
129123
Memcheck:Leak
@@ -134,21 +128,6 @@
134128
fun:_ZN5boost9unit_test14unit_test_mainEPFbvEiPPc
135129
fun:main
136130
}
137-
{
138-
Suppress boost::filesystem warning (fixed in boost 1.70: https://github.com/boostorg/filesystem/commit/bbe9d1771e5d679b3f10c42a58fc81f7e8c024a9)
139-
Memcheck:Cond
140-
fun:_ZN5boost10filesystem6detail28directory_iterator_incrementERNS0_18directory_iteratorEPNS_6system10error_codeE
141-
...
142-
obj:*/libboost_filesystem.so.*
143-
}
144-
{
145-
Suppress boost::filesystem warning (could be related: https://stackoverflow.com/questions/9830182/function-boostfilesystemcomplete-being-reported-as-possible-memory-leak-by-v)
146-
Memcheck:Leak
147-
match-leak-kinds: reachable
148-
fun:_Znwm
149-
...
150-
fun:_ZN5boost10filesystem8absoluteERKNS0_4pathES3_
151-
}
152131
{
153132
Suppress boost still reachable memory warning
154133
Memcheck:Leak

depends/packages/bdb.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ $(package)_config_opts_netbsd=--with-pic
1515
$(package)_config_opts_openbsd=--with-pic
1616
$(package)_config_opts_android=--with-pic
1717
$(package)_cflags+=-Wno-error=implicit-function-declaration
18-
$(package)_cxxflags=-std=c++17
18+
$(package)_cxxflags+=-std=c++17
1919
$(package)_cppflags_mingw32=-DUNICODE -D_UNICODE
2020
endef
2121

depends/packages/boost.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ $(package)_toolset_$(host_os)=clang
2626
else
2727
$(package)_toolset_$(host_os)=gcc
2828
endif
29-
$(package)_config_libraries=filesystem,test
30-
$(package)_cxxflags=-std=c++11
29+
$(package)_config_libraries=test
30+
$(package)_cxxflags+=-std=c++11
3131
$(package)_cxxflags_linux=-fPIC
3232
$(package)_cxxflags_freebsd=-fPIC
3333
$(package)_cxxflags_openbsd=-fPIC

depends/packages/zeromq.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ define $(package)_set_vars
1616
$(package)_config_opts_netbsd=--with-pic
1717
$(package)_config_opts_openbsd=--with-pic
1818
$(package)_config_opts_android=--with-pic
19-
$(package)_cxxflags=-std=c++17
19+
$(package)_cxxflags+=-std=c++17
2020
endef
2121

2222
define $(package)_preprocess_cmds

0 commit comments

Comments
 (0)