[PATCH] libstdc++: detect mold linker.

Martin Liška mliska@suse.cz
Fri Jan 21 16:11:23 GMT 2022


Hi.

This adds linker detection for mold in libstdc++-v3.

Ready to be installed?
Thanks,
Martin

libstdc++-v3/ChangeLog:

	* acinclude.m4: Detect features for ld.mold linker.
	* configure: Regenerate.
---
  libstdc++-v3/acinclude.m4 |  8 +++++-
  libstdc++-v3/configure    | 52 +++++++++++++++++++++++++++++++--------
  2 files changed, 49 insertions(+), 11 deletions(-)

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index d996477254c..1a7d7a96050 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -172,6 +172,7 @@ dnl  LD (as a side effect of testing)
  dnl Sets:
  dnl  with_gnu_ld
  dnl  glibcxx_ld_is_gold (set to "no" or "yes")
+dnl  glibcxx_ld_is_mold (set to "no" or "yes")
  dnl  glibcxx_gnu_ld_version (possibly)
  dnl
  dnl The last will be a single integer, e.g., version 1.23.45.0.67.89 will
@@ -204,11 +205,14 @@ AC_DEFUN([GLIBCXX_CHECK_LINKER_FEATURES], [
    # Start by getting the version number.  I think the libtool test already
    # does some of this, but throws away the result.
    glibcxx_ld_is_gold=no
+  glibcxx_ld_is_mold=no
    if test x"$with_gnu_ld" = x"yes"; then
      AC_MSG_CHECKING([for ld version])
      changequote(,)
      if $LD --version 2>/dev/null | grep 'GNU gold' >/dev/null 2>&1; then
        glibcxx_ld_is_gold=yes
+    elif $LD --version 2>/dev/null | grep 'mold' >/dev/null 2>&1; then
+      glibcxx_ld_is_mold=yes
      fi
      ldver=`$LD --version 2>/dev/null |
  	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
@@ -220,7 +224,7 @@ AC_DEFUN([GLIBCXX_CHECK_LINKER_FEATURES], [
  
    # Set --gc-sections.
    glibcxx_have_gc_sections=no
-  if test "$glibcxx_ld_is_gold" = "yes"; then
+  if test "$glibcxx_ld_is_gold" = "yes" || test "$glibcxx_ld_is_mold" = "yes" ; then
      if $LD --help 2>/dev/null | grep gc-sections >/dev/null 2>&1; then
        glibcxx_have_gc_sections=yes
      fi
@@ -3796,6 +3800,8 @@ changequote([,])dnl
      enable_symvers=no
    elif test $glibcxx_ld_is_gold = yes ; then
      : All versions of gold support symbol versioning.
+  elif test $glibcxx_ld_is_mold = yes ; then
+    : All versions of mold support symbol versioning.
    elif test $glibcxx_gnu_ld_version -lt $glibcxx_min_gnu_ld_version ; then
      # The right tools, the right setup, but too old.  Fallbacks?
      AC_MSG_WARN(=== Linker version $glibcxx_gnu_ld_version is too old for)
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 4c20c669144..0b551b864ce 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -22157,12 +22157,15 @@ with_gnu_ld=$lt_cv_prog_gnu_ld
    # Start by getting the version number.  I think the libtool test already
    # does some of this, but throws away the result.
    glibcxx_ld_is_gold=no
+  glibcxx_ld_is_mold=no
    if test x"$with_gnu_ld" = x"yes"; then
      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld version" >&5
  $as_echo_n "checking for ld version... " >&6; }
  
      if $LD --version 2>/dev/null | grep 'GNU gold' >/dev/null 2>&1; then
        glibcxx_ld_is_gold=yes
+    elif $LD --version 2>/dev/null | grep 'mold' >/dev/null 2>&1; then
+      glibcxx_ld_is_mold=yes
      fi
      ldver=`$LD --version 2>/dev/null |
  	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
@@ -22175,7 +22178,7 @@ $as_echo "$glibcxx_gnu_ld_version" >&6; }
  
    # Set --gc-sections.
    glibcxx_have_gc_sections=no
-  if test "$glibcxx_ld_is_gold" = "yes"; then
+  if test "$glibcxx_ld_is_gold" = "yes" || test "$glibcxx_ld_is_mold" = "yes" ; then
      if $LD --help 2>/dev/null | grep gc-sections >/dev/null 2>&1; then
        glibcxx_have_gc_sections=yes
      fi
@@ -29371,12 +29374,15 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
    # Start by getting the version number.  I think the libtool test already
    # does some of this, but throws away the result.
    glibcxx_ld_is_gold=no
+  glibcxx_ld_is_mold=no
    if test x"$with_gnu_ld" = x"yes"; then
      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld version" >&5
  $as_echo_n "checking for ld version... " >&6; }
  
      if $LD --version 2>/dev/null | grep 'GNU gold' >/dev/null 2>&1; then
        glibcxx_ld_is_gold=yes
