public inbox for gentoo-embedded@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-embedded] Auto Repair Cross Includes?
@ 2008-09-21 17:12 Ned Ludd
  2008-09-22  8:45 ` Ahmed Ammar
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Ned Ludd @ 2008-09-21 17:12 UTC (permalink / raw
  To: gentoo-embedded

[-- Attachment #1: Type: text/plain, Size: 699 bytes --]

I've been toying with an idea after seeing a patch which would abort()
when it detected host includes for cross compiles. I did not like the
idea of aborting as it prevented me from building pkgs that had the same
headers in $ROOT as /. I did like the fact there was a little QA I could
slip in there. After thinking about it a while. I said fsck the QA and
just fixed the problem. Here is what I came up with for gcc-4.2.4.. 

While in my testing I'm finding this works beautifully. However I'd like
some input from others on what they think of such an idea. 
Good/Bad/Other?

Basic goal detect ^/usr/include and rewrite it to $ROOT/usr/include if
using a cross compiler and ROOT is set.


-solar


[-- Attachment #2: Type: text/x-patch, Size: 1069 bytes --]

--- gcc/c-incpath.c	2007-09-01 08:28:30.000000000 -0700
+++ gcc/c-incpath.c	2008-09-19 20:32:27.000000000 -0700
@@ -332,6 +332,32 @@
   tails[chain] = p;
 }
 
+#ifdef CROSS_COMPILE
+/* Rewrite the include paths for cross compiles */
+char *cross_fixup_path(char *path);
+char *cross_fixup_path(char *path) {
+	char *name, *root, *ptr;
+	int len;
+
+	root = getenv("ROOT");
+	if (root == NULL)
+		return name;
+
+	if (strstr(path, "/usr/include") != path)
+		return path;
+
+	name = xstrdup(path);
+	len = strlen(root) + strlen(name) + 2;
+	ptr = (char *) xmalloc (len);
+	sprintf(ptr, "%s/%s", root, name);
+	fprintf(stderr, _("Autofixing Invalid Cross Include Path: %s -> %s\n"), name, ptr);
+	free(path);
+	path = ptr;
+	name = path;
+	return name;
+}
+#endif
+
 /* Add PATH to the include chain CHAIN. PATH must be malloc-ed and
    NUL-terminated.  */
 void
@@ -359,6 +385,11 @@
   p->construct = 0;
   p->user_supplied_p = user_supplied_p;
 
+#ifdef CROSS_COMPILE
+  path = cross_fixup_path(path);
+  p->name = path;
+#endif
+
   add_cpp_dir_path (p, chain);
 }
 

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-02-05 22:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-21 17:12 [gentoo-embedded] Auto Repair Cross Includes? Ned Ludd
2008-09-22  8:45 ` Ahmed Ammar
2008-10-26  8:14 ` Mike Frysinger
2008-10-26 16:39   ` Ned Ludd
2008-10-26 20:07     ` Mike Frysinger
2008-11-15  5:22 ` Enrico Weigelt
2009-02-05 15:32 ` Christopher Friedt
2009-02-05 22:26   ` Ned Ludd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox