Use static link by default for --disable-shared
authorH.J. Lu <hjl.tools@gmail.com>
Tue, 25 Sep 2012 00:31:36 +0000 (17:31 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 25 Sep 2012 00:31:36 +0000 (17:31 -0700)
ChangeLog
Makeconfig
NEWS

index 8c7dfe6..43ba419 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2012-09-24  H.J. Lu  <hongjiu.lu@intel.com>
 
+       [BZ #13679]
+       * Makeconfig (+link): Defined as $(+link-static) if
+       $(build-shared) isn't yes.
+       (link-tests): Defined as $(+link-static-tests) if $(build-shared)
+       isn't yes.
+       (static-gnulib): Add -lgcc_eh if $(build-shared) isn't yes.
+
        * Makeconfig (+postctorT): Replace crtendS.o with crtend.o.
 
        [BZ #14562]
index 42b836e..e96ebc7 100644 (file)
@@ -411,22 +411,6 @@ LDFLAGS.so += $(hashstyle-LDFLAGS)
 LDFLAGS-rtld += $(hashstyle-LDFLAGS)
 endif
 
-# Commands for linking programs with the C library.
-ifndef +link
-+link-before-libc = $(CC) -nostdlib -nostartfiles -o $@ \
-             $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
-             $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
-             $(addprefix $(csu-objpfx),$(start-installed-name)) \
-             $(+preinit) $(+prector) \
-             $(filter-out $(addprefix $(csu-objpfx),start.o \
-                                                    $(start-installed-name))\
-                          $(+preinit) $(link-extra-libs) \
-                          $(common-objpfx)libc% $(+postinit),$^) \
-             $(link-extra-libs)
-+link-after-libc = $(+postctor) $(+postinit)
-+link = $(+link-before-libc) $(link-libc) $(+link-after-libc)
-+link-tests = $(+link-before-libc) $(link-libc-tests) $(+link-after-libc)
-endif
 # Command for linking PIE programs with the C library.
 ifndef +link-pie
 +link-pie = $(CC) -pie -Wl,-O1 -nostdlib -nostartfiles -o $@ \
@@ -457,6 +441,27 @@ ifndef +link-static
 +link-static-tests = $(+link-static-before-libc) $(link-libc-static-tests) \
                     $(+link-static-after-libc)
 endif
+# Commands for linking programs with the C library.
+ifndef +link
+ifeq (yes,$(build-shared))
++link-before-libc = $(CC) -nostdlib -nostartfiles -o $@ \
+             $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
+             $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
+             $(addprefix $(csu-objpfx),$(start-installed-name)) \
+             $(+preinit) $(+prector) \
+             $(filter-out $(addprefix $(csu-objpfx),start.o \
+                                                    $(start-installed-name))\
+                          $(+preinit) $(link-extra-libs) \
+                          $(common-objpfx)libc% $(+postinit),$^) \
+             $(link-extra-libs)
++link-after-libc = $(+postctor) $(+postinit)
++link = $(+link-before-libc) $(link-libc) $(+link-after-libc)
++link-tests = $(+link-before-libc) $(link-libc-tests) $(+link-after-libc)
+else
++link = $(+link-static)
++link-tests = $(+link-static-tests)
+endif
+endif
 # Command for statically linking bounded-pointer programs with the C library.
 ifndef +link-bounded
 +link-bounded = $(CC) -nostdlib -nostartfiles -static -fbounded-pointers -o $@ \
@@ -568,7 +573,14 @@ gnulib-arch =
 gnulib = -lgcc $(gnulib-arch)
 gnulib-tests := -lgcc $(libgcc_eh)
 static-gnulib-arch =
+# By default, elf/static-stubs.o, instead of -lgcc_eh, is used to
+# statically link programs.  When --disable-shared is used, we use
+# -lgcc_eh since elf/static-stubs.o isn't sufficient.
+ifeq (yes,$(build-shared))
 static-gnulib = -lgcc $(static-gnulib-arch)
+else
+static-gnulib = -lgcc -lgcc_eh $(static-gnulib-arch)
+endif
 static-gnulib-tests := -lgcc -lgcc_eh $(libunwind)
 libc.so-gnulib := -lgcc
 endif
diff --git a/NEWS b/NEWS
index 13523ac..0933b30 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -10,11 +10,11 @@ Version 2.17
 * The following bugs are resolved with this release:
 
   1349, 3479, 5044, 5400, 6778, 6808, 9685, 9914, 10014, 10038, 11607,
-  13412, 13542, 13717, 13696, 13939, 13966, 14042, 14090, 14166, 14150,
-  14151, 14154, 14157, 14166, 14173, 14195, 14237, 14252, 14283, 14298,
-  14303, 14307, 14328, 14331, 14336, 14337, 14347, 14349, 14459, 14476,
-  14505, 14510, 14516, 14518, 14519, 14532, 14538, 14544, 14545, 14562,
-  14576, 14579, 14583, 14587.
+  13412, 13542, 13679, 13717, 13696, 13939, 13966, 14042, 14090, 14166,
+  14150, 14151, 14154, 14157, 14166, 14173, 14195, 14237, 14252, 14283,
+  14298, 14303, 14307, 14328, 14331, 14336, 14337, 14347, 14349, 14459,
+  14476, 14505, 14510, 14516, 14518, 14519, 14532, 14538, 14544, 14545,
+  14562, 14576, 14579, 14583, 14587.
 
 * Support for STT_GNU_IFUNC symbols added for s390 and s390x.
   Optimized versions of memcpy, memset, and memcmp added for System z10 and