+    elif $LD --version 2>/dev/null | grep 'mold' >/dev/null 2>&1; then
+      glibcxx_ld_is_mold=yes
      fi
      ldver=`$LD --version 2>/dev/null |
  	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
@@ -29389,7 +29395,7 @@ $as_echo "$glibcxx_gnu_ld_version" >&6; }
  
    # Set --gc-sections.
    glibcxx_have_gc_sections=no
-  if test "$glibcxx_ld_is_gold" = "yes"; then
+  if test "$glibcxx_ld_is_gold" = "yes" || test "$glibcxx_ld_is_mold" = "yes" ; then
      if $LD --help 2>/dev/null | grep gc-sections >/dev/null 2>&1; then
        glibcxx_have_gc_sections=yes
      fi
@@ -35303,12 +35309,15 @@ done
    # Start by getting the version number.  I think the libtool test already
    # does some of this, but throws away the result.
    glibcxx_ld_is_gold=no
+  glibcxx_ld_is_mold=no
    if test x"$with_gnu_ld" = x"yes"; then
      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld version" >&5
  $as_echo_n "checking for ld version... " >&6; }
  
      if $LD --version 2>/dev/null | grep 'GNU gold' >/dev/null 2>&1; then
        glibcxx_ld_is_gold=yes
+    elif $LD --version 2>/dev/null | grep 'mold' >/dev/null 2>&1; then
+      glibcxx_ld_is_mold=yes
      fi
      ldver=`$LD --version 2>/dev/null |
  	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
@@ -35321,7 +35330,7 @@ $as_echo "$glibcxx_gnu_ld_version" >&6; }
  
    # Set --gc-sections.
    glibcxx_have_gc_sections=no
-  if test "$glibcxx_ld_is_gold" = "yes"; then
+  if test "$glibcxx_ld_is_gold" = "yes" || test "$glibcxx_ld_is_mold" = "yes" ; then
      if $LD --help 2>/dev/null | grep gc-sections >/dev/null 2>&1; then
        glibcxx_have_gc_sections=yes
      fi
@@ -47234,12 +47243,15 @@ done
    # Start by getting the version number.  I think the libtool test already
    # does some of this, but throws away the result.
    glibcxx_ld_is_gold=no
+  glibcxx_ld_is_mold=no
    if test x"$with_gnu_ld" = x"yes"; then
      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld version" >&5
  $as_echo_n "checking for ld version... " >&6; }
  
      if $LD --version 2>/dev/null | grep 'GNU gold' >/dev/null 2>&1; then
        glibcxx_ld_is_gold=yes
+    elif $LD --version 2>/dev/null | grep 'mold' >/dev/null 2>&1; then
+      glibcxx_ld_is_mold=yes
      fi
      ldver=`$LD --version 2>/dev/null |
  	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
@@ -47252,7 +47264,7 @@ $as_echo "$glibcxx_gnu_ld_version" >&6; }
  
    # Set --gc-sections.
    glibcxx_have_gc_sections=no
-  if test "$glibcxx_ld_is_gold" = "yes"; then
+  if test "$glibcxx_ld_is_gold" = "yes" || test "$glibcxx_ld_is_mold" = "yes" ; then
      if $LD --help 2>/dev/null | grep gc-sections >/dev/null 2>&1; then
        glibcxx_have_gc_sections=yes
      fi
@@ -47519,12 +47531,15 @@ done
    # Start by getting the version number.  I think the libtool test already
    # does some of this, but throws away the result.
    glibcxx_ld_is_gold=no
+  glibcxx_ld_is_mold=no
    if test x"$with_gnu_ld" = x"yes"; then
      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld version" >&5
  $as_echo_n "checking for ld version... " >&6; }
  
      if $LD --version 2>/dev/null | grep 'GNU gold' >/dev/null 2>&1; then
        glibcxx_ld_is_gold=yes
+    elif $LD --version 2>/dev/null | grep 'mold' >/dev/null 2>&1; then
+      glibcxx_ld_is_mold=yes
      fi
      ldver=`$LD --version 2>/dev/null |
  	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
