]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: Disable -Wl,--as-needed in DEAL_II_HAVE_USABLE_FLAGS 3916/head
authorMatthias Maier <tamiko@43-1.org>
Fri, 3 Feb 2017 08:35:32 +0000 (02:35 -0600)
committerMatthias Maier <tamiko@43-1.org>
Fri, 3 Feb 2017 20:24:50 +0000 (14:24 -0600)
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.

See #3686

cmake/macros/macro_check_compiler_setup.cmake

index 32c33a77aa6277ccb3d75e959103ef23518e2cff..70ba2d38af9c3ef190fcd76312a46dc5c36abec6 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_unstr}" _linker_flags)
+  STRING(STRIP "${_linker_flags}" _linker_flags)
 
   #
   # Rerun this test if flags have changed:

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.