gem5-dev@gem5.org

The gem5 Developer List

View all threads

[S] Change in gem5/gem5[develop]: scons: Add '-lstdc++fs' to LIBS env when GCC version < 9

BB
Bobby Bruce (Gerrit)
Tue, Apr 11, 2023 6:08 AM

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

Change subject: scons: Add '-lstdc++fs' to LIBS env when GCC version < 9
......................................................................

scons: Add '-lstdc++fs' to LIBS env when GCC version < 9

This commit is in response to a failure in the compiler tests:
https://jenkins.gem5.org/job/compiler-checks/570/

GCC versions <9 failed to compile gem5 with the following error:

socket.cc:(.text+0x32d5): undefined reference to  
`std::filesystem::__cxx11::path::_M_split_cmpts()'
socket.cc:(.text+0x32e5): undefined reference to  
`std::filesystem::create_directory(std::filesystem::__cxx11::path const&,  
std::error_code&)'
socket.cc:(.text+0x3370): undefined reference to  
`std::filesystem::current_path[abi:cxx11](std::error_code&)'
socket.cc:(.text+0x33cc): undefined reference to  
`std::filesystem::__cxx11::path::_M_split_cmpts()'
socket.cc:(.text+0x33d7): undefined reference to  
`std::filesystem::current_path(std::filesystem::__cxx11::path const&,  
std::error_code&)'
socket.cc:(.text+0x3468): undefined reference to  
`std::filesystem::current_path(std::filesystem::__cxx11::path const&,  
std::error_code&)'

This was due to this patch:
https://gem5-review.googlesource.com/c/public/gem5/+/69164 which
utilized std::filesystem. Prior to to GCC v9, explicit linking with
the stdc++fs library is required due to std::filesystem being an
experimental implementation prior to GGC v9.

Change-Id: I584e29f100cb59b40bd155c212e1814f6d8fbb99
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/69597
Tested-by: kokoro noreply+kokoro@google.com
Reviewed-by: Bobby Bruce bbruce@ucdavis.edu
Maintainer: Bobby Bruce bbruce@ucdavis.edu

M SConstruct
1 file changed, 11 insertions(+), 0 deletions(-)

Approvals:
Bobby Bruce: Looks good to me, approved; Looks good to me, approved
kokoro: Regressions pass

diff --git a/SConstruct b/SConstruct
index 7d6f406..e91e700 100755
--- a/SConstruct
+++ b/SConstruct
@@ -483,6 +483,17 @@
'-fno-builtin-malloc', '-fno-builtin-calloc',
'-fno-builtin-realloc', '-fno-builtin-free'])

  •    if compareVersions(env['CXXVERSION'], "9") < 0:
    
  •        # `libstdc++fs`` must be explicitly linked for  
    

`std::filesystem``

  •        # in GCC version 8. As of GCC version 9, this is not required.
    
  •        #
    
  •        # In GCC 7 the `libstdc++fs`` library explicit linkage is also
    
  •        # required but the `std::filesystem` is under the  
    

experimental

  •        # namespace(`std::experimental::filesystem`).
    
  •        #
    
  •        # Note: gem5 does not support GCC versions < 7.
    
  •        env.Append(LIBS=['stdc++fs'])
    
  • elif env['CLANG']:
        if compareVersions(env['CXXVERSION'], "6") < 0:
            error('clang version 6 or newer required.\n'
    

--
To view, visit
https://gem5-review.googlesource.com/c/public/gem5/+/69597?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: I584e29f100cb59b40bd155c212e1814f6d8fbb99
Gerrit-Change-Number: 69597
Gerrit-PatchSet: 2
Gerrit-Owner: Bobby Bruce bbruce@ucdavis.edu
Gerrit-Reviewer: Bobby Bruce bbruce@ucdavis.edu
Gerrit-Reviewer: Gabe Black gabe.black@gmail.com
Gerrit-Reviewer: kokoro noreply+kokoro@google.com
Gerrit-MessageType: merged

Bobby Bruce has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/69597?usp=email ) Change subject: scons: Add '-lstdc++fs' to LIBS env when GCC version < 9 ...................................................................... scons: Add '-lstdc++fs' to LIBS env when GCC version < 9 This commit is in response to a failure in the compiler tests: https://jenkins.gem5.org/job/compiler-checks/570/ GCC versions <9 failed to compile gem5 with the following error: ``` socket.cc:(.text+0x32d5): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()' socket.cc:(.text+0x32e5): undefined reference to `std::filesystem::create_directory(std::filesystem::__cxx11::path const&, std::error_code&)' socket.cc:(.text+0x3370): undefined reference to `std::filesystem::current_path[abi:cxx11](std::error_code&)' socket.cc:(.text+0x33cc): undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()' socket.cc:(.text+0x33d7): undefined reference to `std::filesystem::current_path(std::filesystem::__cxx11::path const&, std::error_code&)' socket.cc:(.text+0x3468): undefined reference to `std::filesystem::current_path(std::filesystem::__cxx11::path const&, std::error_code&)' ``` This was due to this patch: https://gem5-review.googlesource.com/c/public/gem5/+/69164 which utilized `std::filesystem`. Prior to to GCC v9, explicit linking with the stdc++fs library is required due to `std::filesystem` being an experimental implementation prior to GGC v9. Change-Id: I584e29f100cb59b40bd155c212e1814f6d8fbb99 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/69597 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu> Maintainer: Bobby Bruce <bbruce@ucdavis.edu> --- M SConstruct 1 file changed, 11 insertions(+), 0 deletions(-) Approvals: Bobby Bruce: Looks good to me, approved; Looks good to me, approved kokoro: Regressions pass diff --git a/SConstruct b/SConstruct index 7d6f406..e91e700 100755 --- a/SConstruct +++ b/SConstruct @@ -483,6 +483,17 @@ '-fno-builtin-malloc', '-fno-builtin-calloc', '-fno-builtin-realloc', '-fno-builtin-free']) + if compareVersions(env['CXXVERSION'], "9") < 0: + # `libstdc++fs`` must be explicitly linked for `std::filesystem`` + # in GCC version 8. As of GCC version 9, this is not required. + # + # In GCC 7 the `libstdc++fs`` library explicit linkage is also + # required but the `std::filesystem` is under the `experimental` + # namespace(`std::experimental::filesystem`). + # + # Note: gem5 does not support GCC versions < 7. + env.Append(LIBS=['stdc++fs']) + elif env['CLANG']: if compareVersions(env['CXXVERSION'], "6") < 0: error('clang version 6 or newer required.\n' -- To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/69597?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: I584e29f100cb59b40bd155c212e1814f6d8fbb99 Gerrit-Change-Number: 69597 Gerrit-PatchSet: 2 Gerrit-Owner: Bobby Bruce <bbruce@ucdavis.edu> Gerrit-Reviewer: Bobby Bruce <bbruce@ucdavis.edu> Gerrit-Reviewer: Gabe Black <gabe.black@gmail.com> Gerrit-Reviewer: kokoro <noreply+kokoro@google.com> Gerrit-MessageType: merged