gem5-dev@gem5.org

The gem5 Developer List

View all threads

[S] Change in gem5/gem5[develop]: base: Use <experimental/filesystem> include for GCC v7

BB
Bobby Bruce (Gerrit)
Tue, Apr 11, 2023 1:24 AM

Bobby Bruce has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/69598?usp=email )

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

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

M src/base/socket.cc
1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/base/socket.cc b/src/base/socket.cc
index 2e9f815..0f47b2a 100644
--- a/src/base/socket.cc
+++ b/src/base/socket.cc
@@ -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"

--
To view, visit
https://gem5-review.googlesource.com/c/public/gem5/+/69598?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I31db5488f272f9652edebf24ecefca3722369076
Gerrit-Change-Number: 69598
Gerrit-PatchSet: 1
Gerrit-Owner: Bobby Bruce bbruce@ucdavis.edu
Gerrit-MessageType: newchange

Bobby Bruce has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/69598?usp=email ) Change subject: base: Use <experimental/filesystem> include for GCC v7 ...................................................................... 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 --- M src/base/socket.cc 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/base/socket.cc b/src/base/socket.cc index 2e9f815..0f47b2a 100644 --- a/src/base/socket.cc +++ b/src/base/socket.cc @@ -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" -- To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/69598?usp=email To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings Gerrit-Project: public/gem5 Gerrit-Branch: develop Gerrit-Change-Id: I31db5488f272f9652edebf24ecefca3722369076 Gerrit-Change-Number: 69598 Gerrit-PatchSet: 1 Gerrit-Owner: Bobby Bruce <bbruce@ucdavis.edu> Gerrit-MessageType: newchange