summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gcc/gcc-6.1/0010-gcc-poison-system-directories.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/gcc/gcc-6.1/0010-gcc-poison-system-directories.patch')
-rw-r--r--meta/recipes-devtools/gcc/gcc-6.1/0010-gcc-poison-system-directories.patch192
1 files changed, 192 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-6.1/0010-gcc-poison-system-directories.patch b/meta/recipes-devtools/gcc/gcc-6.1/0010-gcc-poison-system-directories.patch
new file mode 100644
index 0000000000..ac4cf442da
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-6.1/0010-gcc-poison-system-directories.patch
@@ -0,0 +1,192 @@
1From d76250323dad69212c958e4857a98d99ab51a39e 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 10/46] gcc: poison-system-directories
5
6Signed-off-by: Khem Raj <raj.khem@gmail.com>
7
8Upstream-Status: Inappropriate [distribution: codesourcery]
9---
10 gcc/common.opt | 4 ++++
11 gcc/config.in | 6 ++++++
12 gcc/configure | 16 ++++++++++++++++
13 gcc/configure.ac | 10 ++++++++++
14 gcc/doc/invoke.texi | 9 +++++++++
15 gcc/gcc.c | 2 ++
16 gcc/incpath.c | 19 +++++++++++++++++++
17 7 files changed, 66 insertions(+)
18
19diff --git a/gcc/common.opt b/gcc/common.opt
20index 67048db..733185c 100644
21--- a/gcc/common.opt
22+++ b/gcc/common.opt
23@@ -659,6 +659,10 @@ Wreturn-local-addr
24 Common Var(warn_return_local_addr) Init(1) Warning
25 Warn about returning a pointer/reference to a local or temporary variable.
26
27+Wpoison-system-directories
28+Common Var(flag_poison_system_directories) Init(1) Warning
29+Warn for -I and -L options using system directories if cross compiling
30+
31 Wshadow
32 Common Var(warn_shadow) Warning
33 Warn when one local variable shadows another.
34diff --git a/gcc/config.in b/gcc/config.in
35index 115cb61..105b30f 100644
36--- a/gcc/config.in
37+++ b/gcc/config.in
38@@ -187,6 +187,12 @@
39 #endif
40
41
42+/* Define to warn for use of native system header directories */
43+#ifndef USED_FOR_TARGET
44+#undef ENABLE_POISON_SYSTEM_DIRECTORIES
45+#endif
46+
47+
48 /* Define if you want all operations on RTL (the basic data structure of the
49 optimizer and back end) to be checked for dynamic type safety at runtime.
50 This is quite expensive. */
51diff --git a/gcc/configure b/gcc/configure
52index 1c6e340..8f83152 100755
53--- a/gcc/configure
54+++ b/gcc/configure
55@@ -942,6 +942,7 @@ with_system_zlib
56 enable_maintainer_mode
57 enable_link_mutex
58 enable_version_specific_runtime_libs
59+enable_poison_system_directories
60 enable_plugin
61 enable_host_shared
62 enable_libquadmath_support
63@@ -1681,6 +1682,8 @@ Optional Features:
64 --enable-version-specific-runtime-libs
65 specify that runtime libraries should be installed
66 in a compiler-specific directory
67+ --enable-poison-system-directories
68+ warn for use of native system header directories
69 --enable-plugin enable plugin support
70 --enable-host-shared build host code as shared libraries
71 --disable-libquadmath-support
72@@ -28908,6 +28911,19 @@ if test "${enable_version_specific_runtime_libs+set}" = set; then :
73 fi
74
75
76+# Check whether --enable-poison-system-directories was given.
77+if test "${enable_poison_system_directories+set}" = set; then :
78+ enableval=$enable_poison_system_directories;
79+else
80+ enable_poison_system_directories=no
81+fi
82+
83+if test "x${enable_poison_system_directories}" = "xyes"; then
84+
85+$as_echo "#define ENABLE_POISON_SYSTEM_DIRECTORIES 1" >>confdefs.h
86+
87+fi
88+
89 # Substitute configuration variables
90
91
92diff --git a/gcc/configure.ac b/gcc/configure.ac
93index 6c1dcd9..0fccaef 100644
94--- a/gcc/configure.ac
95+++ b/gcc/configure.ac
96@@ -5861,6 +5861,16 @@ AC_ARG_ENABLE(version-specific-runtime-libs,
97 [specify that runtime libraries should be
98 installed in a compiler-specific directory])])
99
100+AC_ARG_ENABLE([poison-system-directories],
101+ AS_HELP_STRING([--enable-poison-system-directories],
102+ [warn for use of native system header directories]),,
103+ [enable_poison_system_directories=no])
104+if test "x${enable_poison_system_directories}" = "xyes"; then
105+ AC_DEFINE([ENABLE_POISON_SYSTEM_DIRECTORIES],
106+ [1],
107+ [Define to warn for use of native system header directories])
108+fi
109+
110 # Substitute configuration variables
111 AC_SUBST(subdirs)
112 AC_SUBST(srcdir)
113diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
114index 821f8fd..8bb49e7 100644
115--- a/gcc/doc/invoke.texi
116+++ b/gcc/doc/invoke.texi
117@@ -284,6 +284,7 @@ Objective-C and Objective-C++ Dialects}.
118 -Wparentheses -Wno-pedantic-ms-format @gol
119 -Wplacement-new -Wplacement-new=@var{n} @gol
120 -Wpointer-arith -Wno-pointer-to-int-cast @gol
121+-Wno-poison-system-directories @gol
122 -Wno-pragmas -Wredundant-decls -Wno-return-local-addr @gol
123 -Wreturn-type -Wsequence-point -Wshadow -Wno-shadow-ivar @gol
124 -Wshift-overflow -Wshift-overflow=@var{n} @gol
125@@ -4723,6 +4724,14 @@ made up of data only and thus requires no special treatment. But, for
126 most targets, it is made up of code and thus requires the stack to be
127 made executable in order for the program to work properly.
128
129+@item -Wno-poison-system-directories
130+@opindex Wno-poison-system-directories
131+Do not warn for @option{-I} or @option{-L} options using system
132+directories such as @file{/usr/include} when cross compiling. This
133+option is intended for use in chroot environments when such
134+directories contain the correct headers and libraries for the target
135+system rather than the host.
136+
137 @item -Wfloat-equal
138 @opindex Wfloat-equal
139 @opindex Wno-float-equal
140diff --git a/gcc/gcc.c b/gcc/gcc.c
141index 1af5920..4cfef7f 100644
142--- a/gcc/gcc.c
143+++ b/gcc/gcc.c
144@@ -1017,6 +1017,8 @@ proper position among the other output files. */
145 "%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \
146 "%X %{o*} %{e*} %{N} %{n} %{r}\
147 %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!nostartfiles:%S}} \
148+ %{Wno-poison-system-directories:--no-poison-system-directories} \
149+ %{Werror=poison-system-directories:--error-poison-system-directories} \
150 %{static:} %{L*} %(mfwrap) %(link_libgcc) " \
151 VTABLE_VERIFICATION_SPEC " " SANITIZER_EARLY_SPEC " %o " CHKP_SPEC " \
152 %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1):\
153diff --git a/gcc/incpath.c b/gcc/incpath.c
154index ea40f4a..856da41 100644
155--- a/gcc/incpath.c
156+++ b/gcc/incpath.c
157@@ -26,6 +26,7 @@
158 #include "intl.h"
159 #include "incpath.h"
160 #include "cppdefault.h"
161+#include "diagnostic-core.h"
162
163 /* Microsoft Windows does not natively support inodes.
164 VMS has non-numeric inodes. */
165@@ -381,6 +382,24 @@ merge_include_chains (const char *sysroot, cpp_reader *pfile, int verbose)
166 }
167 fprintf (stderr, _("End of search list.\n"));
168 }
169+
170+#ifdef ENABLE_POISON_SYSTEM_DIRECTORIES
171+ if (flag_poison_system_directories)
172+ {
173+ struct cpp_dir *p;
174+
175+ for (p = heads[QUOTE]; p; p = p->next)
176+ {
177+ if ((!strncmp (p->name, "/usr/include", 12))
178+ || (!strncmp (p->name, "/usr/local/include", 18))
179+ || (!strncmp (p->name, "/usr/X11R6/include", 18)))
180+ warning (OPT_Wpoison_system_directories,
181+ "include location \"%s\" is unsafe for "
182+ "cross-compilation",
183+ p->name);
184+ }
185+ }
186+#endif
187 }
188
189 /* Use given -I paths for #include "..." but not #include <...>, and
190--
1912.8.2
192