[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#535237: binutils: Please enable --build-id in ld by default



Matthias Klose wrote:
> Emilio Pozuelo Monfort schrieb:
>> I'll look into gcc-4.4 and gcc-4.3 next.

OK, here they are.

I've tested both only on i386 (I don't have any other arch right now). They seem
to work fine (pass build-id by default, can be overridden with
-Wl,--build-id=none). I've also put gcc-4.3 in my chroot and built a couple of
packages (rarian and libsoup2.4), both built successfully.

The patch is the same from gcc trunk, not the one Fedora uses.

How do they look?

Thanks,
Emilio
diff -u gcc-4.3-4.3.3/debian/changelog gcc-4.3-4.3.3/debian/changelog
--- gcc-4.3-4.3.3/debian/changelog
+++ gcc-4.3-4.3.3/debian/changelog
@@ -1,3 +1,12 @@
+gcc-4.3 (4.3.3-14) UNRELEASED; urgency=low
+
+  * debian/patches/gcc-build-id.dpatch, debian/rules.patch:
+    Backport change from trunk to pass --build-id to the linker
+    when it supports it.
+  * debian/rules2: Build with --enable-linker-build-id.
+
+ -- Emilio Pozuelo Monfort <pochu@ubuntu.com>  Sat, 11 Jul 2009 00:55:51 +0200
+
 gcc-4.3 (4.3.3-13) unstable; urgency=low
 
   * Update to SVN 20090625 from the gcc-4_3-branch.
diff -u gcc-4.3-4.3.3/debian/rules2 gcc-4.3-4.3.3/debian/rules2
--- gcc-4.3-4.3.3/debian/rules2
+++ gcc-4.3-4.3.3/debian/rules2
@@ -176,6 +176,7 @@
 	--prefix=/$(PF) \
 	--enable-shared \
 	--enable-multiarch \
+	--enable-linker-build-id \
 	--with-system-zlib \
 
 ifneq ($(PKGSOURCE),gcc-snapshot)
diff -u gcc-4.3-4.3.3/debian/rules.patch gcc-4.3-4.3.3/debian/rules.patch
--- gcc-4.3-4.3.3/debian/rules.patch
+++ gcc-4.3-4.3.3/debian/rules.patch
@@ -34,6 +34,7 @@
 	gcc-textdomain \
 	gcc-driver-extra-langs \
 	gcc-hash-style-both \
+	gcc-build-id \
 	libstdc++-pic \
 	libstdc++-doclink \
 	libobjc-gc-link \
