base: Use <experimental/filesystem> include for GCC v7

gem5 officially supports GCC 7+. In GCC 7 the "filesystem" module was
added but only in the "experimental" namespace as
"<experimental/filesystem>". In GCC 8+ the module can be found as
"<filesystem>".

Because of this, include guards to handle this. They include
"<experimental/filesystem>" for the GCC v7 case and the "<filesystem>"
for all other versions.

This bug was partially responsible for this compiler tests failures:
https://jenkins.gem5.org/job/compiler-checks/570

Note: gem5 does not support GCC versions <7. Thus the
"#if __GNUC__ >=8 <GCC 8+ code> #else <GCC 7 code> #endif" logic is
valid.

Change-Id: I31db5488f272f9652edebf24ecefca3722369076
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/69598
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu>
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
This commit is contained in:
Bobby R. Bruce
2023-04-10 17:07:18 -07:00
committed by Bobby Bruce
parent 1258f481c9
commit e79d6616dd

View File

@@ -39,7 +39,19 @@
#include <unistd.h>
#include <cerrno>
#include <filesystem>
#if (defined(__GNUC__) && (__GNUC__ >= 8)) || defined(__clang__)
#include <filesystem>
#else
// This is only reachable if we're using GCC 7 (note: gem5 does not support
// GCC versions older than GCC 7 as they do not support the C++17
// standard).
// If we're using GCC 7, we need to use <experimental/filesystem>.
#include <experimental/filesystem>
namespace std {
namespace filesystem = experimental::filesystem;
}
#endif
#include "base/logging.hh"
#include "base/output.hh"