]> code.ossystems Code Review - openembedded-core.git/commitdiff
gcc: Update poisoned include path checking
authorMark Hatle <mark.hatle@windriver.com>
Wed, 29 Sep 2010 20:18:01 +0000 (15:18 -0500)
committerRichard Purdie <rpurdie@linux.intel.com>
Fri, 1 Oct 2010 15:30:43 +0000 (16:30 +0100)
[BUGID #374]

The poison directory patch that was included with gcc-4.5.0 was not previously
enabled due to the lack of the configure file changes.

The patch has been updated to include the configure fragment.  It was also noted
that this patch preformed nearly the same functions as the
zecke-no-host-includes patch, but with slightly different directories.

The directories scanned were added from the zecke-no-host-includes patch to
the new gcc-poison-dir-extend.patch.

The other difference with the zecke patch is that poisoned headers is no longer
an immediate fatal error.  There may be instances where someone wants to do
this.

Adding -Werror=poison-system-directories to the CFLAGS would restore the
behavior.

Also fix a small problem where --help=warnings on gcc wouldn't return the
poison-system-directories as a valid option, even though it was.

Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
meta/recipes-devtools/gcc/gcc-4.5.0.inc
meta/recipes-devtools/gcc/gcc-4.5.0/gcc-poison-dir-extend.patch [new file with mode: 0644]
meta/recipes-devtools/gcc/gcc-4.5.0/gcc-poison-system-directories.patch
meta/recipes-devtools/gcc/gcc-4.5.0/zecke-no-host-includes.patch [deleted file]
meta/recipes-devtools/gcc/gcc-cross_4.5.0.bb

index 2b5c82975a14088c37ae71eeca05ec85ac11faff..9a0a5e5671cf1be11014f5d3a735f73afe775914 100644 (file)
@@ -44,6 +44,7 @@ SRC_URI = "${GNU_MIRROR}/gcc/gcc-${PV}/gcc-${PV}.tar.bz2 \
            file://arm-softfloat.patch \
            file://zecke-xgcc-cpp.patch \
            file://gcc-poison-system-directories.patch \
+           file://gcc-poison-dir-extend.patch \
            file://gcc-4.3.3-SYSROOT_CFLAGS_FOR_TARGET.patch \
           file://64bithack.patch \
           file://optional_libstdc.patch \
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-poison-dir-extend.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/gcc-poison-dir-extend.patch
new file mode 100644 (file)
index 0000000..d171207
--- /dev/null
@@ -0,0 +1,24 @@
+Add /sw/include and /opt/include based on the original
+zecke-no-host-includes.patch patch.  The original patch checked for
+/usr/include, /sw/include and /opt/include and then triggered a failure and
+aborted.
+
+Instead, we add the two missing items to the current scan.  If the user
+wants this to be a failure, they can add "-Werror=poison-system-directories".
+
+Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
+
+diff -ur gcc-4.5.0.orig/gcc/incpath.c gcc-4.5.0/gcc/incpath.c
+--- gcc-4.5.0.orig/gcc/incpath.c       2010-09-29 14:58:31.358975524 -0500
++++ gcc-4.5.0/gcc/incpath.c    2010-09-29 15:08:02.065975516 -0500
+@@ -363,7 +363,9 @@
+          {
+           if ((!strncmp (p->name, "/usr/include", 12))
+               || (!strncmp (p->name, "/usr/local/include", 18))
+-              || (!strncmp (p->name, "/usr/X11R6/include", 18)))
++              || (!strncmp (p->name, "/usr/X11R6/include", 18))
++              || (!strncmp (p->name, "/sw/include", 11))
++              || (!strncmp (p->name, "/opt/include", 12)))
+             warning (OPT_Wpoison_system_directories,
+                      "include location \"%s\" is unsafe for "
+                      "cross-compilation",
index e68a2de2a2065e3a62390f97ba57d5c884ab930c..04043ff0b7264d9000413225d848e2c029f5bf86 100644 (file)
@@ -34,7 +34,7 @@ Index: gcc-4.5.0/gcc/common.opt
  Warn when padding is required to align structure members
  
 +Wpoison-system-directories
-+Common Var(flag_poison_system_directories) Init(1)
++Common Var(flag_poison_system_directories) Init(1) Warning
 +Warn for -I and -L options using system directories if cross compiling
 +
  Wshadow
@@ -147,3 +147,55 @@ Index: gcc-4.5.0/gcc/incpath.c
  }
  
  /* Use given -I paths for #include "..." but not #include <...>, and
+diff -ur gcc-4.5.0.orig/gcc/Makefile.in gcc-4.5.0/gcc/Makefile.in
+--- gcc-4.5.0.orig/gcc/Makefile.in     2010-09-29 17:13:49.164088845 -0500
++++ gcc-4.5.0/gcc/Makefile.in  2010-09-29 18:48:19.300178501 -0500
+@@ -1965,7 +1965,7 @@
+ incpath.o: incpath.c incpath.h $(CONFIG_H) $(SYSTEM_H) $(CPPLIB_H) \
+               intl.h prefix.h coretypes.h $(TM_H) cppdefault.h $(TARGET_H) \
+-              $(MACHMODE_H)
++              $(MACHMODE_H) $(FLAGS_H) toplev.h
+ c-decl.o : c-decl.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
+     $(RTL_H) $(C_TREE_H) $(GGC_H) $(TARGET_H) $(FLAGS_H) $(FUNCTION_H) output.h \
+diff -ur gcc-4.5.0.orig/gcc/configure gcc-4.5.0/gcc/configure
+--- gcc-4.5.0.orig/gcc/configure       2010-09-29 14:58:31.702054881 -0500
++++ gcc-4.5.0/gcc/configure    2010-09-29 18:46:31.486068500 -0500
+@@ -913,6 +913,7 @@
+ enable_maintainer_mode
+ enable_version_specific_runtime_libs
+ with_slibdir
++enable_poison_system_directories
+ enable_plugin
+ enable_target_optspace
+ '
+@@ -1621,6 +1622,8 @@
+   --enable-version-specific-runtime-libs
+                           specify that runtime libraries should be
+                           installed in a compiler-specific directory
++  --enable-poison-system-directories
++                          warn for use of native system header directories
+   --enable-plugin         enable plugin support
+ Optional Packages:
+@@ -25339,6 +25377,19 @@
++# Check whether --enable-poison-system-directories was given.
++if test "${enable_poison_system_directories+set}" = set; then :
++  enableval=$enable_poison_system_directories;
++else
++  enable_poison_system_directories=no
++fi
++
++if test "x${enable_poison_system_directories}" = "xyes"; then
++
++$as_echo "#define ENABLE_POISON_SYSTEM_DIRECTORIES 1" >>confdefs.h
++
++fi
++
+ # Substitute configuration variables
diff --git a/meta/recipes-devtools/gcc/gcc-4.5.0/zecke-no-host-includes.patch b/meta/recipes-devtools/gcc/gcc-4.5.0/zecke-no-host-includes.patch
deleted file mode 100644 (file)
index 4ccf35f..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-Index: gcc-4.4+svnr145550/gcc/incpath.c
-===================================================================
---- gcc-4.4+svnr145550.orig/gcc/incpath.c      2009-04-04 13:48:31.000000000 -0700
-+++ gcc-4.4+svnr145550/gcc/incpath.c   2009-04-04 14:49:29.000000000 -0700
-@@ -417,6 +417,26 @@
-   p->construct = 0;
-   p->user_supplied_p = user_supplied_p;
-+#ifdef CROSS_COMPILE
-+    /* A common error when cross compiling is including
-+    host headers. This code below will try to fail fast
-+    for cross compiling. Currently we consider /usr/include,
-+    /opt/include and /sw/include as harmful.  */
-+      {
-+              /* printf("Adding Path: %s\n", p->name ); */
-+              if( strstr(p->name, "/usr/include" ) == p->name ) {
-+                      fprintf(stderr, _("CROSS COMPILE Badness: /usr/include in INCLUDEPATH: %s\n"), p->name);
-+                      abort();
-+              } else if( strstr(p->name, "/sw/include") == p->name ) {
-+                      fprintf(stderr, _("CROSS COMPILE Badness: /sw/include in INCLUDEPATH: %s\n"), p->name);
-+                      abort();
-+              } else if( strstr(p->name, "/opt/include") == p->name ) {
-+                      fprintf(stderr, _("CROSS COMPILE Badness: /opt/include in INCLUDEPATH: %s\n"), p->name);
-+                      abort();
-+               }
-+      }
-+#endif
-+
-   add_cpp_dir_path (p, chain);
- }
index 545beebd1aeff3fad4e0e003369e119927a46633..7f67acf28d11a5ae1d74c95d026c7d1b0da303b8 100644 (file)
@@ -3,8 +3,6 @@ PR = "r11"
 require gcc-${PV}.inc
 require gcc-cross4.inc
 
-SRC_URI_append_fail-fast = " file://zecke-no-host-includes.patch "
-
 EXTRA_OECONF += "--disable-libunwind-exceptions \
                  --with-mpfr=${STAGING_DIR_NATIVE}${prefix_native} \
                  --with-system-zlib "