Skip to content

Commit

Permalink
merge bitcoin#20744: Use std::filesystem. Remove Boost Filesystem & S…
Browse files Browse the repository at this point in the history
…ystem
  • Loading branch information
kwvg committed Aug 6, 2024
1 parent be7ac49 commit a3b7926
Show file tree
Hide file tree
Showing 46 changed files with 264 additions and 437 deletions.
118 changes: 0 additions & 118 deletions build-aux/m4/ax_boost_filesystem.m4

This file was deleted.

47 changes: 47 additions & 0 deletions build-aux/m4/l_filesystem.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
dnl Copyright (c) 2022 The Bitcoin Core developers
dnl Distributed under the MIT software license, see the accompanying
dnl file COPYING or http://www.opensource.org/licenses/mit-license.php.

# GCC 8.1 and earlier requires -lstdc++fs
# Clang 8.0.0 (libc++) and earlier requires -lc++fs

m4_define([_CHECK_FILESYSTEM_testbody], [[
#include <filesystem>
namespace fs = std::filesystem;
int main() {
(void)fs::current_path().root_name();
return 0;
}
]])

AC_DEFUN([CHECK_FILESYSTEM], [
AC_LANG_PUSH(C++)
AC_MSG_CHECKING([whether std::filesystem can be used without link library])
AC_LINK_IFELSE([AC_LANG_SOURCE([_CHECK_FILESYSTEM_testbody])],[
AC_MSG_RESULT([yes])
],[
AC_MSG_RESULT([no])
SAVED_LIBS="$LIBS"
LIBS="$SAVED_LIBS -lstdc++fs"
AC_MSG_CHECKING([whether std::filesystem needs -lstdc++fs])
AC_LINK_IFELSE([AC_LANG_SOURCE([_CHECK_FILESYSTEM_testbody])],[
AC_MSG_RESULT([yes])
],[
AC_MSG_RESULT([no])
AC_MSG_CHECKING([whether std::filesystem needs -lc++fs])
LIBS="$SAVED_LIBS -lc++fs"
AC_LINK_IFELSE([AC_LANG_SOURCE([_CHECK_FILESYSTEM_testbody])],[
AC_MSG_RESULT([yes])
],[
AC_MSG_FAILURE([cannot figure out how to use std::filesystem])
])
])
])
AC_LANG_POP
])
2 changes: 1 addition & 1 deletion ci/test/00_setup_env_native_asan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

export LC_ALL=C.UTF-8

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"
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"
export NO_DEPENDS=1
export TEST_RUNNER_EXTRA="--timeout-factor=4" # Increase timeout because sanitizers slow down
export FUNCTIONAL_TESTS_CONFIG="--exclude wallet_multiwallet.py" # Temporarily suppress ASan heap-use-after-free (see issue #14163)
Expand Down
2 changes: 1 addition & 1 deletion ci/test/00_setup_env_native_fuzz.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
export LC_ALL=C.UTF-8

export CONTAINER_NAME=ci_native_fuzz
export PACKAGES="clang llvm python3 libevent-dev bsdmainutils libboost-dev libboost-filesystem-dev libboost-test-dev"
export PACKAGES="clang llvm python3 libevent-dev bsdmainutils libboost-dev libboost-test-dev"
export DEP_OPTS="NO_UPNP=1 DEBUG=1"
export CPPFLAGS="-DDEBUG_LOCKORDER -DARENA_DEBUG"
export CXXFLAGS="-Werror -Wno-unused-command-line-argument -Wno-unused-value -Wno-deprecated-builtins"
Expand Down
2 changes: 1 addition & 1 deletion ci/test/00_setup_env_native_fuzz_with_valgrind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
export LC_ALL=C.UTF-8

export CONTAINER_NAME=ci_native_fuzz_valgrind
export PACKAGES="clang llvm python3 libevent-dev bsdmainutils libboost-dev libboost-system-dev libboost-filesystem-dev libboost-test-dev valgrind"
export PACKAGES="clang llvm python3 libevent-dev bsdmainutils libboost-dev libboost-test-dev valgrind"
export NO_DEPENDS=1
export RUN_UNIT_TESTS=false
export RUN_FUNCTIONAL_TESTS=false
Expand Down
2 changes: 1 addition & 1 deletion ci/test/00_setup_env_native_ubsan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
export LC_ALL=C.UTF-8

export CONTAINER_NAME=ci_native_ubsan
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"
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"
export DEP_OPTS="NO_UPNP=1 DEBUG=1"
export GOAL="install"
export BITCOIN_CONFIG="--enable-zmq --enable-reduce-exports --enable-crash-hooks --with-sanitizers=undefined CC=clang-16 CXX=clang++-16"
Expand Down
2 changes: 1 addition & 1 deletion ci/test/00_setup_env_native_valgrind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