@@ -47537,7 +47552,7 @@ $as_echo "$glibcxx_gnu_ld_version" >&6; }
  
    # Set --gc-sections.
    glibcxx_have_gc_sections=no
-  if test "$glibcxx_ld_is_gold" = "yes"; then
+  if test "$glibcxx_ld_is_gold" = "yes" || test "$glibcxx_ld_is_mold" = "yes" ; then
      if $LD --help 2>/dev/null | grep gc-sections >/dev/null 2>&1; then
        glibcxx_have_gc_sections=yes
      fi
@@ -47995,12 +48010,15 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
    # Start by getting the version number.  I think the libtool test already
    # does some of this, but throws away the result.
    glibcxx_ld_is_gold=no
+  glibcxx_ld_is_mold=no
    if test x"$with_gnu_ld" = x"yes"; then
      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld version" >&5
  $as_echo_n "checking for ld version... " >&6; }
  
      if $LD --version 2>/dev/null | grep 'GNU gold' >/dev/null 2>&1; then
        glibcxx_ld_is_gold=yes
+    elif $LD --version 2>/dev/null | grep 'mold' >/dev/null 2>&1; then
+      glibcxx_ld_is_mold=yes
      fi
      ldver=`$LD --version 2>/dev/null |
  	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
@@ -48013,7 +48031,7 @@ $as_echo "$glibcxx_gnu_ld_version" >&6; }
  
    # Set --gc-sections.
    glibcxx_have_gc_sections=no
-  if test "$glibcxx_ld_is_gold" = "yes"; then
+  if test "$glibcxx_ld_is_gold" = "yes" || test "$glibcxx_ld_is_mold" = "yes" ; then
      if $LD --help 2>/dev/null | grep gc-sections >/dev/null 2>&1; then
        glibcxx_have_gc_sections=yes
      fi
@@ -54383,12 +54401,15 @@ _ACEOF
    # Start by getting the version number.  I think the libtool test already
    # does some of this, but throws away the result.
    glibcxx_ld_is_gold=no
+  glibcxx_ld_is_mold=no
    if test x"$with_gnu_ld" = x"yes"; then
      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld version" >&5
  $as_echo_n "checking for ld version... " >&6; }
  
      if $LD --version 2>/dev/null | grep 'GNU gold' >/dev/null 2>&1; then
        glibcxx_ld_is_gold=yes
+    elif $LD --version 2>/dev/null | grep 'mold' >/dev/null 2>&1; then
+      glibcxx_ld_is_mold=yes
      fi
      ldver=`$LD --version 2>/dev/null |
  	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
@@ -54401,7 +54422,7 @@ $as_echo "$glibcxx_gnu_ld_version" >&6; }
  
    # Set --gc-sections.
    glibcxx_have_gc_sections=no
-  if test "$glibcxx_ld_is_gold" = "yes"; then
+  if test "$glibcxx_ld_is_gold" = "yes" || test "$glibcxx_ld_is_mold" = "yes" ; then
      if $LD --help 2>/dev/null | grep gc-sections >/dev/null 2>&1; then
        glibcxx_have_gc_sections=yes
      fi
@@ -60531,12 +60552,15 @@ $as_echo "#define HAVE_TLS 1" >>confdefs.h
    # Start by getting the version number.  I think the libtool test already
    # does some of this, but throws away the result.
    glibcxx_ld_is_gold=no
+  glibcxx_ld_is_mold=no
    if test x"$with_gnu_ld" = x"yes"; then
      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld version" >&5
  $as_echo_n "checking for ld version... " >&6; }
  
      if $LD --version 2>/dev/null | grep 'GNU gold' >/dev/null 2>&1; then
        glibcxx_ld_is_gold=yes
