This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Enable building glibc with gold.


In BZ#14995 (http://sourceware.org/bugzilla/show_bug.cgi?id=14995)
we have a request to build glibc with ld.bfd even if gold 
is the default linker.

I'd like to do the opposite and instead enable building 
glibc with either ld or gold.

There are two conditions that that will prevent glibc from 
being built with gold:

(a) libc_cv_use_default_link = no.

In Makerules if use-default-link is not `yes' then the
linker is run with --verbose and the expected output of
the builtin linker script is used to auto-generate a
modified linker script suitable for shared links.
The requirement that the linker support printing a
builtin linker script via --verbose is not supported 
by gold.

The value of use-default-link comes from configure.in's
libc_cv_use_default_link and may be set by the user via
--with/without-default-link or may be auto-detected by 
configure by testing a shared link.

gold version 1.11, which I've tested with, is sufficiently
new that it produces a usable shared link and without
user settings will automatically set use_default_link to 
`yes' without the need to fall back to editing builtin 
linker scripts.

(b) libc_cv_output_format = unknown.

The linker is run with --print-output-format, and if we
are unable to parse the output we set libc_cv_output_format
to `unknown'.

If libc_cv_output_format is set to `unknown',
will fall back on parsing the output of the builtin linker
script to guess the format. This fails since gold has no
builtin linker script.

gold version 1.11 supports --print-output-format
and thus sets libc_cv_output_format to a non-"unknown"
value e.g. elf64-x86-64 for x86-64.

With gold version 1.11 (a) and (b) do not appear to be
an issue and I can successfully build glibc using gold.

There are 7 regressions when using gold:

make[2]: *** [/home/carlos/build/glibc/nptl/tst-cancel21-static.out] Error 1
make[2]: *** [/home/carlos/build/glibc/nptl/tst-cancel24-static.out] Error 1
make[2]: *** [/home/carlos/build/glibc/nptl/tst-cond8-static.out] Error 1
make[2]: *** [/home/carlos/build/glibc/nptl/tst-mutex8-static.out] Error 1
make[2]: *** [/home/carlos/build/glibc/nptl/tst-mutexpi8-static.out] Error 1
make[2]: *** [/home/carlos/build/glibc/nptl/tst-sem11-static.out] Error 134
make[2]: *** [/home/carlos/build/glibc/nptl/tst-sem12-static.out] Error 134

Which leave us with two courses of action:

(1) Don't support building with gold.

Given that there are regressions we should not
support building with gold at all. Knowing that
downstream distributions and users might build 
glibc with gold and ignore the testsuite results.

(2) Support building with gold.

Enable building with gold in order to help 
minimize the work required to test building with
gold. Downstream distributions can switch the system
default to gold and start diagnosing failures. As
a counter-point to (1) Debian's build system will 
fail a package build if regressions are detected in
the testsuite (prevents a gold build from being uploaded).

I'm inclined strongly to (2) because it enables developer
choice and makes it easier to test "new" technology.

The inlined patch does the following:

- Supports building glibc with gold 1.11 or newer.
  - gold 1.11 is an arbitrary choice based on my testing.
- Prevents the use of gold if libc_cv_use_default_link = no.
  e.g. --without-default-link and gold will print an error.
- Prevents the use of gold if libc_cv_output_format = unknown.

Comments re. (1) or (2)?

OK to commit?

Tested on x86_64 with ld.bfd, no regressions.

Tested on x86_64 with ld.gold, 7 regressions (see above).
I have not looked at the failures, but the fact that they are all
failures in statically linked applications indicates a pattern.

2013-01-08  Carlos O'Donell  <codonell@redhat.com>

	* configure.in: Check for gold 1.11 or newer. Don't use gold if 
	use_default_link=no or libc_cv_output_format=unknown.
	* configure: Regenerate.

diff --git a/configure.in b/configure.in
index d369382..38ff3cd 100644
--- a/configure.in
+++ b/configure.in
@@ -924,9 +924,25 @@ AC_SUBST(MIG)dnl Needed by sysdeps/mach/configure.in
 AC_CHECK_PROG_VER(AS, $AS, --version,
 		  [GNU assembler.* \([0-9]*\.[0-9.]*\)],
 		  [2.1[0-9][0-9]*|2.[2-9][0-9]*|[3-9].*|[1-9][0-9]*], AS=: critic_missing="$critic_missing as")
-AC_CHECK_PROG_VER(LD, $LD, --version,
+LD_BFD=
+LD_GOLD=
+ld_is_gold="`$LD --version | sed -n 's/^GNU \(gold\).*$/\1/p'`"
+if test -z "$ld_is_gold"; then
+  LD_BFD=$LD
+  AC_CHECK_PROG_VER(LD_BFD, $LD_BFD, --version,
 		  [GNU ld.* \([0-9][0-9]*\.[0-9.]*\)],
-		  [2.1[0-9][0-9]*|2.[2-9][0-9]*|[3-9].*|[1-9][0-9]*], LD=: critic_missing="$critic_missing ld")
+		  [2.1[0-9][0-9]*|2.[2-9][0-9]*|[3-9].*|[1-9][0-9]*],LD_BFD=:)
+else
+# Accept gold 1.11 or higher.
+  LD_GOLD=$LD
+  AC_CHECK_PROG_VER(LD_GOLD, $LD_GOLD, --version,
+		  [GNU gold.* \([0-9][0-9]*\.[0-9.]*\)],
+		  [1.1[1-9]*|1.[2-9][0-9]*|1.1[0-9][0-9]*|[2-9].*|[1-9][0-9]*],LD_GOLD=:)
+fi
+# Neither ld nor gold are new enough.
+if test -z "$LD_BFD" && test -z "$LD_GOLD"; then
+  critic_missing="$critic_missing ld"
+fi
 
 # These programs are version sensitive.
 AC_CHECK_TOOL_PREFIX
@@ -1635,6 +1651,16 @@ $ac_try"
   use_default_link=$libc_cv_use_default_link
 fi
 
+# The gold linker has no builtin default linker script,
+# and the fallback of editing the builtin linker
+# script is not available. Therefore if use_default_link
+# is `no' then we can't use gold. This check is independent
+# of gold's version and is used to sanity check that the
+# linker continues to produce a useful shared link.
+if test "$ld_is_gold" && test "$use_default_link" = "no"; then
+  AC_MSG_ERROR([$LD did not generate a useful shared link. Try using GNU ld.bfd?])
+fi
+
 AC_CACHE_CHECK(linker output format, libc_cv_output_format, [dnl
 if libc_cv_output_format=`
 ${CC-cc} -nostartfiles -nostdlib -Wl,--print-output-format 2>&AS_MESSAGE_LOG_FD`
@@ -1646,6 +1672,17 @@ fi
 test -n "$libc_cv_output_format" || libc_cv_output_format=unknown])
 AC_SUBST(libc_cv_output_format)
 
+# The gold linker has no builtin default linker script,
+# and the fallback of parsing the builtin linker
+# script to determine the target is not available.
+# Therefore if libc_cv_output_format is `unknown' then
+# we can't use gold. This check is independent of gold's
+# version and is used to sanity check that the linker
+# continues to support --print-output-format.
+if test "$ld_is_gold" && test "$libc_cv_output_format" = "unknown"; then
+  AC_MSG_ERROR([$LD did not support --print-output-format. Try using GNU ld.bfd?])
+fi
+
 AC_CACHE_CHECK(for -fno-toplevel-reorder -fno-section-anchors, libc_cv_fno_toplevel_reorder, [dnl
 cat > conftest.c <<EOF
 int foo;
---

Cheers,
Carlos.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]