Blame SOURCES/glibc-with-nonshared-cflags.patch

077c9d
Author: Florian Weimer <fweimer@redhat.com>
077c9d
Date:   Wed Jul 4 11:34:36 2018 +0200
077c9d
077c9d
    Add --with-nonshared-cflags option to configure
077c9d
077c9d
Submitted upstream:
077c9d
077c9d
  https://sourceware.org/ml/libc-alpha/2018-07/msg00071.html
077c9d
077c9d
diff --git a/INSTALL b/INSTALL
077c9d
index 0a22aa7d01e6e87b..0f80d9d615db6d42 100644
077c9d
--- a/INSTALL
077c9d
+++ b/INSTALL
077c9d
@@ -90,6 +90,15 @@ if 'CFLAGS' is specified it must enable optimization.  For example:
077c9d
      library will still be usable, but functionality may be lost--for
077c9d
      example, you can't build a shared libc with old binutils.
077c9d
 
077c9d
+'--with-nonshared-cflags=CFLAGS'
077c9d
+     Use additional compiler flags CFLAGS to build the parts of the
077c9d
+     library which are always statically linked into applications and
077c9d
+     libraries even with shared linking (that is, the object files
077c9d
+     contained in 'lib*_nonshared.a' libraries).  The build process will
077c9d
+     automatically use the appropriate flags, but this option can be
077c9d
+     used to set additional flags required for building applications and
077c9d
+     libraries, to match local policy.
077c9d
+
077c9d
 '--disable-shared'
077c9d
      Don't build shared libraries even if it is possible.  Not all
077c9d
      systems support shared libraries; you need ELF support and
077c9d
diff --git a/Makeconfig b/Makeconfig
077c9d
index 608ffe648c80c724..b0b27f0113ac18b8 100644
077c9d
--- a/Makeconfig
077c9d
+++ b/Makeconfig
077c9d
@@ -1038,7 +1038,7 @@ object-suffixes-for-libc += .oS
077c9d
 # Must build the routines as PIC, though, because they can end up in (users')
077c9d
 # shared objects.  We don't want to use CFLAGS-os because users may, for
077c9d
 # example, make that processor-specific.
077c9d
-CFLAGS-.oS = $(CFLAGS-.o) $(PIC-ccflag)
077c9d
+CFLAGS-.oS = $(CFLAGS-.o) $(PIC-ccflag) $(extra-nonshared-cflags)
077c9d
 CPPFLAGS-.oS = $(CPPFLAGS-.o) -DPIC -DLIBC_NONSHARED=1
077c9d
 libtype.oS = lib%_nonshared.a
077c9d
 endif
077c9d
diff --git a/config.make.in b/config.make.in
077c9d
index d9891b2cd8ec3fbf..a6fe48d31f4d2725 100644
077c9d
--- a/config.make.in
077c9d
+++ b/config.make.in
077c9d
@@ -110,6 +110,7 @@ BUILD_CC = @BUILD_CC@
077c9d
 CFLAGS = @CFLAGS@
077c9d
 CPPFLAGS-config = @CPPFLAGS@
077c9d
 CPPUNDEFS = @CPPUNDEFS@
077c9d
+extra-nonshared-cflags = @extra_nonshared_cflags@
077c9d
 ASFLAGS-config = @ASFLAGS_config@
077c9d
 AR = @AR@
077c9d
 NM = @NM@
077c9d
diff --git a/configure b/configure
077c9d
index ef1830221522b7a5..fec0efff8216addd 100755
077c9d
--- a/configure
077c9d
+++ b/configure
077c9d
@@ -684,6 +684,7 @@ force_install
077c9d
 bindnow
077c9d
 hardcoded_path_in_tests
077c9d
 enable_timezone_tools
077c9d
+extra_nonshared_cflags
077c9d
 use_default_link
077c9d
 sysheaders
077c9d
 ac_ct_CXX
077c9d
@@ -762,6 +763,7 @@ with_binutils
077c9d
 with_selinux
077c9d
 with_headers
077c9d
 with_default_link
077c9d
+with_nonshared_cflags
077c9d
 enable_sanity_checks
077c9d
 enable_shared
077c9d
 enable_profile
077c9d
@@ -1479,6 +1481,8 @@ Optional Packages:
077c9d
   --with-headers=PATH     location of system headers to use (for example
077c9d
                           /usr/src/linux/include) [default=compiler default]
077c9d
   --with-default-link     do not use explicit linker scripts
077c9d
+  --with-nonshared-cflags=FLAGS
077c9d
+                          build nonshared libraries with additional FLAGS
077c9d
   --with-cpu=CPU          select code for CPU variant
077c9d
 
077c9d
 Some influential environment variables:
077c9d
@@ -3336,6 +3340,16 @@ else
077c9d
 fi
077c9d
 
077c9d
 
077c9d
+
077c9d
+# Check whether --with-nonshared-cflags was given.
077c9d
+if test "${with_nonshared_cflags+set}" = set; then :
077c9d
+  withval=$with_nonshared_cflags; extra_nonshared_cflags=$withval
077c9d
+else
077c9d
+  extra_nonshared_cflags=
077c9d
+fi
077c9d
+
077c9d
+
077c9d
+
077c9d
 # Check whether --enable-sanity-checks was given.
077c9d
 if test "${enable_sanity_checks+set}" = set; then :
077c9d
   enableval=$enable_sanity_checks; enable_sanity=$enableval
077c9d
diff --git a/configure.ac b/configure.ac
077c9d
index dc517017f588626a..154185d70de38928 100644
077c9d
--- a/configure.ac
077c9d
+++ b/configure.ac
077c9d
@@ -154,6 +154,14 @@ AC_ARG_WITH([default-link],
077c9d
 	    [use_default_link=$withval],
077c9d
 	    [use_default_link=default])
077c9d
 
077c9d
+dnl Additional build flags injection.
077c9d
+AC_ARG_WITH([nonshared-cflags],
077c9d
+	    AC_HELP_STRING([--with-nonshared-cflags=FLAGS],
077c9d
+			   [build nonshared libraries with additional FLAGS]),
077c9d
+	    [extra_nonshared_cflags=$withval],
077c9d
+	    [extra_nonshared_cflags=])
077c9d
+AC_SUBST(extra_nonshared_cflags)
077c9d
+
077c9d
 AC_ARG_ENABLE([sanity-checks],
077c9d
 	      AC_HELP_STRING([--disable-sanity-checks],
077c9d
 			     [really do not use threads (should not be used except in special situations) @<:@default=yes@:>@]),
077c9d
diff --git a/manual/install.texi b/manual/install.texi
077c9d
index 422da1447eb4dc68..eaf0cd09e7501b96 100644
077c9d
--- a/manual/install.texi
077c9d
+++ b/manual/install.texi
077c9d
@@ -117,6 +117,15 @@ problem and suppress these constructs, so that the library will still be
077c9d
 usable, but functionality may be lost---for example, you can't build a
077c9d
 shared libc with old binutils.
077c9d
 
077c9d
+@item --with-nonshared-cflags=@var{cflags}
077c9d
+Use additional compiler flags @var{cflags} to build the parts of the
077c9d
+library which are always statically linked into applications and
077c9d
+libraries even with shared linking (that is, the object files contained
077c9d
+in @file{lib*_nonshared.a} libraries).  The build process will
077c9d
+automatically use the appropriate flags, but this option can be used to
077c9d
+set additional flags required for building applications and libraries,
077c9d
+to match local policy.
077c9d
+
077c9d
 @c disable static doesn't work currently
077c9d
 @c @item --disable-static
077c9d
 @c Don't build static libraries.  Static libraries aren't that useful these