12745e
#
12745e
# In rhel-6.x the Makerules are not entirely as mature as they are
12745e
# in glibc 2.21 (from which the example link-libc-args is taken from).
12745e
# In rhel-6.x the applications are not built like their counterpart
12745e
# real applications, and because of that compiling DSOs that use TLS
12745e
# will fail with undefined references to __tls_get_addr which resides
12745e
# in ld.so and is never included in the link. This patch enhances
12745e
# only the build-module and build-module-asneeded targets to include
12745e
# a more fully and correct link line as the compiler driver would use
12745e
# when constructing an application or DSO. We do not adjust the link
12745e
# lines used to build lib* targets.
12745e
#
bca718
# The rest of this patch is brought in by glibc-rh1292018-0a.patch
bca718
# where we need to link against ld.so from libm.so.
bca718
#
bca718
bca718
commit fab7ce3f5b4060bf62659e8b58529de4156b5a2f
bca718
Author: Joseph Myers <joseph@codesourcery.com>
bca718
Date:   Fri May 31 16:16:33 2013 +0000
bca718
bca718
    Link extra-libs consistently with libc and ld.so.
bca718
12745e
diff -urN glibc-2.17-c758a686/Makerules glibc-2.17-c758a686/Makerules
12745e
--- glibc-2.17-c758a686/Makerules	2015-02-18 19:53:00.000000000 -0500
12745e
+++ glibc-2.17-c758a686/Makerules	2015-02-18 20:08:33.299000028 -0500
12745e
@@ -437,6 +437,25 @@
12745e
 load-map-file = $(map-file:%=-Wl,--version-script=%)
12745e
 endif
12745e
 
12745e
+# Compiler arguments to use to link a shared object with libc and
12745e
+# ld.so.  This is intended to be as similar as possible to a default
12745e
+# link with an installed libc.
12745e
+link-libc-args = -Wl,--start-group \
12745e
+                 $(libc-for-link) \
12745e
+                 $(common-objpfx)libc_nonshared.a \
12745e
+                 $(as-needed) $(elf-objpfx)ld.so $(no-as-needed) \
12745e
+                 -Wl,--end-group
12745e
+
12745e
+# The corresponding shared libc to use.  This may be modified for a
12745e
+# particular target.
12745e
+libc-for-link = $(common-objpfx)libc.so
12745e
+
12745e
+# The corresponding dependencies.  As these are used in dependencies,
12745e
+# not just commands, they cannot use target-specific variables so need
12745e
+# to name both possible libc.so objects.
12745e
+link-libc-deps = $(common-objpfx)libc.so $(common-objpfx)linkobj/libc.so \
12745e
+                 $(common-objpfx)libc_nonshared.a $(elf-objpfx)ld.so
12745e
+
12745e
 # Pattern rule to build a shared object from an archive of PIC objects.
12745e
 # This must come after the installation rules so Make doesn't try to
12745e
 # build shared libraries in place from the installed *_pic.a files.
12745e
@@ -518,12 +537,13 @@
12745e
 # not for shared objects
12745e
 define build-module
12745e
 $(build-module-helper) -o $@ $(shlib-lds-flags) \
12745e
-	  $(csu-objpfx)abi-note.o $(build-module-objlist)
12745e
+	  $(csu-objpfx)abi-note.o $(build-module-objlist) $(link-libc-args)
12745e
 endef
12745e
 define build-module-asneeded
12745e
 $(build-module-helper) -o $@ $(shlib-lds-flags) \
12745e
 	  $(csu-objpfx)abi-note.o \
12745e
-	  -Wl,--as-needed $(build-module-objlist) -Wl,--no-as-needed
12745e
+	  -Wl,--as-needed $(build-module-objlist) -Wl,--no-as-needed \
12745e
+	  $(link-libc-args)
12745e
 endef
12745e
 
12745e
 build-module-helper-objlist = \