This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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][RFA] gold: build with -frandom-seed


Patch adds -frandom-seed to gold builds, to make them rebuild the
same from build to build.

GCC uses -frandom-seed to generate unique names for symbols in
unnamed namespaces, etc., so without specifying a seed the resulting
gold binary will come out different from build to build.  Each
object is given a different random seed based on the file's name, as
recommended by the GCC manual.

configured/built for x86_64-unknown-linux-gnu, passes gold tests,
and verified that two builds (done w/ the same build dir) produce
identical binaries.


chris
--
[gold/ChangeLog]
2008-07-20  Chris Demetriou  <cgd@google.com>

        * configure.ac (gold_cv_c_random_seed): New configured variable.
	(RANDOM_SEED_CFLAGS): New substituted variable.
	* Makefile.am (AM_CFLAGS, AM_CXXFLAGS): Add $(RANDOM_SEED_CFLAGS).
	* configure: Rebuild.
	* Makefile.in: Likewise.
	* testsuite/Makefile.in: Likewise.

Index: Makefile.am
===================================================================
RCS file: /cvs/src/src/gold/Makefile.am,v
retrieving revision 1.38
diff -u -u -p -r1.38 Makefile.am
--- Makefile.am	12 Jun 2008 17:02:17 -0000	1.38
+++ Makefile.am	20 Jul 2008 22:55:42 -0000
@@ -8,8 +8,8 @@ tooldir = $(exec_prefix)/$(target_alias)
 
 ACLOCAL_AMFLAGS = -I ../bfd -I ../config
 
-AM_CFLAGS = $(WARN_CFLAGS) $(LFS_CFLAGS)
-AM_CXXFLAGS = $(WARN_CXXFLAGS) $(LFS_CFLAGS)
+AM_CFLAGS = $(WARN_CFLAGS) $(LFS_CFLAGS) $(RANDOM_SEED_CFLAGS)
+AM_CXXFLAGS = $(WARN_CXXFLAGS) $(LFS_CFLAGS) $(RANDOM_SEED_CFLAGS)
 
 INCLUDES = \
 	-I$(srcdir) -I$(srcdir)/../include -I$(srcdir)/../elfcpp \
Index: configure.ac
===================================================================
RCS file: /cvs/src/src/gold/configure.ac,v
retrieving revision 1.33
diff -u -u -p -r1.33 configure.ac
--- configure.ac	5 May 2008 20:20:21 -0000	1.33
+++ configure.ac	20 Jul 2008 22:55:42 -0000
@@ -269,6 +269,20 @@ AC_CACHE_CHECK([for constructor prioriti
 
 AM_CONDITIONAL(CONSTRUCTOR_PRIORITY, test "$gold_cv_c_conprio" = "yes")
 
+dnl Test for the -frandom-seed option.
+AC_CACHE_CHECK([for -frandom-seed support], [gold_cv_c_random_seed],
+[save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -frandom-seed=foo"
+AC_COMPILE_IFELSE([int i;], [gold_cv_c_random_seed=yes],
+[gold_cv_c_random_seed=no])
+CFLAGS="$save_CFLAGS"])
+if test "$gold_cv_c_random_seed" = "yes"; then
+  # In Makefile, '$@' will be expanded to be the name of the file
+  # being built, providing a unique seed for each file.
+  RANDOM_SEED_CFLAGS=-frandom-seed=\$@
+fi
+AC_SUBST(RANDOM_SEED_CFLAGS)
+
 AM_BINUTILS_WARNINGS
 
 WARN_CXXFLAGS=`echo ${WARN_CFLAGS} | sed -e 's/-Wstrict-prototypes//' -e 's/-Wmissing-prototypes//'`


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