[1/3] configure: Allow LD to be a linker other than GNU ld and gold

Message ID 20201228194855.510315-2-maskray@google.com
State Superseded
Headers
Series Make glibc build with LLD |

Commit Message

Fangrui Song Dec. 28, 2020, 7:48 p.m. UTC
  When using lld as the linker, configure prints a confusing message.

*** These critical programs are missing or too old: GNU ld

lld>=8 can build glibc with very few patches. lld may be built with a
custom version information (e.g. git commit ID), so a version check is not
useful at all.
---
 configure    | 13 ++++++++-----
 configure.ac | 13 ++++++++-----
 2 files changed, 16 insertions(+), 10 deletions(-)
  

Comments

H.J. Lu Dec. 28, 2020, 8:46 p.m. UTC | #1
On Mon, Dec 28, 2020 at 11:49 AM Fangrui Song via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
> When using lld as the linker, configure prints a confusing message.
>
> *** These critical programs are missing or too old: GNU ld
>
> lld>=8 can build glibc with very few patches. lld may be built with a
> custom version information (e.g. git commit ID), so a version check is not
> useful at all.

But not all versions of lld can be used to build glibc.  Please find a way
to check the working lld version.

> ---
>  configure    | 13 ++++++++-----
>  configure.ac | 13 ++++++++-----
>  2 files changed, 16 insertions(+), 10 deletions(-)
>
> diff --git a/configure b/configure
> index 6a35553805..6dcd2270f8 100755
> --- a/configure
> +++ b/configure
> @@ -4601,9 +4601,10 @@ if test $ac_verc_fail = yes; then
>  fi
>
>
> -if test -n "`$LD --version | sed -n 's/^GNU \(gold\).*$/\1/p'`"; then
> +case $($LD --version) in
> +  "GNU gold"*)
>    # Accept gold 1.14 or higher
> -  for ac_prog in $LD
> +    for ac_prog in $LD
>  do
>    # Extract the first word of "$ac_prog", so it can be a program name with args.
>  set dummy $ac_prog; ac_word=$2
> @@ -4666,8 +4667,9 @@ if test $ac_verc_fail = yes; then
>    LD=: critic_missing="$critic_missing GNU gold"
>  fi
>
> -else
> -  for ac_prog in $LD
> +    ;;
> +  "GNU ld"*)
> +    for ac_prog in $LD
>  do
>    # Extract the first word of "$ac_prog", so it can be a program name with args.
>  set dummy $ac_prog; ac_word=$2
> @@ -4730,7 +4732,8 @@ if test $ac_verc_fail = yes; then
>    LD=: critic_missing="$critic_missing GNU ld"
>  fi
>
> -fi
> +    ;;
> +esac
>
>  # These programs are version sensitive.
>
> diff --git a/configure.ac b/configure.ac
> index 43cfac9d48..1a2054cd1a 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -979,18 +979,21 @@ AC_CHECK_PROG_VER(AS, $AS, --version,
>                   [2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
>                   AS=: critic_missing="$critic_missing as")
>
> -if test -n "`$LD --version | sed -n 's/^GNU \(gold\).*$/\1/p'`"; then
> +case $($LD --version) in
> +  "GNU gold"*)
>    # Accept gold 1.14 or higher
> -  AC_CHECK_PROG_VER(LD, $LD, --version,
> +    AC_CHECK_PROG_VER(LD, $LD, --version,
>                     [GNU gold.* \([0-9][0-9]*\.[0-9.]*\)],
>                     [1.1[4-9]*|1.[2-9][0-9]*|1.1[0-9][0-9]*|[2-9].*|[1-9][0-9]*],
>                     LD=: critic_missing="$critic_missing GNU gold")
> -else
> -  AC_CHECK_PROG_VER(LD, $LD, --version,
> +    ;;
> +  "GNU ld"*)
> +    AC_CHECK_PROG_VER(LD, $LD, --version,
>                     [GNU ld.* \([0-9][0-9]*\.[0-9.]*\)],
>                     [2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
>                     LD=: critic_missing="$critic_missing GNU ld")
> -fi
> +    ;;
> +esac
>
>  # These programs are version sensitive.
>  AC_CHECK_TOOL_PREFIX
> --
> 2.29.2.729.g45daf8777d-goog
>
  

Patch

diff --git a/configure b/configure
index 6a35553805..6dcd2270f8 100755
--- a/configure
+++ b/configure
@@ -4601,9 +4601,10 @@  if test $ac_verc_fail = yes; then
 fi
 
 
-if test -n "`$LD --version | sed -n 's/^GNU \(gold\).*$/\1/p'`"; then
+case $($LD --version) in
+  "GNU gold"*)
   # Accept gold 1.14 or higher
-  for ac_prog in $LD
+    for ac_prog in $LD
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
@@ -4666,8 +4667,9 @@  if test $ac_verc_fail = yes; then
   LD=: critic_missing="$critic_missing GNU gold"
 fi
 
-else
-  for ac_prog in $LD
+    ;;
+  "GNU ld"*)
+    for ac_prog in $LD
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
@@ -4730,7 +4732,8 @@  if test $ac_verc_fail = yes; then
   LD=: critic_missing="$critic_missing GNU ld"
 fi
 
-fi
+    ;;
+esac
 
 # These programs are version sensitive.
 
diff --git a/configure.ac b/configure.ac
index 43cfac9d48..1a2054cd1a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -979,18 +979,21 @@  AC_CHECK_PROG_VER(AS, $AS, --version,
 		  [2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
 		  AS=: critic_missing="$critic_missing as")
 
-if test -n "`$LD --version | sed -n 's/^GNU \(gold\).*$/\1/p'`"; then
+case $($LD --version) in
+  "GNU gold"*)
   # Accept gold 1.14 or higher
-  AC_CHECK_PROG_VER(LD, $LD, --version,
+    AC_CHECK_PROG_VER(LD, $LD, --version,
 		    [GNU gold.* \([0-9][0-9]*\.[0-9.]*\)],
 		    [1.1[4-9]*|1.[2-9][0-9]*|1.1[0-9][0-9]*|[2-9].*|[1-9][0-9]*],
 		    LD=: critic_missing="$critic_missing GNU gold")
-else
-  AC_CHECK_PROG_VER(LD, $LD, --version,
+    ;;
+  "GNU ld"*)
+    AC_CHECK_PROG_VER(LD, $LD, --version,
 		    [GNU ld.* \([0-9][0-9]*\.[0-9.]*\)],
 		    [2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
 		    LD=: critic_missing="$critic_missing GNU ld")
-fi
+    ;;
+esac
 
 # These programs are version sensitive.
 AC_CHECK_TOOL_PREFIX