Skip to content

Commit

Permalink
Fix errors when linking fdbserver on macOS due to boost::filesystem
Browse files Browse the repository at this point in the history
This replaces boost::filesystem with std::filesystem.
`std::filesystem::recursive_directory_iterator` is supported since C++17
and `std::string::ends_with` is since C++20. FoundationDB is configured
to C++20.

Without this change, linking fails with:

```
[1183/1697] Linking CXX executable bin/fdbserver
FAILED: bin/fdbserver
...
Undefined symbols for architecture arm64:
  "boost::filesystem::detail::dir_itr_imp::~dir_itr_imp()", referenced from:
      encryptionAtRestPlaintextMarkerCheck() in tester.actor.g.cpp.o
      boost::filesystem::recursive_directory_iterator::~recursive_directory_iterator() in tester.actor.g.cpp.o
      boost::filesystem::recursive_directory_iterator::recursive_directory_iterator(boost::filesystem::path const&) (.cold.1) in tester.actor.g.cpp.o
  "boost::filesystem::detail::dir_itr_imp::operator delete(void*)", referenced from:
      encryptionAtRestPlaintextMarkerCheck() in tester.actor.g.cpp.o
      boost::filesystem::recursive_directory_iterator::~recursive_directory_iterator() in tester.actor.g.cpp.o
      boost::filesystem::recursive_directory_iterator::recursive_directory_iterator(boost::filesystem::path const&) (.cold.1) in tester.actor.g.cpp.o
  "boost::filesystem::detail::recursive_directory_iterator_construct(boost::filesystem::recursive_directory_iterator&, boost::filesystem::path const&, boost::filesystem::directory_options, boost::system::error_code*)", referenced from:
      boost::filesystem::recursive_directory_iterator::recursive_directory_iterator(boost::filesystem::path const&) in tester.actor.g.cpp.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```

This also fixes a forgotten include (unordered_map) in fdbmonitor.h.
  • Loading branch information
sepeth committed Sep 17, 2024
1 parent b9926ae commit b614ba7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
1 change: 1 addition & 0 deletions fdbmonitor/fdbmonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <string>
#include <sstream>
#include <random>
#include <unordered_map>
#include <unordered_set>

#ifdef __linux__
Expand Down
16 changes: 6 additions & 10 deletions fdbserver/tester.actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@
* limitations under the License.
*/

#include <boost/algorithm/string/predicate.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/directory.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/range/iterator_range_core.hpp>
#include <cinttypes>
#include <filesystem>
#include <fstream>
#include <functional>
#include <istream>
Expand Down Expand Up @@ -2558,7 +2554,7 @@ void encryptionAtRestPlaintextMarkerCheck() {
return;
}

namespace fs = boost::filesystem;
namespace fs = std::filesystem;

printf("EncryptionAtRestPlaintextMarkerCheckStart\n");
TraceEvent("EncryptionAtRestPlaintextMarkerCheckStart");
Expand All @@ -2568,8 +2564,8 @@ void encryptionAtRestPlaintextMarkerCheck() {
bool success = true;
// Enumerate all files in the "simfdb/" folder and look for "marker" string
for (fs::recursive_directory_iterator itr(p); itr != end; ++itr) {
if (boost::filesystem::is_regular_file(itr->path())) {
std::ifstream f(itr->path().string().c_str());
if (fs::is_regular_file(itr->path())) {
std::ifstream f(itr->path());
if (f) {
std::string buf;
int count = 0;
Expand Down Expand Up @@ -3048,9 +3044,9 @@ ACTOR Future<Void> runTests(Reference<IClusterConnectionRecord> connRecord,
return Void();
}
enableClientInfoLogging(); // Enable Client Info logging by default for tester
if (boost::algorithm::ends_with(fileName, ".txt")) {
if (fileName.ends_with(".txt")) {
testSet.testSpecs = readTests(ifs);
} else if (boost::algorithm::ends_with(fileName, ".toml")) {
} else if (fileName.ends_with(".toml")) {
// TOML is weird about opening the file as binary on windows, so we
// just let TOML re-open the file instead of using ifs.
testSet = readTOMLTests(fileName);
Expand Down

0 comments on commit b614ba7

Please sign in to comment.