changeset 441:8d14303eeca8

Upgrade --print-file-name to search $WRAPPER_DIR/lib, to print the directories it's trying when WRAPPER_DEBUG=1, and a few in-passing cleanups.
author Rob Landley <rob@landley.net>
date Sun, 02 Nov 2008 22:49:42 -0600
parents 59fe5a276991
children 4b96ad732432
files sources/toys/gcc-uClibc.c
diffstat 1 files changed, 23 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/sources/toys/gcc-uClibc.c	Sat Nov 01 21:53:23 2008 -0500
+++ b/sources/toys/gcc-uClibc.c	Sun Nov 02 22:49:42 2008 -0600
@@ -102,8 +102,8 @@
 	int i, argcnt, liblen, lplen, sawM = 0, sawdotoa = 0, sawcES = 0;
 	char **gcc_argv, **libraries, **libpath;
 	char *dlstr, *incstr, *devprefix, *libstr;
-	char *cc, *rpath_link, *rpath, *uClibc_inc, *our_lib_path[2];
-	char *crt0_path, *crtbegin_path[2], *crtend_path[2];
+	char *cc, *rpath_link, *rpath, *uClibc_inc;
+	char *crtbegin_path[2], *crtend_path[2];
 	char *debug_wrapper=getenv("WRAPPER_DEBUG");
 
 	// For C++
@@ -179,13 +179,11 @@
 	asprintf(&rpath, "-Wl,-rpath,%s/lib", devprefix);
 	asprintf(&uClibc_inc, "%s/include/", devprefix);
 
-	asprintf(&crt0_path, "%s/lib/crt1.o", devprefix);
 	asprintf(&crti_path, "%s/lib/crti.o", devprefix);
 	asprintf(&crtn_path, "%s/lib/crtn.o", devprefix);
 
 	// profiling
 	asprintf(&gcrt1_path, "%s/lib/gcrt1.o", devprefix);
-	asprintf(our_lib_path, "-L%s/lib", devprefix);
 
 	// Figure out where the dynamic linker is.
 	dlstr = getenv("UCLIBC_DYNAMIC_LINKER");
@@ -299,23 +297,30 @@
 
 						// Find this entry in the library path.
 						for(itemp=0;;itemp++) {
-							if (itemp == lplen) {
-								asprintf(&temp, "%s/gcc/lib/%s", devprefix, temp2);
-							} else if (itemp == lplen+1) {
-								// This is so "include" finds the gcc internal
-								// include dir.  The uClibc build needs this.
+							if (itemp == lplen)
+								asprintf(&temp, "%s/gcc/lib/%s", devprefix,	temp2);
+							else if (itemp == lplen+1)
+								asprintf(&temp, "%s/lib/%s", devprefix, temp2);
+
+							// This is so "include" finds the gcc internal
+							// include dir.  The uClibc build needs this.
+							else if (itemp == lplen+2)
 								asprintf(&temp, "%s/gcc/%s", devprefix, temp2);
-							} else if (itemp == lplen+2) {
+							else if (itemp == lplen+3) {
 								temp = temp2;
 								break;
-							} else {
-								asprintf(&temp, "%s/%s", libpath[itemp],
+							} else asprintf(&temp, "%s/%s", libpath[itemp],
 											temp2);
-							}
+
+							if (debug_wrapper)
+								fprintf(stderr, "try=%s\n", temp);
+
 							if (showall) printf(":%s"+(itemp?0:1), temp);
 							else if (!access(temp, F_OK)) break;
 						}
 
+
+
 						printf("%s\n"+(showall ? 2 : 0), temp);
 						exit(0);
 
@@ -402,7 +407,8 @@
 		gcc_argv[argcnt++] = rpath_link; /* just to be safe */
 		if( libstr )
 			gcc_argv[argcnt++] = libstr;
-		gcc_argv[argcnt++] = our_lib_path[0];
+
+		asprintf(gcc_argv+(argcnt++), "-L%s/lib", devprefix);
 		asprintf(gcc_argv+(argcnt++), "-L%s/gcc/lib", devprefix);
 	}
 	if (use_stdinc && source_count) {
@@ -413,7 +419,7 @@
 				gcc_argv[argcnt++] = nostdinc_plus;
 			}
 			gcc_argv[argcnt++] = "-isystem";
-			asprintf(gcc_argv+(argcnt++), "%sc++", uClibc_inc);
+			asprintf(gcc_argv+(argcnt++), "%sc++/4.1.1", uClibc_inc);
 		}
 
 		gcc_argv[argcnt++] = "-isystem";
@@ -438,7 +444,8 @@
 				gcc_argv[argcnt++] = crtbegin_path[0];
 			}
 		}
-		if (use_start && !profile) gcc_argv[argcnt++] = crt0_path;
+		if (use_start && !profile)
+			asprintf(gcc_argv+(argcnt++), "%s/lib/crt1.o", devprefix);
 
 		// Add remaining unclaimed arguments.