summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gcc/gcc-7.3/0009-gcc-poison-system-directories.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/gcc/gcc-7.3/0009-gcc-poison-system-directories.patch')
-rw-r--r--meta/recipes-devtools/gcc/gcc-7.3/0009-gcc-poison-system-directories.patch192
1 files changed, 0 insertions, 192 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-7.3/0009-gcc-poison-system-directories.patch b/meta/recipes-devtools/gcc/gcc-7.3/0009-gcc-poison-system-directories.patch
deleted file mode 100644
index fe13ed6e2d..0000000000
--- a/meta/recipes-devtools/gcc/gcc-7.3/0009-gcc-poison-system-directories.patch
+++ /dev/null
@@ -1,192 +0,0 @@
1From 4791a0a0f4595d0a18974f4e85a759a0789943db 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 09/47] 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 a5c3aeaa336..f02fe66367e 100644
21--- a/gcc/common.opt
22+++ b/gcc/common.opt
23@@ -662,6 +662,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 variable shadows another. Same as -Wshadow=global.
34diff --git a/gcc/config.in b/gcc/config.in
35index bf2aa7b2e7d..b1203987e15 100644
36--- a/gcc/config.in
37+++ b/gcc/config.in
38@@ -194,6 +194,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 c823ffe6290..4898f04fa6b 100755
53--- a/gcc/configure
54+++ b/gcc/configure
55@@ -949,6 +949,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@@ -1691,6 +1692,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@@ -29347,6 +29350,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 acfe9797389..9dc1dc7fc96 100644
94--- a/gcc/configure.ac
95+++ b/gcc/configure.ac
96@@ -6101,6 +6101,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 68a558e9992..060cd7169c6 100644
115--- a/gcc/doc/invoke.texi
116+++ b/gcc/doc/invoke.texi
117@@ -298,6 +298,7 @@ Objective-C and Objective-C++ Dialects}.
118 -Wpacked -Wpacked-bitfield-compat -Wpadded @gol
119 -Wparentheses -Wno-pedantic-ms-format @gol
120 -Wplacement-new -Wplacement-new=@var{n} @gol
121+-Wno-poison-system-directories @gol
122 -Wpointer-arith -Wpointer-compare -Wno-pointer-to-int-cast @gol
123 -Wno-pragmas -Wredundant-decls -Wrestrict -Wno-return-local-addr @gol
124 -Wreturn-type -Wsequence-point -Wshadow -Wno-shadow-ivar @gol
125@@ -5395,6 +5396,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 c48178f..f63d53d 100644
142--- a/gcc/gcc.c
143+++ b/gcc/gcc.c
144@@ -1029,6 +1029,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|no-pie:} %{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 98fe5ec9ab3..f90e74dbd73 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@@ -382,6 +383,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.12.2
192