From: ppluzhnikov@google.com (Paul Pluzhnikov)
To: gcc-patches@sourceware.org
Cc: satorux@google.com, iant@google.com, ppluzhnikov@google.com
Subject: [patch] make default linker --hash-style configurable option
Date: Mon, 04 Apr 2011 18:17:00 -0000 [thread overview]
Message-ID: <20110404181738.52D661909EB@elbrus2.mtv.corp.google.com> (raw)
Greetings,
Several Linux distributions (e.g. Fedora) carry local patches that turn
on --hash-style=gnu for all links.
Attached is a proposed patch (originally by Satoru Takabayashi) that makes
default hash style a configure option.
Tested by doing native bootstrap and verifying that no --hash-style is
passed to the linker, and also configuring with --with-linker-hash-style=gnu
and verifying that --hash-style=gnu is then passed to the linker.
Ok for trunk?
Thanks,
P.S. Google has a blanket copyright assignment to FSF.
--
Paul Pluzhnikov
2011-04-04 Satoru Takabayashi <satorux@google.com>
Paul Pluzhnikov <ppluzhnikov@google.com>
* gcc/doc/install.texi (Configuration): Document
--with-linker-hash-style.
* gcc/gcc.c (init_spec): Handle LINKER_HASH_STYLE.
* gcc/config.in: Add LINKER_HASH_STYLE.
* gcc/configure.ac: Add --with-linker-hash-style.
* gcc/configure: Regenerate.
Index: gcc/doc/install.texi
===================================================================
--- gcc/doc/install.texi (revision 171942)
+++ gcc/doc/install.texi (working copy)
@@ -1657,6 +1657,11 @@
support @option{--build-id} option, a warning is issued and the
@option{--enable-linker-build-id} option is ignored. The default is off.
+@item --with-linker-hash-style=@var{choice}
+Tells GCC to pass @option{--hash-style=@var{choice}} option to the
+linker for all final links. @var{choice} can be one of
+@samp{sysv}, @samp{gnu}, and @samp{both} where @samp{sysv} is the default.
+
@item --enable-gnu-unique-object
@itemx --disable-gnu-unique-object
Tells GCC to use the gnu_unique_object relocation for C++ template
Index: gcc/gcc.c
===================================================================
--- gcc/gcc.c (revision 171942)
+++ gcc/gcc.c (working copy)
@@ -1438,7 +1438,8 @@
}
#endif
-#if defined LINK_EH_SPEC || defined LINK_BUILDID_SPEC
+#if defined LINK_EH_SPEC || defined LINK_BUILDID_SPEC || \
+ defined LINKER_HASH_STYLE
# 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);
@@ -1447,6 +1448,16 @@
/* Prepend LINK_EH_SPEC to whatever link_spec we had before. */
obstack_grow (&obstack, LINK_EH_SPEC, sizeof(LINK_EH_SPEC) - 1);
# endif
+# ifdef LINKER_HASH_STYLE
+ /* Prepend --hash-style=LINKER_HASH_STYLE to whatever link_spec we had
+ before. */
+ {
+ static const char hash_style[] = "--hash-style=";
+ obstack_grow (&obstack, hash_style, sizeof(hash_style) - 1);
+ obstack_grow (&obstack, LINKER_HASH_STYLE, sizeof(LINKER_HASH_STYLE) - 1);
+ obstack_1grow (&obstack, ' ');
+ }
+# endif
obstack_grow0 (&obstack, link_spec, strlen (link_spec));
link_spec = XOBFINISH (&obstack, const char *);
#endif
Index: gcc/config.in
===================================================================
--- gcc/config.in (revision 171942)
+++ gcc/config.in (working copy)
@@ -1580,6 +1580,12 @@
#endif
+/* The linker hash style */
+#ifndef USED_FOR_TARGET
+#undef LINKER_HASH_STYLE
+#endif
+
+
/* Define to the name of the LTO plugin DSO that must be passed to the
linker's -plugin=LIB option. */
#ifndef USED_FOR_TARGET
Index: gcc/configure.ac
===================================================================
--- gcc/configure.ac (revision 171942)
+++ gcc/configure.ac (working copy)
@@ -4936,6 +4936,30 @@
fi
+# Specify what hash style to use by default.
+AC_ARG_WITH([linker-hash-style],
+[AC_HELP_STRING([--with-linker-hash-style={sysv,gnu,both}],
+ [specify the linker hash style])],
+[case x"$withval" in
+ xsysv)
+ LINKER_HASH_STYLE=sysv
+ ;;
+ xgnu)
+ LINKER_HASH_STYLE=gnu
+ ;;
+ xboth)
+ LINKER_HASH_STYLE=both
+ ;;
+ *)
+ AC_MSG_ERROR([$withval is an invalid option to --with-linker-hash-style])
+ ;;
+ esac],
+[LINKER_HASH_STYLE=''])
+if test x"${LINKER_HASH_STYLE}" != x; then
+ AC_DEFINE_UNQUOTED(LINKER_HASH_STYLE, "$LINKER_HASH_STYLE",
+ [The linker hash style])
+fi
+
# Configure the subdirectories
# AC_CONFIG_SUBDIRS($subdirs)
Index: gcc/configure
===================================================================
--- gcc/configure (revision 171942)
+++ gcc/configure (working copy)
@@ -913,6 +913,7 @@
with_slibdir
enable_plugin
enable_libquadmath_support
+with_linker_hash_style
'
ac_precious_vars='build_alias
host_alias
@@ -1663,6 +1664,8 @@
with the compiler
--with-system-zlib use installed libz
--with-slibdir=DIR shared libraries in DIR [LIBDIR]
+ --with-linker-hash-style={sysv,gnu,both}
+ specify the linker hash style
Some influential environment variables:
CC C compiler command
@@ -17505,7 +17508,7 @@
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 17508 "configure"
+#line 17511 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -17611,7 +17614,7 @@
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 17614 "configure"
+#line 17617 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -26461,6 +26464,36 @@
fi
+# Specify what hash style to use by default.
+
+# Check whether --with-linker-hash-style was given.
+if test "${with_linker_hash_style+set}" = set; then :
+ withval=$with_linker_hash_style; case x"$withval" in
+ xsysv)
+ LINKER_HASH_STYLE=sysv
+ ;;
+ xgnu)
+ LINKER_HASH_STYLE=gnu
+ ;;
+ xboth)
+ LINKER_HASH_STYLE=both
+ ;;
+ *)
+ as_fn_error "$withval is an invalid option to --with-linker-hash-style" "$LINENO" 5
+ ;;
+ esac
+else
+ LINKER_HASH_STYLE=''
+fi
+
+if test x"${LINKER_HASH_STYLE}" != x; then
+
+cat >>confdefs.h <<_ACEOF
+#define LINKER_HASH_STYLE "$LINKER_HASH_STYLE"
+_ACEOF
+
+fi
+
# Configure the subdirectories
# AC_CONFIG_SUBDIRS($subdirs)
next reply other threads:[~2011-04-04 18:17 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-04 18:17 Paul Pluzhnikov [this message]
2011-04-04 18:22 ` Rainer Orth
2011-04-04 18:26 ` Ian Lance Taylor
2011-04-04 22:53 ` Matthias Klose
2011-04-05 0:01 ` Joseph S. Myers
2011-04-11 18:01 ` Paul Pluzhnikov
2011-04-18 17:20 ` Paul Pluzhnikov
2011-04-25 17:03 ` Paul Pluzhnikov
2011-05-02 14:23 ` Paul Pluzhnikov
2011-05-02 15:00 ` Joseph S. Myers
2011-05-02 15:57 ` Paul Pluzhnikov
2011-05-09 17:01 ` Paul Pluzhnikov
2011-05-09 17:04 ` Paolo Bonzini
2011-05-09 17:26 ` Joseph S. Myers
2011-05-09 17:31 ` Paolo Bonzini
2011-05-09 17:31 ` Joseph S. Myers
2011-05-09 18:00 ` Paul Pluzhnikov
2011-05-10 11:36 ` Richard Guenther
2011-05-10 15:00 ` Ian Lance Taylor
2011-05-10 15:08 ` Jakub Jelinek
2011-05-10 15:23 ` Paul Pluzhnikov
2011-05-10 15:26 ` Richard Guenther
2011-05-12 9:10 ` Eric Botcazou
2011-05-12 9:19 ` Eric Botcazou
2011-05-12 9:23 ` Paul Pluzhnikov
2011-05-12 9:32 ` Paul Pluzhnikov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110404181738.52D661909EB@elbrus2.mtv.corp.google.com \
--to=ppluzhnikov@google.com \
--cc=gcc-patches@sourceware.org \
--cc=iant@google.com \
--cc=satorux@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).