summaryrefslogtreecommitdiff
blob: 94abba89306cbbcb1038b10fb99b0bf09f185bc4 (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
57
Description:	Add dummy -arch option with simplistic check.
Author:			Heiko Przybyl <zuxez@cs.tu-berlin.de>

diff -pruN gcc-5664.orig/gcc/gcc.c gcc-5664/gcc/gcc.c
--- gcc-5664.orig/gcc/gcc.c	2010-09-21 22:28:11.000000000 +0200
+++ gcc-5664/gcc/gcc.c	2010-09-21 22:28:24.000000000 +0200
@@ -88,6 +88,8 @@ compilation is specified by a string cal
 #include "flags.h"
 #include "opts.h"
 
+#include <mach-o/arch.h>
+
 /* By default there is no special suffix for target executables.  */
 /* FIXME: when autoconf is fixed, remove the host check - dj */
 #if defined(TARGET_EXECUTABLE_SUFFIX) && defined(HOST_EXECUTABLE_SUFFIX)
--- gcc-5664/gcc/gcc.c.orig	2010-09-22 01:30:04.000000000 +0200
+++ gcc-5664/gcc/gcc.c	2010-09-22 01:36:52.000000000 +0200
@@ -1401,6 +1401,39 @@ translate_options (int *argcp, const cha
 	    nskip += 1;
 	  else if (! strcmp (p, "Xassembler"))
 	    nskip += 1;
+	  /* GENTOO_PORTAGE Allow but filter -arch. */
+	  if (! strcmp (p, "arch")) {
+		if (i + 1 == argc)
+			fatal ("argument to `-arch' is missing");
+		/* Check current arch vs. given arch if possible. */
+		const NXArchInfo *ai = NXGetLocalArchInfo();
+		if (ai) {
+			/* Returns the most generic setting */
+			/* aka "i386", "x86_64", "ppc", "ppc64", "arm". */
+			const NXArchInfo *gai = NXGetArchInfoFromCpuType(ai->cputype, CPU_SUBTYPE_MULTIPLE);
+			if (gai) {
+				const char *name = gai->name;
+#ifdef __LP64__
+				/* Make sure x64 on 32bit kernel is set correctly. */
+				if (gai->cputype == CPU_TYPE_I386) {
+					name = "x86_64";
+				}
+				else if (gai->cputype == CPU_TYPE_POWERPC) {
+					name = "ppc64";
+				}                       
+#endif                              
+				if (strcmp(name, argv[i + 1]) != 0) {
+					fatal ("`-arch %s' does not match current compiler arch `%s'",
+						argv[i + 1], name);
+				}                       
+			}                           
+		}                               
+
+		/* Skip argument. */
+		i += 2;
+		/* Don't add option to the new env. */
+		nskip = 0;
+	  }
 
 	  /* Watch out for an option at the end of the command line that
 	     is missing arguments, and avoid skipping past the end of the