This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[5/8] Make collect2 honour --sysroot

This patch adds --sysroot support to collect2.  Specifically, it makes
sure that ignore_library strips the sysroot directory from the start
of a library path before comparing it against aix_std_libs.

I haven't tried to cope with cases where there are two "/"s after
the sysroot path, or where the sysroot path ends in more "/"s than
the paths themselves.  These situations would not occur in the
automatically-generated paths we care about, and I think allowing
slash variations is conceptually a separate change.  (Slash variations
would also allow native toolchains to treat "///unix" as "/unix",
for example.)

Tested on powerpc-ibm-aix6.1 and x86_64-linux-gnu.  OK to install?


	* collect2.c (target_system_root): New variable.
	(main): Handle --sysroot=.
	(ignore_library): Strip the sysroot from the library path.

Index: gcc/collect2.c
--- gcc/collect2.c	2009-06-02 13:06:05.000000000 +0100
+++ gcc/collect2.c	2009-06-02 13:06:07.000000000 +0100
@@ -217,6 +217,14 @@ static const char *ldd_file_name;	/* pat
 struct obstack temporary_obstack;
 char * temporary_firstobj;
+/* A string that must be prepended to a target OS path in order to find
+   it on the host system.  */
+static const char *target_system_root = TARGET_SYSTEM_ROOT;
+static const char *target_system_root = "";
 /* Structure to hold all the directories in which to search for files to
    execute.  */
@@ -1220,6 +1228,8 @@ main (int argc, char **argv)
+	      else if (strncmp (arg, "--sysroot=", 10) == 0)
+		target_system_root = arg + 10;
@@ -2449,6 +2459,15 @@ static int ignore_library (const char *)
 ignore_library (const char *name)
   const char *const *p = &aix_std_libs[0];
+  size_t length;
+  if (target_system_root[0] != '\0')
+    {
+      length = strlen (target_system_root);
+      if (strncmp (name, target_system_root, length) != 0)
+	return 0;
+      name += length;
+    }
   while (*p)
     if (! strcmp (name, *p++))
       return 1;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]