export LC_ALL=C.UTF-8

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"
export PACKAGES="valgrind clang llvm python3-zmq libevent-dev bsdmainutils libboost-dev libboost-test-dev libdb5.3++-dev libminiupnpc-dev libzmq3-dev"
export USE_VALGRIND=1
export NO_DEPENDS=1
export TEST_RUNNER_EXTRA="--exclude rpc_bind --timeout-factor=4" # Excluded for now, see https://github.com/bitcoin/bitcoin/issues/17765#issuecomment-602068547
Expand Down
7 changes: 4 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ fi
dnl Check if -latomic is required for <std::atomic>
CHECK_ATOMIC

dnl check if additional link flags are required for std::filesystem
CHECK_FILESYSTEM

dnl Unless the user specified OBJCXX, force it to be the same as CXX. This ensures
dnl that we get the same -std flags for both.
m4_ifdef([AC_PROG_OBJCXX],[
Expand Down Expand Up @@ -1472,8 +1475,6 @@ dnl and will generate warnings with newer compilers.
dnl See: https://github.com/boostorg/container_hash/issues/22.
BOOST_CPPFLAGS="$BOOST_CPPFLAGS -DBOOST_NO_CXX98_FUNCTION_BASE"

AX_BOOST_FILESYSTEM

dnl Opt-in to Boost Process
if test "x$boost_process" != xno; then
AC_MSG_CHECKING(for Boost Process)
Expand All @@ -1488,7 +1489,7 @@ if test x$suppress_external_warnings != xno; then
BOOST_CPPFLAGS=SUPPRESS_WARNINGS($BOOST_CPPFLAGS)
fi

BOOST_LIBS="$BOOST_LDFLAGS $BOOST_SYSTEM_LIB $BOOST_FILESYSTEM_LIB"
BOOST_LIBS="$BOOST_LDFLAGS"
fi

dnl Check for reduced exports
Expand Down
21 changes: 0 additions & 21 deletions contrib/valgrind.supp
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,6 @@
fun:__wcsnlen_sse4_1
fun:wcsnrtombs
}
{
Suppress wcsnrtombs warning (remove after removing boost::fs)
Memcheck:Cond
...
fun:_ZN5boost10filesystem6detail11unique_pathERKNS0_4pathEPNS_6system10error_codeE
}
{
Suppress boost warning
Memcheck:Leak
Expand All @@ -134,21 +128,6 @@
fun:_ZN5boost9unit_test14unit_test_mainEPFbvEiPPc
fun:main
}
{
Suppress boost::filesystem warning (fixed in boost 1.70: https://github.com/boostorg/filesystem/commit/bbe9d1771e5d679b3f10c42a58fc81f7e8c024a9)
Memcheck:Cond
fun:_ZN5boost10filesystem6detail28directory_iterator_incrementERNS0_18directory_iteratorEPNS_6system10error_codeE
...
obj:*/libboost_filesystem.so.*
}
{
Suppress boost::filesystem warning (could be related: https://stackoverflow.com/questions/9830182/function-boostfilesystemcomplete-being-reported-as-possible-memory-leak-by-v)
Memcheck:Leak
match-leak-kinds: reachable
fun:_Znwm
...
fun:_ZN5boost10filesystem8absoluteERKNS0_4pathES3_
}
{
Suppress boost still reachable memory warning
Memcheck:Leak
Expand Down
2 changes: 1 addition & 1 deletion depends/packages/boost.mk
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ $(package)_toolset_$(host_os)=clang
else
$(package)_toolset_$(host_os)=gcc
endif
$(package)_config_libraries=filesystem,test
$(package)_config_libraries=test
$(package)_cxxflags+=-std=c++11
$(package)_cxxflags_linux=-fPIC
$(package)_cxxflags_freebsd=-fPIC
Expand Down
2 changes: 1 addition & 1 deletion doc/build-unix.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ sudo apt-get install build-essential libtool autotools-dev automake pkg-config b
Now, you can either build from self-compiled [depends](/depends/README.md) or install the required dependencies:

```sh
sudo apt-get install libevent-dev libboost-dev libboost-system-dev libboost-filesystem-dev libboost-test-dev
sudo apt-get install libevent-dev libboost-dev libboost-test-dev
```

SQLite is required for the descriptor wallet:
Expand Down
1 change: 1 addition & 0 deletions src/addrdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <addrman.h>
#include <chainparams.h>
#include <clientversion.h>
#include <fs.h>
#include <hash.h>
#include <logging/timer.h>
#include <netbase.h>
Expand Down
3 changes: 2 additions & 1 deletion src/bench/bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <validation.h>

#include <algorithm>
#include <fstream>
#include <iostream>
#include <regex>

Expand All @@ -23,7 +24,7 @@ void GenerateTemplateResults(const std::vector<ankerl::nanobench::Result>& bench
// nothing to write, bail out
return;
}
fsbridge::ofstream fout{fs::PathFromString(filename)};
std::ofstream fout{fs::PathFromString(filename)};
if (fout.is_open()) {
ankerl::nanobench::render(tpl, benchmarkResults, fout);
} else {
Expand Down
Loading

0 comments on commit a3b7926

Please sign in to comment.