Skip to content

Commit

Permalink
fix: use boost::filesystem::path instead of std::filesystem::path to …
Browse files Browse the repository at this point in the history
…be compatible with lower gcc/clang versions (apache#1771)

apache#1772

Building jobs for Ubuntu 1804, CentOS 7 and Clang-9 failed due to
"fatal error: filesystem: No such file or directory #include <filesystem>"
while the Action `Lint and build regularly` was run on Github.

The compiler versions of Ubuntu 1804, CentOS 7 and Clang-9 are
GCC 7.5.0, GCC 7.3.1 and Clang 9. All of these versions do not support
including `<filesystem>` header file and using `std::filesystem`. The
minimum compiler versions that support `std::filesystem` are GCC 8
and Clang 10.

The reason to be compatible with lower GCC/Clang versions is that GCC 7
is high enough for now. Upgrading GCC version might lead to errors for
users while building Pegasus on their own development environments.
  • Loading branch information
empiredan authored Dec 15, 2023
1 parent df61744 commit 89ee42c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/shell/commands/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
*/

// IWYU pragma: no_include <bits/getopt_core.h>
// TODO(wangdan): Since std::filesystem was first introduced in
// gcc 8 and clang 10, we could only use boost::filesystem for
// now. Once the minimum version of all the compilers we support
// has reached these versions, use #include <filesystem> instead.
#include <boost/filesystem/path.hpp>
// TODO(yingchun): refactor this after libfmt upgraded
#include <fmt/chrono.h> // IWYU pragma: keep
#include <fmt/printf.h> // IWYU pragma: keep
Expand All @@ -35,7 +40,6 @@
#include <ctime>
// IWYU pragma: no_include <fmt/core.h>
// IWYU pragma: no_include <fmt/format.h>
#include <filesystem>
#include <functional>
#include <iostream>
#include <string>
Expand Down Expand Up @@ -109,7 +113,7 @@ bool mlog_dump(command_executor *e, shell_context *sc, arguments args)
return false;
}

const auto replica_path = std::filesystem::path(plog_dir).parent_path();
const auto replica_path = boost::filesystem::path(plog_dir).parent_path();
const auto name = replica_path.filename().string();
if (name.empty()) {
fmt::print(stderr, "ERROR: '{}' is not a valid plog directory\n", plog_dir);
Expand Down

0 comments on commit 89ee42c

Please sign in to comment.