]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: remove -Wl,--as-needed flag setup 13732/head
authorMatthias Maier <tamiko@43-1.org>
Fri, 13 May 2022 20:57:15 +0000 (15:57 -0500)
committerMatthias Maier <tamiko@43-1.org>
Fri, 13 May 2022 21:22:27 +0000 (16:22 -0500)
The issue with the current handling of the --Wl,--as-needed flag is the
fact that we set it internally but later on filter it (unconditionally)
for user projects.

This has the issue that it is currently not possible to set
--Wl,--as-needed by hand when needed.

Thus, let us simply remove the setup and the workarounds.

cmake/config/CMakeLists.txt
cmake/macros/macro_check_compiler_setup.cmake
cmake/setup_compiler_flags_gnu.cmake
cmake/setup_compiler_flags_intel.cmake

index 54763e068cb4c4e9e8ff3cb391537a5db1717eeb..8255cf2576edad5e61ff6fde35758d940c031e98 100644 (file)
@@ -64,12 +64,6 @@ INSTALL(FILES ${_macros}
 #                                                                      #
 ########################################################################
 
-#
-# Do not force --as-needed for executables on user side:
-#
-
-STRIP_FLAG(DEAL_II_LINKER_FLAGS "-Wl,--as-needed")
-
 #
 # Strip -Wno-deprecated-declarations from DEAL_II_CXX_FLAGS so that
 # deprecation warnings are actually shown for user code:
index 6572e5635687246284421c6e17d950e3fdf1533e..ef8c3a3d678f1ff7c638f5c4d4b0c26effb77807 100644 (file)
 #
 
 MACRO(CHECK_COMPILER_SETUP _compiler_flags_unstr _linker_flags_unstr _var)
-  #
-  # Strip -Wl,--as-needed from the list of linker flags. This works around
-  # a serious regression with ld.bfd in combination with -Wl,--as-needed
-  # when compiling a simple
-  #
-  #    int main () { return 0; }
-  #
-  # and linking against a *huge* list of (entirely unused) libraries.
-  #
-  # Ideally, one should use ld.gold [1] instead of ld.bfd - but because
-  # this is not always possible, simply disable -Wl,--as-needed.
-  #
-  # See https://github.com/dealii/dealii/issues/3686
-  #
-  # [1] https://lwn.net/Articles/274859/
-  #
-  STRING(REPLACE "-Wl,--as-needed" "" _linker_flags "${_linker_flags_unstr}")
-
   #
   # Strip leading and trailing whitespace to make CMake 2.8.8 happy
   #
   STRING(STRIP "${_compiler_flags_unstr}" _compiler_flags)
-  STRING(STRIP "${_linker_flags}" _linker_flags)
+  STRING(STRIP "${_linker_flags_unstr}" _linker_flags)
 
   #
   # Rerun this test if flags have changed:
index 737a90b821071f93162ae9676308fb4195028b6a..bd28e195b245e274d72c5285612f328c8e26da0f 100644 (file)
@@ -65,12 +65,6 @@ ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-pedantic")
 #
 ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-fPIC")
 
-#
-# Check whether the -as-needed flag is available. If so set it to link
-# the deal.II library with it.
-#
-ENABLE_IF_LINKS(DEAL_II_LINKER_FLAGS "-Wl,--as-needed")
-
 #
 # Setup various warnings:
 #
index b83493f848002981281ce4b6a2e1d1db92d71247..817fe5e16994e11ab0f42739725ccc397d7b5185 100644 (file)
@@ -39,12 +39,6 @@ ENDIF()
 #
 ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-fpic")
 
-#
-# Check whether the -as-needed flag is available. If so set it to link
-# the deal.II library with it.
-#
-ENABLE_IF_LINKS(DEAL_II_LINKER_FLAGS "-Wl,--as-needed")
-
 #
 # Enable verbose warnings:
 #

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.