The cirros image was rebuilt against the 3.13.0-83 kernel, drivers e1000e, igbvf...
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / package / gcc / arc-2014.12 / 910-gcc-poison-system-directories.patch
1 From 160397ef3c3331099af028f1b8d3e085b07d88ad 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 16/35] gcc: poison-system-directories
5
6 Adapted to Buildroot and gcc arc-4.8-R3 by Thomas Petazzoni,
7 especially the addition of the BR_COMPILER_PARANOID_UNSAFE_PATH
8 environment variable.
9
10 Signed-off-by: Khem Raj <raj.khem@gmail.com>
11 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
12
13 Upstream-Status: Inappropriate [distribution: codesourcery]
14 ---
15  gcc/Makefile.in     |    2 +-
16  gcc/common.opt      |    4 ++++
17  gcc/config.in       |    6 ++++++
18  gcc/configure       |   20 ++++++++++++++++++--
19  gcc/configure.ac    |   10 ++++++++++
20  gcc/doc/invoke.texi |    9 +++++++++
21  gcc/gcc.c           |    2 ++
22  gcc/incpath.c       |   19 +++++++++++++++++++
23  8 files changed, 69 insertions(+), 3 deletions(-)
24
25 Index: b/gcc/common.opt
26 ===================================================================
27 --- a/gcc/common.opt
28 +++ b/gcc/common.opt
29 @@ -595,6 +595,10 @@
30  Common Var(pedantic) Warning
31  Issue warnings needed for strict compliance to the standard
32  
33 +Wpoison-system-directories
34 +Common Var(flag_poison_system_directories) Init(1) Warning
35 +Warn for -I and -L options using system directories if cross compiling
36 +
37  Wshadow
38  Common Var(warn_shadow) Warning
39  Warn when one local variable shadows another
40 Index: b/gcc/config.in
41 ===================================================================
42 --- a/gcc/config.in
43 +++ b/gcc/config.in
44 @@ -138,6 +138,12 @@
45  #endif
46  
47  
48 +/* Define to warn for use of native system header directories */
49 +#ifndef USED_FOR_TARGET
50 +#undef ENABLE_POISON_SYSTEM_DIRECTORIES
51 +#endif
52 +
53 +
54  /* Define if you want all operations on RTL (the basic data structure of the
55     optimizer and back end) to be checked for dynamic type safety at runtime.
56     This is quite expensive. */
57 Index: b/gcc/configure
58 ===================================================================
59 --- a/gcc/configure
60 +++ b/gcc/configure
61 @@ -917,6 +917,7 @@
62  with_system_zlib
63  enable_maintainer_mode
64  enable_version_specific_runtime_libs
65 +enable_poison_system_directories
66  enable_plugin
67  enable_libquadmath_support
68  with_linker_hash_style
69 @@ -1630,6 +1631,8 @@
70    --enable-version-specific-runtime-libs
71                            specify that runtime libraries should be installed
72                            in a compiler-specific directory
73 +  --enable-poison-system-directories
74 +                          warn for use of native system header directories
75    --enable-plugin         enable plugin support
76    --disable-libquadmath-support
77                            disable libquadmath support for Fortran
78 @@ -27103,6 +27106,19 @@
79  fi
80  
81  
82 +# Check whether --enable-poison-system-directories was given.
83 +if test "${enable_poison_system_directories+set}" = set; then :
84 +  enableval=$enable_poison_system_directories;
85 +else
86 +  enable_poison_system_directories=no
87 +fi
88 +
89 +if test "x${enable_poison_system_directories}" = "xyes"; then
90 +
91 +$as_echo "#define ENABLE_POISON_SYSTEM_DIRECTORIES 1" >>confdefs.h
92 +
93 +fi
94 +
95  # Substitute configuration variables
96  
97  
98 Index: b/gcc/configure.ac
99 ===================================================================
100 --- a/gcc/configure.ac
101 +++ b/gcc/configure.ac
102 @@ -5063,6 +5063,16 @@
103                  [specify that runtime libraries should be
104                   installed in a compiler-specific directory])])
105  
106 +AC_ARG_ENABLE([poison-system-directories],
107 +             AS_HELP_STRING([--enable-poison-system-directories],
108 +                            [warn for use of native system header directories]),,
109 +             [enable_poison_system_directories=no])
110 +if test "x${enable_poison_system_directories}" = "xyes"; then
111 +  AC_DEFINE([ENABLE_POISON_SYSTEM_DIRECTORIES],
112 +           [1],
113 +           [Define to warn for use of native system header directories])
114 +fi
115 +
116  # Substitute configuration variables
117  AC_SUBST(subdirs)
118  AC_SUBST(srcdir)
119 Index: b/gcc/doc/invoke.texi
120 ===================================================================
121 --- a/gcc/doc/invoke.texi
122 +++ b/gcc/doc/invoke.texi
123 @@ -258,6 +258,7 @@
124  -Woverlength-strings  -Wpacked  -Wpacked-bitfield-compat  -Wpadded @gol
125  -Wparentheses  -Wpedantic-ms-format -Wno-pedantic-ms-format @gol
126  -Wpointer-arith  -Wno-pointer-to-int-cast @gol
127 +-Wno-poison-system-directories @gol
128  -Wredundant-decls  -Wno-return-local-addr @gol
129  -Wreturn-type  -Wsequence-point  -Wshadow @gol
130  -Wsign-compare  -Wsign-conversion  -Wsizeof-pointer-memaccess @gol
131 @@ -4025,6 +4026,14 @@
132   for most targets, it is made up of code and thus requires the stack
133   to be made executable in order for the program to work properly.
134  
135 +@item -Wno-poison-system-directories
136 +@opindex Wno-poison-system-directories
137 +Do not warn for @option{-I} or @option{-L} options using system
138 +directories such as @file{/usr/include} when cross compiling.  This
139 +option is intended for use in chroot environments when such
140 +directories contain the correct headers and libraries for the target
141 +system rather than the host.
142 +
143  @item -Wfloat-equal
144  @opindex Wfloat-equal
145  @opindex Wno-float-equal
146 Index: b/gcc/gcc.c
147 ===================================================================
148 --- a/gcc/gcc.c
149 +++ b/gcc/gcc.c
150 @@ -740,6 +740,8 @@
151     "%{fuse-ld=*:-fuse-ld=%*}\
152      %X %{o*} %{e*} %{N} %{n} %{r}\
153      %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!nostartfiles:%S}}\
154 +    %{Wno-poison-system-directories:--no-poison-system-directories}\
155 +    %{Werror=poison-system-directories:--error-poison-system-directories}\
156      %{static:} %{L*} %(mfwrap) %(link_libgcc) " SANITIZER_EARLY_SPEC " %o\
157      %{fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)}\
158      %{fgnu-tm:%:include(libitm.spec)%(link_itm)}\
159 @@ -3990,6 +3992,12 @@
160        gcc_assert (!compare_debug_opt);
161      }
162  
163 +  temp = getenv("BR_COMPILER_PARANOID_UNSAFE_PATH");
164 +  if (temp && strlen(temp) > 0)
165 +    {
166 +      save_switch("-Werror=poison-system-directories", 0, NULL, false, true);
167 +    }
168 +
169    /* Set up the search paths.  We add directories that we expect to
170       contain GNU Toolchain components before directories specified by
171       the machine description so that we will find GNU components (like
172 Index: b/gcc/incpath.c
173 ===================================================================
174 --- a/gcc/incpath.c
175 +++ b/gcc/incpath.c
176 @@ -28,6 +28,7 @@
177  #include "intl.h"
178  #include "incpath.h"
179  #include "cppdefault.h"
180 +#include "diagnostic-core.h"
181  
182  /* Microsoft Windows does not natively support inodes.
183     VMS has non-numeric inodes.  */
184 @@ -382,6 +383,24 @@
185         }
186        fprintf (stderr, _("End of search list.\n"));
187      }
188 +
189 +#ifdef ENABLE_POISON_SYSTEM_DIRECTORIES
190 +  if (flag_poison_system_directories)
191 +    {
192 +       struct cpp_dir *p;
193 +
194 +       for (p = heads[QUOTE]; p; p = p->next)
195 +         {
196 +          if ((!strncmp (p->name, "/usr/include", 12))
197 +              || (!strncmp (p->name, "/usr/local/include", 18))
198 +              || (!strncmp (p->name, "/usr/X11R6/include", 18)))
199 +            warning (OPT_Wpoison_system_directories,
200 +                     "include location \"%s\" is unsafe for "
201 +                     "cross-compilation",
202 +                     p->name);
203 +         }
204 +    }
205 +#endif
206  }
207  
208  /* Use given -I paths for #include "..." but not #include <...>, and
209 Index: b/gcc/config/arc/arc.h
210 ===================================================================
211 --- a/gcc/config/arc/arc.h
212 +++ b/gcc/config/arc/arc.h
213 @@ -205,6 +205,8 @@
214  %{!fsyntax-only:%{!c:%{!M:%{!MM:%{!E:%{!S:\
215      %(linker) %l " LINK_PIE_SPEC "%X %{o*} %{A} %{d} %{e*} %{m} %{N} %{n} %{r}\
216      %{s} %{t} %{u*} %{x} %{z} %{Z} %{!A:%{!nostdlib:%{!nostartfiles:%S}}}\
217 +    %{Wno-poison-system-directories:--no-poison-system-directories}\
218 +    %{Werror=poison-system-directories:--error-poison-system-directories}\
219      %{static:} %{L*} %(mfwrap) %(link_libgcc) %o\
220      %{fopenmp:%:include(libgomp.spec)%(link_gomp)} %(mflib)\
221      %{fprofile-arcs|fprofile-generate|coverage:-lgcov}\