summaryrefslogtreecommitdiffstats
path: root/bsp/meta-synopsys/recipes-core/glibc/files/0032-Add-with-nonshared-cflags-option-to-configure.patch
blob: 065564304828d3d4f1b5d43786534635a23ad25c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
From 2add82381a59df74de413d11166a9840e870e072 Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
Date: Fri, 17 Aug 2018 11:44:39 +0200
Subject: [PATCH] Add --with-nonshared-cflags option to configure

Upstream status: Backport [https://sourceware.org/git/?p=glibc.git;a=commit;f=INSTALL;h=6413fcde4fe0272eee469aaf41c8bb1d6e6a270f]

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
---
 INSTALL             | 16 ++++++++++++++++
 Makeconfig          |  2 +-
 config.make.in      |  1 +
 configure           | 14 ++++++++++++++
 configure.ac        |  8 ++++++++
 manual/install.texi | 14 ++++++++++++++
 6 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/INSTALL b/INSTALL
index 781cb8415b..3e566ebfef 100644
--- a/INSTALL
+++ b/INSTALL
@@ -90,6 +90,22 @@ if 'CFLAGS' is specified it must enable optimization.  For example:
      library will still be usable, but functionality may be lost--for
      example, you can't build a shared libc with old binutils.
 
+'--with-nonshared-cflags=CFLAGS'
+     Use additional compiler flags CFLAGS to build the parts of the
+     library which are always statically linked into applications and
+     libraries even with shared linking (that is, the object files
+     contained in 'lib*_nonshared.a' libraries).  The build process will
+     automatically use the appropriate flags, but this option can be
+     used to set additional flags required for building applications and
+     libraries, to match local policy.  For example, if such a policy
+     requires that all code linked into applications must be built with
+     source fortification,
+     '--with-nonshared-cflags=-Wp,-D_FORTIFY_SOURCE=2' will make sure
+     that the objects in 'libc_nonshared.a' are compiled with this flag
+     (although this will not affect the generated code in this
+     particular case and potentially change debugging information and
+     metadata only).
+
 '--disable-shared'
      Don't build shared libraries even if it is possible.  Not all
      systems support shared libraries; you need ELF support and
diff --git a/Makeconfig b/Makeconfig
index 608ffe648c..b0b27f0113 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -1038,7 +1038,7 @@ object-suffixes-for-libc += .oS
 # Must build the routines as PIC, though, because they can end up in (users')
 # shared objects.  We don't want to use CFLAGS-os because users may, for
 # example, make that processor-specific.
-CFLAGS-.oS = $(CFLAGS-.o) $(PIC-ccflag)
+CFLAGS-.oS = $(CFLAGS-.o) $(PIC-ccflag) $(extra-nonshared-cflags)
 CPPFLAGS-.oS = $(CPPFLAGS-.o) -DPIC -DLIBC_NONSHARED=1
 libtype.oS = lib%_nonshared.a
 endif
diff --git a/config.make.in b/config.make.in
index d9891b2cd8..a6fe48d31f 100644
--- a/config.make.in
+++ b/config.make.in
@@ -110,6 +110,7 @@ BUILD_CC = @BUILD_CC@
 CFLAGS = @CFLAGS@
 CPPFLAGS-config = @CPPFLAGS@
 CPPUNDEFS = @CPPUNDEFS@
+extra-nonshared-cflags = @extra_nonshared_cflags@
 ASFLAGS-config = @ASFLAGS_config@
 AR = @AR@
 NM = @NM@
diff --git a/configure b/configure
index fde57d63fe..285a6537f0 100755
--- a/configure
+++ b/configure
@@ -684,6 +684,7 @@ force_install
 bindnow
 hardcoded_path_in_tests
 enable_timezone_tools
+extra_nonshared_cflags
 use_default_link
 sysheaders
 ac_ct_CXX
@@ -762,6 +763,7 @@ with_binutils
 with_selinux
 with_headers
 with_default_link
+with_nonshared_cflags
 enable_sanity_checks
 enable_shared
 enable_profile
@@ -1482,6 +1484,8 @@ Optional Packages:
   --with-headers=PATH     location of system headers to use (for example
                           /usr/src/linux/include) [default=compiler default]
   --with-default-link     do not use explicit linker scripts
+  --with-nonshared-cflags=CFLAGS
+                          build nonshared libraries with additional CFLAGS
   --with-cpu=CPU          select code for CPU variant
 
 Some influential environment variables:
@@ -3339,6 +3343,16 @@ else
 fi
 
 
+
+# Check whether --with-nonshared-cflags was given.
+if test "${with_nonshared_cflags+set}" = set; then :
+  withval=$with_nonshared_cflags; extra_nonshared_cflags=$withval
+else
+  extra_nonshared_cflags=
+fi
+
+
+
 # Check whether --enable-sanity-checks was given.
 if test "${enable_sanity_checks+set}" = set; then :
   enableval=$enable_sanity_checks; enable_sanity=$enableval
diff --git a/configure.ac b/configure.ac
index 014e09a5d5..8045d44dd0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -154,6 +154,14 @@ AC_ARG_WITH([default-link],
 	    [use_default_link=$withval],
 	    [use_default_link=default])
 
+dnl Additional build flags injection.
+AC_ARG_WITH([nonshared-cflags],
+	    AC_HELP_STRING([--with-nonshared-cflags=CFLAGS],
+			   [build nonshared libraries with additional CFLAGS]),
+	    [extra_nonshared_cflags=$withval],
+	    [extra_nonshared_cflags=])
+AC_SUBST(extra_nonshared_cflags)
+
 AC_ARG_ENABLE([sanity-checks],
 	      AC_HELP_STRING([--disable-sanity-checks],
 			     [really do not use threads (should not be used except in special situations) @<:@default=yes@:>@]),
diff --git a/manual/install.texi b/manual/install.texi
index c39e63bf3b..5476bb66f7 100644
--- a/manual/install.texi
+++ b/manual/install.texi
@@ -117,6 +117,20 @@ problem and suppress these constructs, so that the library will still be
 usable, but functionality may be lost---for example, you can't build a
 shared libc with old binutils.
 
+@item --with-nonshared-cflags=@var{cflags}
+Use additional compiler flags @var{cflags} to build the parts of the
+library which are always statically linked into applications and
+libraries even with shared linking (that is, the object files contained
+in @file{lib*_nonshared.a} libraries).  The build process will
+automatically use the appropriate flags, but this option can be used to
+set additional flags required for building applications and libraries,
+to match local policy.  For example, if such a policy requires that all
+code linked into applications must be built with source fortification,
+@samp{--with-nonshared-cflags=-Wp,-D_FORTIFY_SOURCE=2} will make sure
+that the objects in @file{libc_nonshared.a} are compiled with this flag
+(although this will not affect the generated code in this particular
+case and potentially change debugging information and metadata only).
+
 @c disable static doesn't work currently
 @c @item --disable-static
 @c Don't build static libraries.  Static libraries aren't that useful these
-- 
2.16.2