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

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