only in patch2:
unchanged:
--- gcc-4.3-4.3.3.orig/debian/patches/gcc-build-id.dpatch
+++ gcc-4.3-4.3.3/debian/patches/gcc-build-id.dpatch
@@ -0,0 +1,139 @@
+#! /bin/sh -e
+
+# DP: Link with --build-id when the linker supports it
+
+dir=
+if [ $# -eq 3 -a "$2" = '-d' ]; then
+    pdir="-d $3"
+    dir="$3/"
+elif [ $# -ne 1 ]; then
+    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+case "$1" in
+    -patch)
+        patch $pdir -f --no-backup-if-mismatch -p0 < $0
+        ;;
+    -unpatch)
+        patch $pdir -f --no-backup-if-mismatch -R -p0 < $0
+        ;;
+    *)
+        echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+        exit 1
+esac
+exit 0
+
+Index: gcc/c-common.c
+
+Index: gcc/configure.ac
+===================================================================
+--- gcc/configure.ac	(revision 146981)
++++ gcc/configure.ac	(working copy)
+@@ -3510,6 +3510,41 @@
+     ;;
+ esac
+ 
++AC_CACHE_CHECK(linker --build-id support,
++  gcc_cv_ld_buildid,
++  [gcc_cv_ld_buildid=no
++  if test $in_tree_ld = yes ; then
++    if test "$gcc_cv_gld_major_version" -eq 2 -a \
++       "$gcc_cv_gld_minor_version" -ge 18 -o \
++       "$gcc_cv_gld_major_version" -gt 2 \
++       && test $in_tree_ld_is_elf = yes; then
++      gcc_cv_ld_buildid=yes
++    fi
++  elif test x$gcc_cv_ld != x; then
++    if $gcc_cv_ld --help 2>/dev/null | grep build-id > /dev/null; then
++      gcc_cv_ld_buildid=yes
++    fi
++  fi])
++if test x"$gcc_cv_ld_buildid" = xyes; then
++  AC_DEFINE(HAVE_LD_BUILDID, 1,
++  [Define if your linker supports --build-id.])
++fi
++
++AC_ARG_ENABLE(linker-build-id,
++[  --enable-linker-build-id
++                          compiler will always pass --build-id to linker],
++[],
++enable_linker_build_id=no)
++
++if test x"$enable_linker_build_id" = xyes; then
++  if test x"$gcc_cv_ld_buildid" = xyes; then
++    AC_DEFINE(ENABLE_LD_BUILDID, 1,
++    [Define if gcc should always pass --build-id to linker.])
++  else
++    AC_MSG_WARN(--build-id is not supported by your linker; --enable-linker-build-id ignored)
++  fi
++fi
++
+ AC_CACHE_CHECK(linker --sysroot support,
+   gcc_cv_ld_sysroot,
+   [gcc_cv_ld_sysroot=no
+Index: gcc/gcc.c
+===================================================================
+--- gcc/gcc.c	(revision 146981)
++++ gcc/gcc.c	(working copy)
+@@ -730,6 +730,13 @@
+ #endif
+ #endif
+ 
++#ifndef LINK_BUILDID_SPEC
++# if defined(HAVE_LD_BUILDID) && defined(ENABLE_LD_BUILDID)
++#  define LINK_BUILDID_SPEC "%{!r:--build-id} "
++# endif
++#endif
++
++
+ /* -u* was put back because both BSD and SysV seem to support it.  */
+ /* %{static:} simply prevents an error message if the target machine
+    doesn't handle -static.  */
+@@ -1844,9 +1851,16 @@
+     asm_spec = XOBFINISH (&obstack, const char *);
+   }
+ #endif
+-#ifdef LINK_EH_SPEC
++
++#if defined LINK_EH_SPEC || defined LINK_BUILDID_SPEC
++# ifdef LINK_BUILDID_SPEC
++  /* Prepend LINK_BUILDID_SPEC to whatever link_spec we had before.  */
++  obstack_grow (&obstack, LINK_BUILDID_SPEC, sizeof(LINK_BUILDID_SPEC) - 1);
++# endif
++# ifdef LINK_EH_SPEC
+   /* Prepend LINK_EH_SPEC to whatever link_spec we had before.  */
+   obstack_grow (&obstack, LINK_EH_SPEC, sizeof(LINK_EH_SPEC) - 1);
++# endif
+   obstack_grow0 (&obstack, link_spec, strlen (link_spec));
+   link_spec = XOBFINISH (&obstack, const char *);
+ #endif
+Index: gcc/config.in
+===================================================================
+--- gcc/config.in	(revision 146981)
++++ gcc/config.in	(working copy)
+@@ -101,6 +101,12 @@
+ #endif
+ 
+ 
++/* Define if gcc should always pass --build-id to linker. */
++#ifndef USED_FOR_TARGET
++#undef ENABLE_LD_BUILDID
++#endif
++
++
+ /* Define to 1 if translation of program messages to the user's native
+    language is requested. */
+ #ifndef USED_FOR_TARGET
+@@ -1025,6 +1031,12 @@
+ #endif
+ 
+ 
++/* Define if your linker supports --build-id. */
++#ifndef USED_FOR_TARGET
++#undef HAVE_LD_BUILDID
++#endif
++
++
+ /* Define if your linker supports --demangle option. */
+ #ifndef USED_FOR_TARGET
+ #undef HAVE_LD_DEMANGLE
diff -u gcc-4.4-4.4.0/debian/changelog gcc-4.4-4.4.0/debian/changelog
--- gcc-4.4-4.4.0/debian/changelog
+++ gcc-4.4-4.4.0/debian/changelog
@@ -1,3 +1,12 @@
+gcc-4.4 (4.4.0-11) UNRELEASED; urgency=low
+
+  * debian/patches/gcc-build-id.diff, debian/rules.patch:
+    Backport change from trunk to pass --build-id to the linker
+    when it supports it.
+  * debian/rules2: Build with --enable-linker-build-id.
+
+ -- Emilio Pozuelo Monfort <pochu@ubuntu.com>  Fri, 10 Jul 2009 20:21:26 +0200
+
 gcc-4.4 (4.4.0-10) unstable; urgency=low
 
   [ Arthur Loiret ]
diff -u gcc-4.4-4.4.0/debian/rules2 gcc-4.4-4.4.0/debian/rules2
--- gcc-4.4-4.4.0/debian/rules2
+++ gcc-4.4-4.4.0/debian/rules2
@@ -122,6 +122,7 @@
 	--prefix=/$(PF) \
 	--enable-shared \
 	--enable-multiarch \
+	--enable-linker-build-id \
 	--with-system-zlib \
 
 ifneq ($(PKGSOURCE),gcc-snapshot)
diff -u gcc-4.4-4.4.0/debian/rules.patch gcc-4.4-4.4.0/debian/rules.patch
--- gcc-4.4-4.4.0/debian/rules.patch
+++ gcc-4.4-4.4.0/debian/rules.patch
@@ -32,6 +32,7 @@
 	gcc-textdomain \
 	gcc-driver-extra-langs \
 	gcc-hash-style-both \
+	gcc-build-id \
 	libstdc++-pic \
 	libstdc++-doclink \
 	libstdc++-man-3cxx \
only in patch2:
unchanged:
--- gcc-4.4-4.4.0.orig/debian/patches/gcc-build-id.diff
+++ gcc-4.4-4.4.0/debian/patches/gcc-build-id.diff
@@ -0,0 +1,112 @@
+Index: a/src/gcc/configure.ac
+===================================================================
+--- a/src/gcc/configure.ac	(revision 146981)
++++ b/src/gcc/configure.ac	(working copy)
+@@ -3510,6 +3510,41 @@
+     ;;
+ esac
+ 
++AC_CACHE_CHECK(linker --build-id support,
++  gcc_cv_ld_buildid,
++  [gcc_cv_ld_buildid=no
++  if test $in_tree_ld = yes ; then
++    if test "$gcc_cv_gld_major_version" -eq 2 -a \
++       "$gcc_cv_gld_minor_version" -ge 18 -o \
++       "$gcc_cv_gld_major_version" -gt 2 \
++       && test $in_tree_ld_is_elf = yes; then
++      gcc_cv_ld_buildid=yes
++    fi
++  elif test x$gcc_cv_ld != x; then
++    if $gcc_cv_ld --help 2>/dev/null | grep build-id > /dev/null; then
++      gcc_cv_ld_buildid=yes
++    fi
++  fi])
++if test x"$gcc_cv_ld_buildid" = xyes; then
++  AC_DEFINE(HAVE_LD_BUILDID, 1,
++  [Define if your linker supports --build-id.])
++fi
++
++AC_ARG_ENABLE(linker-build-id,
++[  --enable-linker-build-id
++                          compiler will always pass --build-id to linker],
++[],
++enable_linker_build_id=no)
++
++if test x"$enable_linker_build_id" = xyes; then
++  if test x"$gcc_cv_ld_buildid" = xyes; then
++    AC_DEFINE(ENABLE_LD_BUILDID, 1,
++    [Define if gcc should always pass --build-id to linker.])
++  else
++    AC_MSG_WARN(--build-id is not supported by your linker; --enable-linker-build-id ignored)
++  fi
++fi
++
+ AC_CACHE_CHECK(linker --sysroot support,
+   gcc_cv_ld_sysroot,
+   [gcc_cv_ld_sysroot=no
+Index: a/src/gcc/gcc.c
+===================================================================
+--- a/src/gcc/gcc.c	(revision 146981)
++++ b/src/gcc/gcc.c	(working copy)
+@@ -730,6 +730,13 @@
+ #endif
+ #endif
+ 
++#ifndef LINK_BUILDID_SPEC
++# if defined(HAVE_LD_BUILDID) && defined(ENABLE_LD_BUILDID)
++#  define LINK_BUILDID_SPEC "%{!r:--build-id} "
++# endif
++#endif
++
++
+ /* -u* was put back because both BSD and SysV seem to support it.  */
+ /* %{static:} simply prevents an error message if the target machine
+    doesn't handle -static.  */
+@@ -1844,9 +1851,16 @@
+     asm_spec = XOBFINISH (&obstack, const char *);
+   }
+ #endif
+-#ifdef LINK_EH_SPEC
++
++#if defined LINK_EH_SPEC || defined LINK_BUILDID_SPEC
++# ifdef LINK_BUILDID_SPEC
++  /* Prepend LINK_BUILDID_SPEC to whatever link_spec we had before.  */
++  obstack_grow (&obstack, LINK_BUILDID_SPEC, sizeof(LINK_BUILDID_SPEC) - 1);
++# endif
++# ifdef LINK_EH_SPEC
+   /* Prepend LINK_EH_SPEC to whatever link_spec we had before.  */
+   obstack_grow (&obstack, LINK_EH_SPEC, sizeof(LINK_EH_SPEC) - 1);
++# endif
+   obstack_grow0 (&obstack, link_spec, strlen (link_spec));
+   link_spec = XOBFINISH (&obstack, const char *);
+ #endif
+Index: a/src/gcc/config.in
+===================================================================
+--- a/src/gcc/config.in	(revision 146981)
++++ b/src/gcc/config.in	(working copy)
+@@ -101,6 +101,12 @@
+ #endif
+ 
+ 
++/* Define if gcc should always pass --build-id to linker. */
++#ifndef USED_FOR_TARGET
++#undef ENABLE_LD_BUILDID
++#endif
++
++
+ /* Define to 1 if translation of program messages to the user's native
+    language is requested. */
+ #ifndef USED_FOR_TARGET
+@@ -1025,6 +1031,12 @@
+ #endif
+ 
+ 
++/* Define if your linker supports --build-id. */
++#ifndef USED_FOR_TARGET
++#undef HAVE_LD_BUILDID
++#endif
++
++
+ /* Define if your linker supports --demangle option. */
+ #ifndef USED_FOR_TARGET
+ #undef HAVE_LD_DEMANGLE

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: