OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

219 lines
8.0 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../musl/pkg/gcc/0002-gcc-poison-system-directories.patch
  5. # Copyright (C) 2020 The OpenSDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. From 0e993b1b9a33910193862d76facf34bdbe58ed01 Mon Sep 17 00:00:00 2001
  17. From: Khem Raj <raj.khem@gmail.com>
  18. Date: Fri, 29 Mar 2013 08:59:00 +0400
  19. Subject: [PATCH 02/30] gcc: poison-system-directories
  20. Add /sw/include and /opt/include based on the original
  21. zecke-no-host-includes.patch patch. The original patch checked for
  22. /usr/include, /sw/include and /opt/include and then triggered a failure and
  23. aborted.
  24. Instead, we add the two missing items to the current scan. If the user
  25. wants this to be a failure, they can add "-Werror=poison-system-directories".
  26. Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
  27. Signed-off-by: Khem Raj <raj.khem@gmail.com>
  28. Upstream-Status: Pending
  29. ---
  30. gcc/common.opt | 4 ++++
  31. gcc/config.in | 6 ++++++
  32. gcc/configure | 16 ++++++++++++++++
  33. gcc/configure.ac | 10 ++++++++++
  34. gcc/doc/invoke.texi | 9 +++++++++
  35. gcc/gcc.c | 2 ++
  36. gcc/incpath.c | 21 +++++++++++++++++++++
  37. 7 files changed, 68 insertions(+)
  38. diff --git a/gcc/common.opt b/gcc/common.opt
  39. index 3ec7743eae8..d3c3e51dcb0 100644
  40. --- a/gcc/common.opt
  41. +++ b/gcc/common.opt
  42. @@ -682,6 +682,10 @@ Wreturn-local-addr
  43. Common Var(warn_return_local_addr) Init(1) Warning
  44. Warn about returning a pointer/reference to a local or temporary variable.
  45. +Wpoison-system-directories
  46. +Common Var(flag_poison_system_directories) Init(1) Warning
  47. +Warn for -I and -L options using system directories if cross compiling
  48. +
  49. Wshadow
  50. Common Var(warn_shadow) Warning
  51. Warn when one variable shadows another. Same as -Wshadow=global.
  52. diff --git a/gcc/config.in b/gcc/config.in
  53. index 364eba47737..9551c0dfdf9 100644
  54. --- a/gcc/config.in
  55. +++ b/gcc/config.in
  56. @@ -224,6 +224,12 @@
  57. #endif
  58. +/* Define to warn for use of native system header directories */
  59. +#ifndef USED_FOR_TARGET
  60. +#undef ENABLE_POISON_SYSTEM_DIRECTORIES
  61. +#endif
  62. +
  63. +
  64. /* Define if you want all operations on RTL (the basic data structure of the
  65. optimizer and back end) to be checked for dynamic type safety at runtime.
  66. This is quite expensive. */
  67. diff --git a/gcc/configure b/gcc/configure
  68. index eb6061c1631..90e3be864f8 100755
  69. --- a/gcc/configure
  70. +++ b/gcc/configure
  71. @@ -1010,6 +1010,7 @@ with_system_zlib
  72. enable_maintainer_mode
  73. enable_link_mutex
  74. enable_version_specific_runtime_libs
  75. +enable_poison_system_directories
  76. enable_plugin
  77. enable_host_shared
  78. enable_libquadmath_support
  79. @@ -1766,6 +1767,8 @@ Optional Features:
  80. --enable-version-specific-runtime-libs
  81. specify that runtime libraries should be installed
  82. in a compiler-specific directory
  83. + --enable-poison-system-directories
  84. + warn for use of native system header directories
  85. --enable-plugin enable plugin support
  86. --enable-host-shared build host code as shared libraries
  87. --disable-libquadmath-support
  88. @@ -30266,6 +30269,19 @@ if test "${enable_version_specific_runtime_libs+set}" = set; then :
  89. fi
  90. +# Check whether --enable-poison-system-directories was given.
  91. +if test "${enable_poison_system_directories+set}" = set; then :
  92. + enableval=$enable_poison_system_directories;
  93. +else
  94. + enable_poison_system_directories=no
  95. +fi
  96. +
  97. +if test "x${enable_poison_system_directories}" = "xyes"; then
  98. +
  99. +$as_echo "#define ENABLE_POISON_SYSTEM_DIRECTORIES 1" >>confdefs.h
  100. +
  101. +fi
  102. +
  103. # Substitute configuration variables
  104. diff --git a/gcc/configure.ac b/gcc/configure.ac
  105. index 715fcba0482..f42006e5476 100644
  106. --- a/gcc/configure.ac
  107. +++ b/gcc/configure.ac
  108. @@ -6600,6 +6600,16 @@ AC_ARG_ENABLE(version-specific-runtime-libs,
  109. [specify that runtime libraries should be
  110. installed in a compiler-specific directory])])
  111. +AC_ARG_ENABLE([poison-system-directories],
  112. + AS_HELP_STRING([--enable-poison-system-directories],
  113. + [warn for use of native system header directories]),,
  114. + [enable_poison_system_directories=no])
  115. +if test "x${enable_poison_system_directories}" = "xyes"; then
  116. + AC_DEFINE([ENABLE_POISON_SYSTEM_DIRECTORIES],
  117. + [1],
  118. + [Define to warn for use of native system header directories])
  119. +fi
  120. +
  121. # Substitute configuration variables
  122. AC_SUBST(subdirs)
  123. AC_SUBST(srcdir)
  124. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
  125. index a2794a67d1e..dfed8fd25a8 100644
  126. --- a/gcc/doc/invoke.texi
  127. +++ b/gcc/doc/invoke.texi
  128. @@ -348,6 +348,7 @@ Objective-C and Objective-C++ Dialects}.
  129. -Wpacked -Wno-packed-bitfield-compat -Wpacked-not-aligned -Wpadded @gol
  130. -Wparentheses -Wno-pedantic-ms-format @gol
  131. -Wpointer-arith -Wno-pointer-compare -Wno-pointer-to-int-cast @gol
  132. +-Wno-poison-system-directories @gol
  133. -Wno-pragmas -Wno-prio-ctor-dtor -Wredundant-decls @gol
  134. -Wrestrict -Wno-return-local-addr -Wreturn-type @gol
  135. -Wno-scalar-storage-order -Wsequence-point @gol
  136. @@ -6924,6 +6925,14 @@ made up of data only and thus requires no special treatment. But, for
  137. most targets, it is made up of code and thus requires the stack to be
  138. made executable in order for the program to work properly.
  139. +@item -Wno-poison-system-directories
  140. +@opindex Wno-poison-system-directories
  141. +Do not warn for @option{-I} or @option{-L} options using system
  142. +directories such as @file{/usr/include} when cross compiling. This
  143. +option is intended for use in chroot environments when such
  144. +directories contain the correct headers and libraries for the target
  145. +system rather than the host.
  146. +
  147. @item -Wfloat-equal
  148. @opindex Wfloat-equal
  149. @opindex Wno-float-equal
  150. diff --git a/gcc/gcc.c b/gcc/gcc.c
  151. index 9f790db0daf..b2200c5185a 100644
  152. --- a/gcc/gcc.c
  153. +++ b/gcc/gcc.c
  154. @@ -1041,6 +1041,8 @@ proper position among the other output files. */
  155. "%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \
  156. "%X %{o*} %{e*} %{N} %{n} %{r}\
  157. %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!r:%{!nostartfiles:%S}}} \
  158. + %{Wno-poison-system-directories:--no-poison-system-directories} \
  159. + %{Werror=poison-system-directories:--error-poison-system-directories} \
  160. %{static|no-pie|static-pie:} %@{L*} %(mfwrap) %(link_libgcc) " \
  161. VTABLE_VERIFICATION_SPEC " " SANITIZER_EARLY_SPEC " %o "" \
  162. %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1):\
  163. diff --git a/gcc/incpath.c b/gcc/incpath.c
  164. index 8a2bda00f80..9098ab044ab 100644
  165. --- a/gcc/incpath.c
  166. +++ b/gcc/incpath.c
  167. @@ -26,6 +26,7 @@
  168. #include "intl.h"
  169. #include "incpath.h"
  170. #include "cppdefault.h"
  171. +#include "diagnostic-core.h"
  172. /* Microsoft Windows does not natively support inodes.
  173. VMS has non-numeric inodes. */
  174. @@ -393,6 +394,26 @@ merge_include_chains (const char *sysroot, cpp_reader *pfile, int verbose)
  175. }
  176. fprintf (stderr, _("End of search list.\n"));
  177. }
  178. +
  179. +#ifdef ENABLE_POISON_SYSTEM_DIRECTORIES
  180. + if (flag_poison_system_directories)
  181. + {
  182. + struct cpp_dir *p;
  183. +
  184. + for (p = heads[INC_QUOTE]; p; p = p->next)
  185. + {
  186. + if ((!strncmp (p->name, "/usr/include", 12))
  187. + || (!strncmp (p->name, "/usr/local/include", 18))
  188. + || (!strncmp (p->name, "/usr/X11R6/include", 18))
  189. + || (!strncmp (p->name, "/sw/include", 11))
  190. + || (!strncmp (p->name, "/opt/include", 12)))
  191. + warning (OPT_Wpoison_system_directories,
  192. + "include location \"%s\" is unsafe for "
  193. + "cross-compilation",
  194. + p->name);
  195. + }
  196. + }
  197. +#endif
  198. }
  199. /* Use given -I paths for #include "..." but not #include <...>, and
  200. --
  201. 2.27.0