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

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