Skip to content

Commit

Permalink
automatically link to libstdc++-fs when we detect gcc8
Browse files Browse the repository at this point in the history
No need for a FAQ in this case
  • Loading branch information
glesur committed Nov 4, 2023
1 parent f4f8d46 commit 8ce2d91
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ include(GetGitRevisionDescription)
include(ReplaceIdefixSource)
include(AddIdefixSource)
include(SetIdefixProperty)
include(SetRequiredBuildSettingsForGCC8)

#Idefix requires Cuda Lambdas (experimental)
if(Kokkos_ENABLE_CUDA)
Expand All @@ -50,6 +51,9 @@ add_subdirectory(src/kokkos build/kokkos)
# Add Idefix CXX Flags
add_compile_options(${Idefix_CXX_FLAGS})

# Add filesystem libraries for GCC8
set_required_build_settings_for_GCC8()

if(Idefix_WERROR)
if(Kokkos_ENABLE_CUDA)
add_compile_options(-Xcudafe --promote_warnings)
Expand Down
9 changes: 9 additions & 0 deletions cmake/SetRequiredBuildSettingsForGCC8.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# The std::filesystem functions are part of the C++17 standard, but GCC8
# does not store them in libstdc++ but in libstdc++-fs. This function
# ensure that we link to this additional library when using GCC8
# from https://discourse.cmake.org/t/correct-way-to-link-std-filesystem-with-gcc-8/4121
function( set_required_build_settings_for_GCC8 )
# Always link with libstdc++fs.a when using GCC 8.
# Note: This command makes sure that this option comes pretty late on the cmdline.
link_libraries( "$<$<AND:$<CXX_COMPILER_ID:GNU>,$<VERSION_LESS:$<CXX_COMPILER_VERSION>,9.0>>:-lstdc++fs>" )
endfunction()
5 changes: 0 additions & 5 deletions doc/source/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ The compilation stops while compiling Kokkos with ``/usr/include/stdlib.h(58): e
When using the Intel compiler on a Mac Intel, I get a linking error involving the ``SharedAllocationRecordIvvE18t_tracking_enabledE`` symbol.
This is a known bug of the Intel Mac compiler with Kokkos. Apparently Intel has decided not to fix it. Check the issue on the `Kokkos git page <https://github.com/kokkos/kokkos/issues/1959>`_.

I get an error at link that says there are undefined symbols fo std::filesystem
This is a known bug/limitation of gcc8 that does not include filesystem extensions in the standard library.
You should try to clear up CMakeCache.txt and explicitely add the required link library when calling cmake as in
``LDFLAGS=-lstdc++fs cmake $IDEFIX_DIR ...```

Execution
---------

Expand Down

0 comments on commit 8ce2d91

Please sign in to comment.