+    elif $LD --version 2>/dev/null | grep 'mold' >/dev/null 2>&1; then
+      glibcxx_ld_is_mold=yes
      fi
      ldver=`$LD --version 2>/dev/null |
  	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
@@ -60549,7 +60573,7 @@ $as_echo "$glibcxx_gnu_ld_version" >&6; }
  
    # Set --gc-sections.
    glibcxx_have_gc_sections=no
-  if test "$glibcxx_ld_is_gold" = "yes"; then
+  if test "$glibcxx_ld_is_gold" = "yes" || test "$glibcxx_ld_is_mold" = "yes" ; then
      if $LD --help 2>/dev/null | grep gc-sections >/dev/null 2>&1; then
        glibcxx_have_gc_sections=yes
      fi
@@ -60741,12 +60765,15 @@ done
    # Start by getting the version number.  I think the libtool test already
    # does some of this, but throws away the result.
    glibcxx_ld_is_gold=no
+  glibcxx_ld_is_mold=no
    if test x"$with_gnu_ld" = x"yes"; then
      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld version" >&5
  $as_echo_n "checking for ld version... " >&6; }
  
      if $LD --version 2>/dev/null | grep 'GNU gold' >/dev/null 2>&1; then
        glibcxx_ld_is_gold=yes
+    elif $LD --version 2>/dev/null | grep 'mold' >/dev/null 2>&1; then
+      glibcxx_ld_is_mold=yes
      fi
      ldver=`$LD --version 2>/dev/null |
  	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
@@ -60759,7 +60786,7 @@ $as_echo "$glibcxx_gnu_ld_version" >&6; }
  
    # Set --gc-sections.
    glibcxx_have_gc_sections=no
-  if test "$glibcxx_ld_is_gold" = "yes"; then
+  if test "$glibcxx_ld_is_gold" = "yes" || test "$glibcxx_ld_is_mold" = "yes" ; then
      if $LD --help 2>/dev/null | grep gc-sections >/dev/null 2>&1; then
        glibcxx_have_gc_sections=yes
      fi
@@ -60970,12 +60997,15 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
    # Start by getting the version number.  I think the libtool test already
    # does some of this, but throws away the result.
    glibcxx_ld_is_gold=no
+  glibcxx_ld_is_mold=no
    if test x"$with_gnu_ld" = x"yes"; then
      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld version" >&5
  $as_echo_n "checking for ld version... " >&6; }
  
      if $LD --version 2>/dev/null | grep 'GNU gold' >/dev/null 2>&1; then
        glibcxx_ld_is_gold=yes
+    elif $LD --version 2>/dev/null | grep 'mold' >/dev/null 2>&1; then
+      glibcxx_ld_is_mold=yes
      fi
      ldver=`$LD --version 2>/dev/null |
  	   sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
@@ -60988,7 +61018,7 @@ $as_echo "$glibcxx_gnu_ld_version" >&6; }
  
    # Set --gc-sections.
    glibcxx_have_gc_sections=no
-  if test "$glibcxx_ld_is_gold" = "yes"; then
+  if test "$glibcxx_ld_is_gold" = "yes" || test "$glibcxx_ld_is_mold" = "yes" ; then
      if $LD --help 2>/dev/null | grep gc-sections >/dev/null 2>&1; then
        glibcxx_have_gc_sections=yes
      fi
@@ -74929,6 +74959,8 @@ $as_echo "$as_me: WARNING: === Symbol versioning will be disabled." >&2;}
      enable_symvers=no
    elif test $glibcxx_ld_is_gold = yes ; then
      : All versions of gold support symbol versioning.
+  elif test $glibcxx_ld_is_mold = yes ; then
+    : All versions of mold support symbol versioning.
    elif test $glibcxx_gnu_ld_version -lt $glibcxx_min_gnu_ld_version ; then
      # The right tools, the right setup, but too old.  Fallbacks?
      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: === Linker version $glibcxx_gnu_ld_version is too old for" >&5
-- 
2.34.1



More information about the Gcc-patches mailing list