wok-next view gcc/stuff/patches/0003-gcc-poison-system-directories.patch @ rev 21127

Update xarchiver (0.5.4.14), xcursorgen (1.0.7)
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri Jan 18 11:29:09 2019 +0200 (2019-01-18)
parents
children
line source
1 From 48c670d2678e0323d88eb72205e039f393cabe05 Mon Sep 17 00:00:00 2001
2 From: Khem Raj <raj.khem@gmail.com>
3 Date: Fri, 29 Mar 2013 08:59:00 +0400
4 Subject: [PATCH 03/39] gcc: poison-system-directories
6 Signed-off-by: Khem Raj <raj.khem@gmail.com>
8 Upstream-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(+)
19 diff --git a/gcc/common.opt b/gcc/common.opt
20 index d6ef85928f3..7b29efe3882 100644
21 --- a/gcc/common.opt
22 +++ b/gcc/common.opt
23 @@ -679,6 +679,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.
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.
34 diff --git a/gcc/config.in b/gcc/config.in
35 index 5bccb408016..1c784a8276b 100644
36 --- a/gcc/config.in
37 +++ b/gcc/config.in
38 @@ -194,6 +194,12 @@
39 #endif
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. */
51 diff --git a/gcc/configure b/gcc/configure
52 index 5c345ce0fd7..cafd05fd150 100755
53 --- a/gcc/configure
54 +++ b/gcc/configure
55 @@ -953,6 +953,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 @@ -1696,6 +1697,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 @@ -29715,6 +29718,19 @@ if test "${enable_version_specific_runtime_libs+set}" = set; then :
73 fi
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
92 diff --git a/gcc/configure.ac b/gcc/configure.ac
93 index 65dbf1f2f80..dd5b38195ce 100644
94 --- a/gcc/configure.ac
95 +++ b/gcc/configure.ac
96 @@ -6341,6 +6341,16 @@ AC_ARG_ENABLE(version-specific-runtime-libs,
97 [specify that runtime libraries should be
98 installed in a compiler-specific directory])])
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)
113 diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
114 index 255149fcfb8..cb71b60fe3c 100644
115 --- a/gcc/doc/invoke.texi
116 +++ b/gcc/doc/invoke.texi
117 @@ -303,6 +303,7 @@ Objective-C and Objective-C++ Dialects}.
118 -Wpacked -Wpacked-bitfield-compat -Wpacked-not-aligned -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 @@ -5712,6 +5713,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.
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
140 diff --git a/gcc/gcc.c b/gcc/gcc.c
141 index a716f708259..02b3cd39fc2 100644
142 --- a/gcc/gcc.c
143 +++ b/gcc/gcc.c
144 @@ -1037,6 +1037,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|static-pie:} %{L*} %(mfwrap) %(link_libgcc) " \
151 VTABLE_VERIFICATION_SPEC " " SANITIZER_EARLY_SPEC " %o " CHKP_SPEC " \
152 %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1):\
153 diff --git a/gcc/incpath.c b/gcc/incpath.c
154 index b11c6a57939..e3b7a21966f 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"
163 /* Microsoft Windows does not natively support inodes.
164 VMS has non-numeric inodes. */
165 @@ -393,6 +394,26 @@ 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[INC_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 + || (!strncmp (p->name, "/sw/include", 11))
181 + || (!strncmp (p->name, "/opt/include", 12)))
182 + warning (OPT_Wpoison_system_directories,
183 + "include location \"%s\" is unsafe for "
184 + "cross-compilation",
185 + p->name);
186 + }
187 + }
188 +#endif
189 }
191 /* Use given -I paths for #include "..." but not #include <...>, and
192 --
193 2.17.0