Skip to content

Commit a3b7926

Browse files
committed
merge bitcoin#20744: Use std::filesystem. Remove Boost Filesystem & System
1 parent be7ac49 commit a3b7926

Some content is hidden

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

46 files changed

+264
-437
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: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ fi
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/boost.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ $(package)_toolset_$(host_os)=clang
2626
else
2727
$(package)_toolset_$(host_os)=gcc
2828
endif
29-
$(package)_config_libraries=filesystem,test
29+
$(package)_config_libraries=test
3030
$(package)_cxxflags+=-std=c++11
3131
$(package)_cxxflags_linux=-fPIC
3232
$(package)_cxxflags_freebsd=-fPIC

0 commit comments

Comments
 (0)