summaryrefslogtreecommitdiffstats
path: root/patches/gcc-4.3.2/generic/no-host-includes.diff
blob: 586baed29af8f97a15343a16f667b61cc9673dce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#
# Submitted-By: Marc Kleine-Budde, 2006-11-03
#
# Error:
#
# No error :)
# With this patch gcc bails out if you include a host include path into the searchlist (-I)
#
# Description:
#
# inspired by:
# http://www.openembedded.org/repo/org.openembedded.dev/packages/gcc/gcc-4.1.1/zecke-no-host-includes.patch
#
---
# gcc/c-incpath.c |   28 ++++++++++++++++++++++++++++
# 1 file changed, 28 insertions(+)
#
Index: gcc-4.3.1/gcc/c-incpath.c
===================================================================
--- gcc-4.3.1.orig/gcc/c-incpath.c
+++ gcc-4.3.1/gcc/c-incpath.c
@@ -413,6 +413,34 @@ add_path (char *path, int chain, int cxx
   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.  */
+	{
+		unsigned int i;
+		const char *bad_path[] = {
+			"/usr/include",
+			"/usr/local/include",
+			"/sw/include",
+			"/opt/include",
+		};
+
+		for (i = 0; i < sizeof(bad_path)/sizeof(bad_path[0]); i++) {
+			if( strstr(p->name, bad_path[i]) == p->name ) {
+				fprintf(stderr,_("\n"
+						 "CROSS COMPILE Badness: %s in INCLUDEPATH: %s\n"
+						 "\n"),
+
+				      bad_path[i], p->name);
+
+				exit (FATAL_EXIT_CODE);
+			}
+		}
+	}
+#endif
+
   add_cpp_dir_path (p, chain);
 }