summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gcc/gcc-4.8/0016-gcc-poison-system-directories.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/gcc/gcc-4.8/0016-gcc-poison-system-directories.patch')
-rw-r--r--meta/recipes-devtools/gcc/gcc-4.8/0016-gcc-poison-system-directories.patch224
1 files changed, 224 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-4.8/0016-gcc-poison-system-directories.patch b/meta/recipes-devtools/gcc/gcc-4.8/0016-gcc-poison-system-directories.patch
new file mode 100644
index 0000000000..1e2a9e1009
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-4.8/0016-gcc-poison-system-directories.patch
@@ -0,0 +1,224 @@
1From 160397ef3c3331099af028f1b8d3e085b07d88ad Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 08:59:00 +0400
4Subject: [PATCH 16/35] gcc: poison-system-directories
5
6Signed-off-by: Khem Raj <raj.khem@gmail.com>
7
8Upstream-Status: Inappropriate [distribution: codesourcery]
9---
10 gcc/Makefile.in | 2 +-
11 gcc/common.opt | 4 ++++
12 gcc/config.in | 6 ++++++
13 gcc/configure | 20 ++++++++++++++++++--
14 gcc/configure.ac | 10 ++++++++++
15 gcc/doc/invoke.texi | 9 +++++++++
16 gcc/gcc.c | 2 ++
17 gcc/incpath.c | 19 +++++++++++++++++++
18 8 files changed, 69 insertions(+), 3 deletions(-)
19
20diff --git a/gcc/Makefile.in b/gcc/Makefile.in
21index 54ea04f..90a2bba 100644
22--- a/gcc/Makefile.in
23+++ b/gcc/Makefile.in
24@@ -2018,7 +2018,7 @@ attribs.o : attribs.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
25
26 incpath.o: incpath.c incpath.h $(CONFIG_H) $(SYSTEM_H) $(CPPLIB_H) \
27 intl.h prefix.h coretypes.h $(TM_H) cppdefault.h $(TARGET_H) \
28- $(MACHMODE_H)
29+ $(MACHMODE_H) $(FLAGS_H) toplev.h
30
31 CFLAGS-prefix.o += -DPREFIX=\"$(prefix)\" -DBASEVER=$(BASEVER_s)
32 prefix.o: prefix.c $(CONFIG_H) $(SYSTEM_H) coretypes.h prefix.h \
33diff --git a/gcc/common.opt b/gcc/common.opt
34index bdbd3b6..ab86b00 100644
35--- a/gcc/common.opt
36+++ b/gcc/common.opt
37@@ -595,6 +595,10 @@ Wpedantic
38 Common Var(pedantic) Warning
39 Issue warnings needed for strict compliance to the standard
40
41+Wpoison-system-directories
42+Common Var(flag_poison_system_directories) Init(1) Warning
43+Warn for -I and -L options using system directories if cross compiling
44+
45 Wshadow
46 Common Var(warn_shadow) Warning
47 Warn when one local variable shadows another
48diff --git a/gcc/config.in b/gcc/config.in
49index d80fb9f..0524af7 100644
50--- a/gcc/config.in
51+++ b/gcc/config.in
52@@ -138,6 +138,12 @@
53 #endif
54
55
56+/* Define to warn for use of native system header directories */
57+#ifndef USED_FOR_TARGET
58+#undef ENABLE_POISON_SYSTEM_DIRECTORIES
59+#endif
60+
61+
62 /* Define if you want all operations on RTL (the basic data structure of the
63 optimizer and back end) to be checked for dynamic type safety at runtime.
64 This is quite expensive. */
65diff --git a/gcc/configure b/gcc/configure
66index 135bbf5..b65d21d 100755
67--- a/gcc/configure
68+++ b/gcc/configure
69@@ -917,6 +917,7 @@ with_gc
70 with_system_zlib
71 enable_maintainer_mode
72 enable_version_specific_runtime_libs
73+enable_poison_system_directories
74 enable_plugin
75 enable_libquadmath_support
76 with_linker_hash_style
77@@ -1630,6 +1631,8 @@ Optional Features:
78 --enable-version-specific-runtime-libs
79 specify that runtime libraries should be installed
80 in a compiler-specific directory
81+ --enable-poison-system-directories
82+ warn for use of native system header directories
83 --enable-plugin enable plugin support
84 --disable-libquadmath-support
85 disable libquadmath support for Fortran
86@@ -17828,7 +17831,7 @@ else
87 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
88 lt_status=$lt_dlunknown
89 cat > conftest.$ac_ext <<_LT_EOF
90-#line 17831 "configure"
91+#line 17834 "configure"
92 #include "confdefs.h"
93
94 #if HAVE_DLFCN_H
95@@ -17934,7 +17937,7 @@ else
96 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
97 lt_status=$lt_dlunknown
98 cat > conftest.$ac_ext <<_LT_EOF
99-#line 17937 "configure"
100+#line 17940 "configure"
101 #include "confdefs.h"
102
103 #if HAVE_DLFCN_H
104@@ -27103,6 +27106,19 @@ if test "${enable_version_specific_runtime_libs+set}" = set; then :
105 fi
106
107
108+# Check whether --enable-poison-system-directories was given.
109+if test "${enable_poison_system_directories+set}" = set; then :
110+ enableval=$enable_poison_system_directories;
111+else
112+ enable_poison_system_directories=no
113+fi
114+
115+if test "x${enable_poison_system_directories}" = "xyes"; then
116+
117+$as_echo "#define ENABLE_POISON_SYSTEM_DIRECTORIES 1" >>confdefs.h
118+
119+fi
120+
121 # Substitute configuration variables
122
123
124diff --git a/gcc/configure.ac b/gcc/configure.ac
125index 6363a21..e226b85 100644
126--- a/gcc/configure.ac
127+++ b/gcc/configure.ac
128@@ -5063,6 +5063,16 @@ AC_ARG_ENABLE(version-specific-runtime-libs,
129 [specify that runtime libraries should be
130 installed in a compiler-specific directory])])
131
132+AC_ARG_ENABLE([poison-system-directories],
133+ AS_HELP_STRING([--enable-poison-system-directories],
134+ [warn for use of native system header directories]),,
135+ [enable_poison_system_directories=no])
136+if test "x${enable_poison_system_directories}" = "xyes"; then
137+ AC_DEFINE([ENABLE_POISON_SYSTEM_DIRECTORIES],
138+ [1],
139+ [Define to warn for use of native system header directories])
140+fi
141+
142 # Substitute configuration variables
143 AC_SUBST(subdirs)
144 AC_SUBST(srcdir)
145diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
146index 9273d7d..a022622 100644
147--- a/gcc/doc/invoke.texi
148+++ b/gcc/doc/invoke.texi
149@@ -258,6 +258,7 @@ Objective-C and Objective-C++ Dialects}.
150 -Woverlength-strings -Wpacked -Wpacked-bitfield-compat -Wpadded @gol
151 -Wparentheses -Wpedantic-ms-format -Wno-pedantic-ms-format @gol
152 -Wpointer-arith -Wno-pointer-to-int-cast @gol
153+-Wno-poison-system-directories @gol
154 -Wredundant-decls -Wno-return-local-addr @gol
155 -Wreturn-type -Wsequence-point -Wshadow @gol
156 -Wsign-compare -Wsign-conversion -Wsizeof-pointer-memaccess @gol
157@@ -4007,6 +4008,14 @@ headers---for that, @option{-Wunknown-pragmas} must also be used.
158 for most targets, it is made up of code and thus requires the stack
159 to be made executable in order for the program to work properly.
160
161+@item -Wno-poison-system-directories
162+@opindex Wno-poison-system-directories
163+Do not warn for @option{-I} or @option{-L} options using system
164+directories such as @file{/usr/include} when cross compiling. This
165+option is intended for use in chroot environments when such
166+directories contain the correct headers and libraries for the target
167+system rather than the host.
168+
169 @item -Wfloat-equal
170 @opindex Wfloat-equal
171 @opindex Wno-float-equal
172diff --git a/gcc/gcc.c b/gcc/gcc.c
173index 86077f8..efdb625 100644
174--- a/gcc/gcc.c
175+++ b/gcc/gcc.c
176@@ -740,6 +740,8 @@ proper position among the other output files. */
177 "%{fuse-ld=*:-fuse-ld=%*}\
178 %X %{o*} %{e*} %{N} %{n} %{r}\
179 %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!nostartfiles:%S}}\
180+ %{Wno-poison-system-directories:--no-poison-system-directories}\
181+ %{Werror=poison-system-directories:--error-poison-system-directories}\
182 %{static:} %{L*} %(mfwrap) %(link_libgcc) " SANITIZER_EARLY_SPEC " %o\
183 %{fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)}\
184 %{fgnu-tm:%:include(libitm.spec)%(link_itm)}\
185diff --git a/gcc/incpath.c b/gcc/incpath.c
186index 018da98..cd41c78 100644
187--- a/gcc/incpath.c
188+++ b/gcc/incpath.c
189@@ -28,6 +28,7 @@
190 #include "intl.h"
191 #include "incpath.h"
192 #include "cppdefault.h"
193+#include "diagnostic-core.h"
194
195 /* Microsoft Windows does not natively support inodes.
196 VMS has non-numeric inodes. */
197@@ -382,6 +383,24 @@ merge_include_chains (const char *sysroot, cpp_reader *pfile, int verbose)
198 }
199 fprintf (stderr, _("End of search list.\n"));
200 }
201+
202+#ifdef ENABLE_POISON_SYSTEM_DIRECTORIES
203+ if (flag_poison_system_directories)
204+ {
205+ struct cpp_dir *p;
206+
207+ for (p = heads[QUOTE]; p; p = p->next)
208+ {
209+ if ((!strncmp (p->name, "/usr/include", 12))
210+ || (!strncmp (p->name, "/usr/local/include", 18))
211+ || (!strncmp (p->name, "/usr/X11R6/include", 18)))
212+ warning (OPT_Wpoison_system_directories,
213+ "include location \"%s\" is unsafe for "
214+ "cross-compilation",
215+ p->name);
216+ }
217+ }
218+#endif
219 }
220
221 /* Use given -I paths for #include "..." but not #include <...>, and
222--
2231.7.10.4
224