Mercurial > hg > aboriginal
annotate sources/toys/ccwrap.c @ 547:65b71915c836
Clean up ccwrap some more.
author | Rob Landley <rob@landley.net> |
---|---|
date | Tue, 23 Dec 2008 01:19:10 -0600 |
parents | a7f128fc53b5 |
children | b826a6168464 |
rev | line source |
---|---|
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
1 /* vi: set ts=4 :*/ |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
2 /* |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
3 * Copyright (C) 2000 Manuel Novoa III |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
4 * Copyright (C) 2002-2003 Erik Andersen |
547 | 5 * Copyright (C) 2006-2008 Rob Landley <rob@landley.net> |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
6 * |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
7 * Wrapper to use uClibc with gcc, and make gcc relocatable. |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
8 */ |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
9 |
16
7946bc54424b
Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents:
14
diff
changeset
|
10 #define _GNU_SOURCE |
433
c7a1631711f4
Smallish wrapper cleanups, more to come.
Rob Landley <rob@landley.net>
parents:
403
diff
changeset
|
11 #include <alloca.h> |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
12 #include <stdio.h> |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
13 #include <stdlib.h> |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
14 #include <stdarg.h> |
76
5703436a408e
Update the uClibc snapshot and make config changes it needs.
Rob Landley <rob@landley.net>
parents:
65
diff
changeset
|
15 #include <string.h> |
57
f393a630a5b3
Weird ordering dependency. I think it's a uClibc bug?
Rob Landley <rob@landley.net>
parents:
56
diff
changeset
|
16 #include <strings.h> |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
17 #include <unistd.h> |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
18 #include <errno.h> |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
19 #include <sys/stat.h> |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
20 #include <sys/wait.h> |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
21 |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
22 static char *topdir; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
23 static char static_linking[] = "-static"; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
24 static char nostdinc[] = "-nostdinc"; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
25 static char nostartfiles[] = "-nostartfiles"; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
26 static char nodefaultlibs[] = "-nodefaultlibs"; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
27 static char nostdlib[] = "-nostdlib"; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
28 |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
29 // For C++ |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
30 static char nostdinc_plus[] = "-nostdinc++"; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
31 |
438
e9f3011ec40d
Teach wrapper about libgcc_eh.a for static linking.
Rob Landley <rob@landley.net>
parents:
435
diff
changeset
|
32 // #define GIMME_AN_S for wrapper to support --enable-shared toolchain. |
e9f3011ec40d
Teach wrapper about libgcc_eh.a for static linking.
Rob Landley <rob@landley.net>
parents:
435
diff
changeset
|
33 |
390
a9a9eee9e620
Teach the wrapper script to do the libgcc_s --as-needed stuff when
Rob Landley <rob@landley.net>
parents:
257
diff
changeset
|
34 #ifdef GIMME_AN_S |
438
e9f3011ec40d
Teach wrapper about libgcc_eh.a for static linking.
Rob Landley <rob@landley.net>
parents:
435
diff
changeset
|
35 #define ADD_GCC_S() \ |
e9f3011ec40d
Teach wrapper about libgcc_eh.a for static linking.
Rob Landley <rob@landley.net>
parents:
435
diff
changeset
|
36 do { \ |
e9f3011ec40d
Teach wrapper about libgcc_eh.a for static linking.
Rob Landley <rob@landley.net>
parents:
435
diff
changeset
|
37 if (!use_static_linking) \ |
e9f3011ec40d
Teach wrapper about libgcc_eh.a for static linking.
Rob Landley <rob@landley.net>
parents:
435
diff
changeset
|
38 gcc_argv[argcnt++] = "-Wl,--as-needed,-lgcc_s,--no-as-needed"; \ |
e9f3011ec40d
Teach wrapper about libgcc_eh.a for static linking.
Rob Landley <rob@landley.net>
parents:
435
diff
changeset
|
39 else gcc_argv[argcnt++] = "-lgcc_eh"; \ |
e9f3011ec40d
Teach wrapper about libgcc_eh.a for static linking.
Rob Landley <rob@landley.net>
parents:
435
diff
changeset
|
40 } while (0); |
390
a9a9eee9e620
Teach the wrapper script to do the libgcc_s --as-needed stuff when
Rob Landley <rob@landley.net>
parents:
257
diff
changeset
|
41 #else |
a9a9eee9e620
Teach the wrapper script to do the libgcc_s --as-needed stuff when
Rob Landley <rob@landley.net>
parents:
257
diff
changeset
|
42 #define ADD_GCC_S() |
a9a9eee9e620
Teach the wrapper script to do the libgcc_s --as-needed stuff when
Rob Landley <rob@landley.net>
parents:
257
diff
changeset
|
43 #endif |
a9a9eee9e620
Teach the wrapper script to do the libgcc_s --as-needed stuff when
Rob Landley <rob@landley.net>
parents:
257
diff
changeset
|
44 |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
45 // Confirm that a regular file exists, and (optionally) has the executable bit. |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
46 int is_file(char *filename, int has_exe) |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
47 { |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
48 // Confirm it has the executable bit set, if necessary. |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
49 if (!has_exe || !access(filename, X_OK)) { |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
50 struct stat st; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
51 |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
52 // Confirm it exists and is not a directory. |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
53 if (!stat(filename, &st) && S_ISREG(st.st_mode)) return 1; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
54 } |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
55 return 0; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
56 } |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
57 |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
58 // Find an executable in a colon-separated path |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
59 |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
60 char *find_in_path(char *path, char *filename, int has_exe) |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
61 { |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
62 char *cwd = getcwd(NULL, 0); |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
63 |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
64 if (index(filename, '/') && is_file(filename, has_exe)) |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
65 return strdup(filename); |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
66 |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
67 for (;;) { |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
68 char *str, *next = path ? index(path, ':') : NULL; |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
69 int len = next ? next-path : strlen(path); |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
70 |
64
51b8220c37e7
Make wrapper script work when /bin is a symlink to /usr/bin and the wrapper
Rob Landley <rob@landley.net>
parents:
63
diff
changeset
|
71 // The +3 is a corner case: if strlen(filename) is 1, make sure we |
51b8220c37e7
Make wrapper script work when /bin is a symlink to /usr/bin and the wrapper
Rob Landley <rob@landley.net>
parents:
63
diff
changeset
|
72 // have enough space to append ".." to make topdir. |
51b8220c37e7
Make wrapper script work when /bin is a symlink to /usr/bin and the wrapper
Rob Landley <rob@landley.net>
parents:
63
diff
changeset
|
73 str = malloc(strlen(filename) + (len ? len : strlen(cwd)) + 3); |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
74 if (!len) sprintf(str, "%s/%s", cwd, filename); |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
75 else { |
16
7946bc54424b
Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents:
14
diff
changeset
|
76 char *str2 = str; |
7946bc54424b
Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents:
14
diff
changeset
|
77 |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
78 strncpy(str, path, len); |
16
7946bc54424b
Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents:
14
diff
changeset
|
79 str2 = str+len; |
7946bc54424b
Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents:
14
diff
changeset
|
80 *(str2++) = '/'; |
7946bc54424b
Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents:
14
diff
changeset
|
81 strcpy(str2, filename); |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
82 } |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
83 |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
84 // If it's not a directory, return it. |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
85 if (is_file(str, has_exe)) return str; |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
86 else free(str); |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
87 |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
88 if (!next) break; |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
89 path += len; |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
90 path++; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
91 } |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
92 free(cwd); |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
93 |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
94 return NULL; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
95 } |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
96 |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
97 int main(int argc, char **argv) |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
98 { |
435
d8e531563e35
Clean out some of the old uClibc build dir stuff nothing uses anymore.
Rob Landley <rob@landley.net>
parents:
434
diff
changeset
|
99 int linking = 1, use_static_linking = 0; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
100 int use_stdinc = 1, use_start = 1, use_stdlib = 1, use_pic = 0; |
435
d8e531563e35
Clean out some of the old uClibc build dir stuff nothing uses anymore.
Rob Landley <rob@landley.net>
parents:
434
diff
changeset
|
101 int source_count = 0, verbose = 0; |
528
71f438cde285
Make compiler wrapper parse -M options correctly, so uClibc make utils works.
Rob Landley <rob@landley.net>
parents:
447
diff
changeset
|
102 int i, argcnt, liblen, lplen; |
16
7946bc54424b
Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents:
14
diff
changeset
|
103 char **gcc_argv, **libraries, **libpath; |
435
d8e531563e35
Clean out some of the old uClibc build dir stuff nothing uses anymore.
Rob Landley <rob@landley.net>
parents:
434
diff
changeset
|
104 char *dlstr, *incstr, *devprefix, *libstr; |
547 | 105 char *cc; |
439
f257bd255545
Next round of wrapper cleanups: give C++ includes a sane path, prefix environment variables with WRAPPER_, don't set pointers to a char '\0' value.
Rob Landley <rob@landley.net>
parents:
438
diff
changeset
|
106 char *debug_wrapper=getenv("WRAPPER_DEBUG"); |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
107 |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
108 // For C++ |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
109 |
547 | 110 char *cpp = NULL; |
447
4ed02d53fc92
Add C++ support to native compiler, based on uClibc++.
Rob Landley <rob@landley.net>
parents:
441
diff
changeset
|
111 int len, ctor_dtor = 1, use_nostdinc_plus = 0; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
112 |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
113 // For profiling |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
114 int profile = 0; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
115 |
42
7b0f34fbc35a
Fix inappropriate activation of profiling support, and add environment variable
Rob Landley <rob@landley.net>
parents:
30
diff
changeset
|
116 if(debug_wrapper) { |
217
01fd30185476
Use fprintf(stderr,...) instead of dprintf(2,...) to be more portable.
Rob Landley <rob@landley.net>
parents:
76
diff
changeset
|
117 fprintf(stderr,"incoming: "); |
433
c7a1631711f4
Smallish wrapper cleanups, more to come.
Rob Landley <rob@landley.net>
parents:
403
diff
changeset
|
118 for(gcc_argv=argv;*gcc_argv;gcc_argv++) |
c7a1631711f4
Smallish wrapper cleanups, more to come.
Rob Landley <rob@landley.net>
parents:
403
diff
changeset
|
119 fprintf(stderr,"%s ",*gcc_argv); |
217
01fd30185476
Use fprintf(stderr,...) instead of dprintf(2,...) to be more portable.
Rob Landley <rob@landley.net>
parents:
76
diff
changeset
|
120 fprintf(stderr,"\n\n"); |
42
7b0f34fbc35a
Fix inappropriate activation of profiling support, and add environment variable
Rob Landley <rob@landley.net>
parents:
30
diff
changeset
|
121 } |
28
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
122 |
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
123 // Allocate space for new command line |
433
c7a1631711f4
Smallish wrapper cleanups, more to come.
Rob Landley <rob@landley.net>
parents:
403
diff
changeset
|
124 gcc_argv = alloca(sizeof(char*) * (argc + 128)); |
28
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
125 |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
126 // What directory is the wrapper script in? |
16
7946bc54424b
Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents:
14
diff
changeset
|
127 if(!(topdir = find_in_path(getenv("PATH"), argv[0], 1))) { |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
128 fprintf(stderr, "can't find %s in $PATH\n", argv[0]); |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
129 exit(1); |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
130 } else { |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
131 char *path = getenv("PATH"), *temp; |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
132 |
64
51b8220c37e7
Make wrapper script work when /bin is a symlink to /usr/bin and the wrapper
Rob Landley <rob@landley.net>
parents:
63
diff
changeset
|
133 // Add that directory to the start of $PATH. (Better safe than sorry.) |
16
7946bc54424b
Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents:
14
diff
changeset
|
134 *rindex(topdir,'/') = 0; |
257
d37e39370d39
Fix cross compiler toolchain to be properly relocatable on x86-64 host.
Rob Landley <rob@landley.net>
parents:
217
diff
changeset
|
135 temp = malloc(5+strlen(topdir)+1+strlen(topdir)+14+strlen(path)+1); |
d37e39370d39
Fix cross compiler toolchain to be properly relocatable on x86-64 host.
Rob Landley <rob@landley.net>
parents:
217
diff
changeset
|
136 sprintf(temp,"PATH=%s:%s/../tools/bin:%s",topdir,topdir,path); |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
137 putenv(temp); |
16
7946bc54424b
Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents:
14
diff
changeset
|
138 |
64
51b8220c37e7
Make wrapper script work when /bin is a symlink to /usr/bin and the wrapper
Rob Landley <rob@landley.net>
parents:
63
diff
changeset
|
139 // The directory above the wrapper script should have include, gcc, |
65
79295919b775
Ok, when appending .. instead of truncating at /, remember the "stop truncating"
Rob Landley <rob@landley.net>
parents:
64
diff
changeset
|
140 // and lib directories. However, the script could have a symlink |
79295919b775
Ok, when appending .. instead of truncating at /, remember the "stop truncating"
Rob Landley <rob@landley.net>
parents:
64
diff
changeset
|
141 // pointing to its directory (ala /bin -> /usr/bin), so append ".." |
79295919b775
Ok, when appending .. instead of truncating at /, remember the "stop truncating"
Rob Landley <rob@landley.net>
parents:
64
diff
changeset
|
142 // instead of trucating the path. |
79295919b775
Ok, when appending .. instead of truncating at /, remember the "stop truncating"
Rob Landley <rob@landley.net>
parents:
64
diff
changeset
|
143 strcat(topdir,"/.."); |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
144 } |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
145 |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
146 // What's the name of the C compiler we're wrapping? (It may have a |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
147 // cross-prefix.) |
439
f257bd255545
Next round of wrapper cleanups: give C++ includes a sane path, prefix environment variables with WRAPPER_, don't set pointers to a char '\0' value.
Rob Landley <rob@landley.net>
parents:
438
diff
changeset
|
148 cc = getenv("WRAPPER_CC"); |
390
a9a9eee9e620
Teach the wrapper script to do the libgcc_s --as-needed stuff when
Rob Landley <rob@landley.net>
parents:
257
diff
changeset
|
149 if (!cc) cc = GCC_UNWRAPPED_NAME; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
150 |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
151 // Check end of name, since there could be a cross-prefix on the thing |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
152 len = strlen(argv[0]); |
28
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
153 if (!strcmp(argv[0]+len-2, "ld")) { |
433
c7a1631711f4
Smallish wrapper cleanups, more to come.
Rob Landley <rob@landley.net>
parents:
403
diff
changeset
|
154 |
c7a1631711f4
Smallish wrapper cleanups, more to come.
Rob Landley <rob@landley.net>
parents:
403
diff
changeset
|
155 // TODO: put support for wrapping the linker here. |
c7a1631711f4
Smallish wrapper cleanups, more to come.
Rob Landley <rob@landley.net>
parents:
403
diff
changeset
|
156 |
28
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
157 // Wrapping the c++ compiler? |
433
c7a1631711f4
Smallish wrapper cleanups, more to come.
Rob Landley <rob@landley.net>
parents:
403
diff
changeset
|
158 } else if (!strcmp(argv[0]+len-2, "++")) { |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
159 len = strlen(cc); |
433
c7a1631711f4
Smallish wrapper cleanups, more to come.
Rob Landley <rob@landley.net>
parents:
403
diff
changeset
|
160 cpp = alloca(len+1); |
c7a1631711f4
Smallish wrapper cleanups, more to come.
Rob Landley <rob@landley.net>
parents:
403
diff
changeset
|
161 strcpy(cpp, cc); |
c7a1631711f4
Smallish wrapper cleanups, more to come.
Rob Landley <rob@landley.net>
parents:
403
diff
changeset
|
162 cpp[len-1]='+'; |
c7a1631711f4
Smallish wrapper cleanups, more to come.
Rob Landley <rob@landley.net>
parents:
403
diff
changeset
|
163 cpp[len-2]='+'; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
164 use_nostdinc_plus = 1; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
165 } |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
166 |
439
f257bd255545
Next round of wrapper cleanups: give C++ includes a sane path, prefix environment variables with WRAPPER_, don't set pointers to a char '\0' value.
Rob Landley <rob@landley.net>
parents:
438
diff
changeset
|
167 devprefix = getenv("WRAPPER_TOPDIR"); |
547 | 168 if (!devprefix) devprefix = topdir; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
169 |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
170 incstr = getenv("UCLIBC_GCC_INC"); |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
171 libstr = getenv("UCLIBC_GCC_LIB"); |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
172 |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
173 // Figure out where the dynamic linker is. |
63
89cf9497824e
Teach the native build about ld-uClibc.so.0 can living in /tools.
Rob Landley <rob@landley.net>
parents:
57
diff
changeset
|
174 dlstr = getenv("UCLIBC_DYNAMIC_LINKER"); |
89cf9497824e
Teach the native build about ld-uClibc.so.0 can living in /tools.
Rob Landley <rob@landley.net>
parents:
57
diff
changeset
|
175 if (!dlstr) dlstr = "/lib/ld-uClibc.so.0"; |
89cf9497824e
Teach the native build about ld-uClibc.so.0 can living in /tools.
Rob Landley <rob@landley.net>
parents:
57
diff
changeset
|
176 asprintf(&dlstr, "-Wl,--dynamic-linker,%s", dlstr); |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
177 |
28
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
178 liblen = 0; |
433
c7a1631711f4
Smallish wrapper cleanups, more to come.
Rob Landley <rob@landley.net>
parents:
403
diff
changeset
|
179 libraries = alloca(sizeof(char*) * (argc)); |
439
f257bd255545
Next round of wrapper cleanups: give C++ includes a sane path, prefix environment variables with WRAPPER_, don't set pointers to a char '\0' value.
Rob Landley <rob@landley.net>
parents:
438
diff
changeset
|
180 libraries[liblen] = 0; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
181 |
434
116c10067f4a
Replace variable "n" with something greppable.
Rob Landley <rob@landley.net>
parents:
433
diff
changeset
|
182 lplen = 0; |
433
c7a1631711f4
Smallish wrapper cleanups, more to come.
Rob Landley <rob@landley.net>
parents:
403
diff
changeset
|
183 libpath = alloca(sizeof(char*) * (argc)); |
439
f257bd255545
Next round of wrapper cleanups: give C++ includes a sane path, prefix environment variables with WRAPPER_, don't set pointers to a char '\0' value.
Rob Landley <rob@landley.net>
parents:
438
diff
changeset
|
184 libpath[lplen] = 0; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
185 |
18
eaf7a8d5e697
Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents:
16
diff
changeset
|
186 // Parse the incoming gcc arguments. |
eaf7a8d5e697
Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents:
16
diff
changeset
|
187 |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
188 for ( i = 1 ; i < argc ; i++ ) { |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
189 if (argv[i][0] == '-' && argv[i][1]) { /* option */ |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
190 switch (argv[i][1]) { |
528
71f438cde285
Make compiler wrapper parse -M options correctly, so uClibc make utils works.
Rob Landley <rob@landley.net>
parents:
447
diff
changeset
|
191 case 'M': /* generate dependencies */ |
71f438cde285
Make compiler wrapper parse -M options correctly, so uClibc make utils works.
Rob Landley <rob@landley.net>
parents:
447
diff
changeset
|
192 { |
71f438cde285
Make compiler wrapper parse -M options correctly, so uClibc make utils works.
Rob Landley <rob@landley.net>
parents:
447
diff
changeset
|
193 char *p = argv[i]; |
71f438cde285
Make compiler wrapper parse -M options correctly, so uClibc make utils works.
Rob Landley <rob@landley.net>
parents:
447
diff
changeset
|
194 |
71f438cde285
Make compiler wrapper parse -M options correctly, so uClibc make utils works.
Rob Landley <rob@landley.net>
parents:
447
diff
changeset
|
195 // -M and -MM imply -E and thus no linking |
71f438cde285
Make compiler wrapper parse -M options correctly, so uClibc make utils works.
Rob Landley <rob@landley.net>
parents:
447
diff
changeset
|
196 // Other -MX options _don't_, including -MMD. |
71f438cde285
Make compiler wrapper parse -M options correctly, so uClibc make utils works.
Rob Landley <rob@landley.net>
parents:
447
diff
changeset
|
197 if (p[2] && (p[2]!='M' || p[3])) break; |
71f438cde285
Make compiler wrapper parse -M options correctly, so uClibc make utils works.
Rob Landley <rob@landley.net>
parents:
447
diff
changeset
|
198 } |
71f438cde285
Make compiler wrapper parse -M options correctly, so uClibc make utils works.
Rob Landley <rob@landley.net>
parents:
447
diff
changeset
|
199 // fall through |
71f438cde285
Make compiler wrapper parse -M options correctly, so uClibc make utils works.
Rob Landley <rob@landley.net>
parents:
447
diff
changeset
|
200 |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
201 case 'c': /* compile or assemble */ |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
202 case 'S': /* generate assembler code */ |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
203 case 'E': /* preprocess only */ |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
204 linking = 0; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
205 break; |
18
eaf7a8d5e697
Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents:
16
diff
changeset
|
206 |
eaf7a8d5e697
Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents:
16
diff
changeset
|
207 case 'L': /* library path */ |
434
116c10067f4a
Replace variable "n" with something greppable.
Rob Landley <rob@landley.net>
parents:
433
diff
changeset
|
208 libpath[lplen++] = argv[i]; |
439
f257bd255545
Next round of wrapper cleanups: give C++ includes a sane path, prefix environment variables with WRAPPER_, don't set pointers to a char '\0' value.
Rob Landley <rob@landley.net>
parents:
438
diff
changeset
|
209 libpath[lplen] = 0; |
f257bd255545
Next round of wrapper cleanups: give C++ includes a sane path, prefix environment variables with WRAPPER_, don't set pointers to a char '\0' value.
Rob Landley <rob@landley.net>
parents:
438
diff
changeset
|
210 if (!argv[i][2]) { |
f257bd255545
Next round of wrapper cleanups: give C++ includes a sane path, prefix environment variables with WRAPPER_, don't set pointers to a char '\0' value.
Rob Landley <rob@landley.net>
parents:
438
diff
changeset
|
211 argv[i] = 0; |
434
116c10067f4a
Replace variable "n" with something greppable.
Rob Landley <rob@landley.net>
parents:
433
diff
changeset
|
212 libpath[lplen++] = argv[++i]; |
439
f257bd255545
Next round of wrapper cleanups: give C++ includes a sane path, prefix environment variables with WRAPPER_, don't set pointers to a char '\0' value.
Rob Landley <rob@landley.net>
parents:
438
diff
changeset
|
213 libpath[lplen] = 0; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
214 } |
439
f257bd255545
Next round of wrapper cleanups: give C++ includes a sane path, prefix environment variables with WRAPPER_, don't set pointers to a char '\0' value.
Rob Landley <rob@landley.net>
parents:
438
diff
changeset
|
215 argv[i] = 0; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
216 break; |
18
eaf7a8d5e697
Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents:
16
diff
changeset
|
217 |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
218 case 'l': /* library */ |
28
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
219 libraries[liblen++] = argv[i]; |
439
f257bd255545
Next round of wrapper cleanups: give C++ includes a sane path, prefix environment variables with WRAPPER_, don't set pointers to a char '\0' value.
Rob Landley <rob@landley.net>
parents:
438
diff
changeset
|
220 libraries[liblen] = 0; |
f257bd255545
Next round of wrapper cleanups: give C++ includes a sane path, prefix environment variables with WRAPPER_, don't set pointers to a char '\0' value.
Rob Landley <rob@landley.net>
parents:
438
diff
changeset
|
221 argv[i] = 0; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
222 break; |
18
eaf7a8d5e697
Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents:
16
diff
changeset
|
223 |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
224 case 'v': /* verbose */ |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
225 if (argv[i][2] == 0) verbose = 1; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
226 printf("Invoked as %s\n", argv[0]); |
16
7946bc54424b
Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents:
14
diff
changeset
|
227 printf("Reference path: %s\n", topdir); |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
228 break; |
18
eaf7a8d5e697
Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents:
16
diff
changeset
|
229 |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
230 case 'n': |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
231 if (strcmp(nostdinc,argv[i]) == 0) { |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
232 use_stdinc = 0; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
233 } else if (strcmp(nostartfiles,argv[i]) == 0) { |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
234 ctor_dtor = 0; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
235 use_start = 0; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
236 } else if (strcmp(nodefaultlibs,argv[i]) == 0) { |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
237 use_stdlib = 0; |
439
f257bd255545
Next round of wrapper cleanups: give C++ includes a sane path, prefix environment variables with WRAPPER_, don't set pointers to a char '\0' value.
Rob Landley <rob@landley.net>
parents:
438
diff
changeset
|
238 argv[i] = 0; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
239 } else if (strcmp(nostdlib,argv[i]) == 0) { |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
240 ctor_dtor = 0; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
241 use_start = 0; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
242 use_stdlib = 0; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
243 } else if (strcmp(nostdinc_plus,argv[i]) == 0) { |
447
4ed02d53fc92
Add C++ support to native compiler, based on uClibc++.
Rob Landley <rob@landley.net>
parents:
441
diff
changeset
|
244 if (cpp) use_nostdinc_plus = 0; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
245 } |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
246 break; |
18
eaf7a8d5e697
Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents:
16
diff
changeset
|
247 |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
248 case 's': |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
249 if (strstr(argv[i],static_linking) != NULL) { |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
250 use_static_linking = 1; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
251 } |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
252 if (strcmp("-shared",argv[i]) == 0) { |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
253 use_start = 0; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
254 use_pic = 1; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
255 } |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
256 break; |
18
eaf7a8d5e697
Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents:
16
diff
changeset
|
257 |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
258 case 'W': /* -static could be passed directly to ld */ |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
259 if (strncmp("-Wl,",argv[i],4) == 0) { |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
260 if (strstr(argv[i],static_linking) != 0) { |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
261 use_static_linking = 1; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
262 } |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
263 if (strstr(argv[i],"--dynamic-linker") != 0) { |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
264 dlstr = 0; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
265 } |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
266 } |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
267 break; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
268 |
20
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
269 case 'p': |
29
db08bdb5e9de
The poor design of the gcc command line never ceases to amaze. Notice how
Rob Landley <rob@landley.net>
parents:
28
diff
changeset
|
270 wow_this_sucks: |
20
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
271 if (!strncmp("-print-",argv[i],7)) { |
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
272 char *temp, *temp2; |
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
273 int itemp, showall = 0; |
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
274 |
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
275 temp = argv[i]+7; |
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
276 if (!strcmp(temp, "search-dirs")) { |
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
277 printf("install: %s/\n",devprefix); |
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
278 printf("programs: %s\n",getenv("PATH")); |
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
279 printf("libraries: "); |
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
280 temp2 = ""; |
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
281 showall = 1; |
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
282 } else if (!strncmp(temp, "file-name=", 10)) |
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
283 temp2 = temp+10; |
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
284 else if (!strcmp(temp, "libgcc-file-name")) |
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
285 temp2="libgcc.a"; |
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
286 else break; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
287 |
20
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
288 // Find this entry in the library path. |
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
289 for(itemp=0;;itemp++) { |
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.
Rob Landley <rob@landley.net>
parents:
439
diff
changeset
|
290 if (itemp == lplen) |
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.
Rob Landley <rob@landley.net>
parents:
439
diff
changeset
|
291 asprintf(&temp, "%s/gcc/lib/%s", devprefix, temp2); |
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.
Rob Landley <rob@landley.net>
parents:
439
diff
changeset
|
292 else if (itemp == lplen+1) |
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.
Rob Landley <rob@landley.net>
parents:
439
diff
changeset
|
293 asprintf(&temp, "%s/lib/%s", devprefix, temp2); |
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.
Rob Landley <rob@landley.net>
parents:
439
diff
changeset
|
294 |
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.
Rob Landley <rob@landley.net>
parents:
439
diff
changeset
|
295 // This is so "include" finds the gcc internal |
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.
Rob Landley <rob@landley.net>
parents:
439
diff
changeset
|
296 // include dir. The uClibc build needs this. |
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.
Rob Landley <rob@landley.net>
parents:
439
diff
changeset
|
297 else if (itemp == lplen+2) |
20
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
298 asprintf(&temp, "%s/gcc/%s", devprefix, temp2); |
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.
Rob Landley <rob@landley.net>
parents:
439
diff
changeset
|
299 else if (itemp == lplen+3) { |
20
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
300 temp = temp2; |
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
301 break; |
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.
Rob Landley <rob@landley.net>
parents:
439
diff
changeset
|
302 } else asprintf(&temp, "%s/%s", libpath[itemp], |
20
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
303 temp2); |
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.
Rob Landley <rob@landley.net>
parents:
439
diff
changeset
|
304 |
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.
Rob Landley <rob@landley.net>
parents:
439
diff
changeset
|
305 if (debug_wrapper) |
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.
Rob Landley <rob@landley.net>
parents:
439
diff
changeset
|
306 fprintf(stderr, "try=%s\n", temp); |
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.
Rob Landley <rob@landley.net>
parents:
439
diff
changeset
|
307 |
20
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
308 if (showall) printf(":%s"+(itemp?0:1), temp); |
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
309 else if (!access(temp, F_OK)) break; |
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
310 } |
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
311 |
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.
Rob Landley <rob@landley.net>
parents:
439
diff
changeset
|
312 |
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.
Rob Landley <rob@landley.net>
parents:
439
diff
changeset
|
313 |
20
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
314 printf("%s\n"+(showall ? 2 : 0), temp); |
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
315 exit(0); |
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
316 |
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
317 // Profiling. |
42
7b0f34fbc35a
Fix inappropriate activation of profiling support, and add environment variable
Rob Landley <rob@landley.net>
parents:
30
diff
changeset
|
318 } else if (!strcmp("-pg",argv[i])) profile = 1; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
319 break; |
18
eaf7a8d5e697
Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents:
16
diff
changeset
|
320 |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
321 case 'f': |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
322 /* Check if we are doing PIC */ |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
323 if (strcmp("-fPIC",argv[i]) == 0) { |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
324 use_pic = 1; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
325 } else if (strcmp("-fpic",argv[i]) == 0) { |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
326 use_pic = 1; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
327 |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
328 // profiling |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
329 } else if (strcmp("-fprofile-arcs",argv[i]) == 0) { |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
330 profile = 1; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
331 } |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
332 break; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
333 |
19
b5ffd82d9ae5
Two problems: 1) Needed to parse -print-file-name= to make the uClibc build
Rob Landley <rob@landley.net>
parents:
18
diff
changeset
|
334 // --longopts |
b5ffd82d9ae5
Two problems: 1) Needed to parse -print-file-name= to make the uClibc build
Rob Landley <rob@landley.net>
parents:
18
diff
changeset
|
335 |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
336 case '-': |
29
db08bdb5e9de
The poor design of the gcc command line never ceases to amaze. Notice how
Rob Landley <rob@landley.net>
parents:
28
diff
changeset
|
337 if (!strncmp(argv[i],"--print-",8)) { |
db08bdb5e9de
The poor design of the gcc command line never ceases to amaze. Notice how
Rob Landley <rob@landley.net>
parents:
28
diff
changeset
|
338 argv[i]++; |
db08bdb5e9de
The poor design of the gcc command line never ceases to amaze. Notice how
Rob Landley <rob@landley.net>
parents:
28
diff
changeset
|
339 goto wow_this_sucks; |
db08bdb5e9de
The poor design of the gcc command line never ceases to amaze. Notice how
Rob Landley <rob@landley.net>
parents:
28
diff
changeset
|
340 } else if (strstr(argv[i]+1,static_linking) != NULL) { |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
341 use_static_linking = 1; |
439
f257bd255545
Next round of wrapper cleanups: give C++ includes a sane path, prefix environment variables with WRAPPER_, don't set pointers to a char '\0' value.
Rob Landley <rob@landley.net>
parents:
438
diff
changeset
|
342 argv[i] = 0; |
19
b5ffd82d9ae5
Two problems: 1) Needed to parse -print-file-name= to make the uClibc build
Rob Landley <rob@landley.net>
parents:
18
diff
changeset
|
343 } else if (!strcmp("--version",argv[i])) { |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
344 printf("uClibc "); |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
345 fflush(stdout); |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
346 break; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
347 } else if (strcmp ("--uclibc-cc", argv[i]) == 0 && argv[i + 1]) { |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
348 cc = argv[i + 1]; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
349 argv[i] = 0; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
350 argv[i + 1] = 0; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
351 } else if (strncmp ("--uclibc-cc=", argv[i], 12) == 0) { |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
352 cc = argv[i] + 12; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
353 argv[i] = 0; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
354 } else if (strcmp("--uclibc-no-ctors",argv[i]) == 0) { |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
355 ctor_dtor = 0; |
439
f257bd255545
Next round of wrapper cleanups: give C++ includes a sane path, prefix environment variables with WRAPPER_, don't set pointers to a char '\0' value.
Rob Landley <rob@landley.net>
parents:
438
diff
changeset
|
356 argv[i] = 0; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
357 } |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
358 break; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
359 } |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
360 } else { /* assume it is an existing source file */ |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
361 ++source_count; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
362 } |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
363 } |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
364 |
28
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
365 argcnt = 0; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
366 |
28
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
367 gcc_argv[argcnt++] = cpp ? cpp : cc; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
368 |
447
4ed02d53fc92
Add C++ support to native compiler, based on uClibc++.
Rob Landley <rob@landley.net>
parents:
441
diff
changeset
|
369 if (cpp) gcc_argv[argcnt++] = "-fno-use-cxa-atexit"; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
370 |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
371 if (linking && source_count) { |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
372 //#if defined HAS_ELF && ! defined HAS_MMU |
28
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
373 // gcc_argv[argcnt++] = "-Wl,-elf2flt"; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
374 //#endif |
28
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
375 gcc_argv[argcnt++] = nostdlib; |
547 | 376 if (use_static_linking) |
28
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
377 gcc_argv[argcnt++] = static_linking; |
547 | 378 else if (dlstr) gcc_argv[argcnt++] = dlstr; |
434
116c10067f4a
Replace variable "n" with something greppable.
Rob Landley <rob@landley.net>
parents:
433
diff
changeset
|
379 for ( i = 0 ; i < lplen ; i++ ) |
28
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
380 if (libpath[i]) gcc_argv[argcnt++] = libpath[i]; |
547 | 381 |
382 // just to be safe: | |
383 asprintf(gcc_argv+(argcnt++),"-Wl,-rpath-link,%s/lib", devprefix); | |
384 | |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
385 if( libstr ) |
28
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
386 gcc_argv[argcnt++] = libstr; |
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.
Rob Landley <rob@landley.net>
parents:
439
diff
changeset
|
387 |
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.
Rob Landley <rob@landley.net>
parents:
439
diff
changeset
|
388 asprintf(gcc_argv+(argcnt++), "-L%s/lib", devprefix); |
435
d8e531563e35
Clean out some of the old uClibc build dir stuff nothing uses anymore.
Rob Landley <rob@landley.net>
parents:
434
diff
changeset
|
389 asprintf(gcc_argv+(argcnt++), "-L%s/gcc/lib", devprefix); |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
390 } |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
391 if (use_stdinc && source_count) { |
28
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
392 gcc_argv[argcnt++] = nostdinc; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
393 |
447
4ed02d53fc92
Add C++ support to native compiler, based on uClibc++.
Rob Landley <rob@landley.net>
parents:
441
diff
changeset
|
394 if (cpp) { |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
395 if (use_nostdinc_plus) { |
28
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
396 gcc_argv[argcnt++] = nostdinc_plus; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
397 } |
28
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
398 gcc_argv[argcnt++] = "-isystem"; |
447
4ed02d53fc92
Add C++ support to native compiler, based on uClibc++.
Rob Landley <rob@landley.net>
parents:
441
diff
changeset
|
399 asprintf(gcc_argv+(argcnt++), "%s/c++/include", devprefix); |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
400 } |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
401 |
28
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
402 gcc_argv[argcnt++] = "-isystem"; |
447
4ed02d53fc92
Add C++ support to native compiler, based on uClibc++.
Rob Landley <rob@landley.net>
parents:
441
diff
changeset
|
403 asprintf(gcc_argv+(argcnt++), "%s/include", devprefix); |
28
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
404 gcc_argv[argcnt++] = "-isystem"; |
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
405 asprintf(gcc_argv+(argcnt++), "%s/gcc/include", devprefix); |
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
406 if(incstr) gcc_argv[argcnt++] = incstr; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
407 } |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
408 |
28
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
409 gcc_argv[argcnt++] = "-U__nptl__"; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
410 |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
411 if (linking && source_count) { |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
412 |
547 | 413 if (profile) |
414 asprintf(gcc_argv+(argcnt++), "%s/lib/gcrt1.o", devprefix); | |
415 | |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
416 if (ctor_dtor) { |
547 | 417 asprintf(gcc_argv+(argcnt++), "%s/lib/crti.o", devprefix); |
418 asprintf(gcc_argv+(argcnt++), "%s/gcc/lib/crtbegin%s", devprefix, | |
419 use_pic ? "S.o" : ".o"); | |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
420 } |
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.
Rob Landley <rob@landley.net>
parents:
439
diff
changeset
|
421 if (use_start && !profile) |
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.
Rob Landley <rob@landley.net>
parents:
439
diff
changeset
|
422 asprintf(gcc_argv+(argcnt++), "%s/lib/crt1.o", devprefix); |
16
7946bc54424b
Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents:
14
diff
changeset
|
423 |
7946bc54424b
Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents:
14
diff
changeset
|
424 // Add remaining unclaimed arguments. |
7946bc54424b
Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents:
14
diff
changeset
|
425 |
28
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
426 for (i=1; i<argc; i++) if (argv[i]) gcc_argv[argcnt++] = argv[i]; |
16
7946bc54424b
Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents:
14
diff
changeset
|
427 |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
428 if (use_stdlib) { |
28
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
429 //gcc_argv[argcnt++] = "-Wl,--start-group"; |
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
430 gcc_argv[argcnt++] = "-lgcc"; |
438
e9f3011ec40d
Teach wrapper about libgcc_eh.a for static linking.
Rob Landley <rob@landley.net>
parents:
435
diff
changeset
|
431 ADD_GCC_S(); |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
432 } |
28
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
433 for (i = 0 ; i < liblen ; i++) |
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
434 if (libraries[i]) gcc_argv[argcnt++] = libraries[i]; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
435 if (use_stdlib) { |
447
4ed02d53fc92
Add C++ support to native compiler, based on uClibc++.
Rob Landley <rob@landley.net>
parents:
441
diff
changeset
|
436 if (cpp) { |
28
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
437 gcc_argv[argcnt++] = "-lstdc++"; |
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
438 gcc_argv[argcnt++] = "-lm"; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
439 } |
28
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
440 gcc_argv[argcnt++] = "-lc"; |
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
441 gcc_argv[argcnt++] = "-lgcc"; |
438
e9f3011ec40d
Teach wrapper about libgcc_eh.a for static linking.
Rob Landley <rob@landley.net>
parents:
435
diff
changeset
|
442 ADD_GCC_S(); |
28
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
443 //gcc_argv[argcnt++] = "-Wl,--end-group"; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
444 } |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
445 if (ctor_dtor) { |
547 | 446 asprintf(gcc_argv+(argcnt++), "%s/gcc/lib/crtend%s", devprefix, |
447 use_pic ? "S.o" : ".o"); | |
448 asprintf(gcc_argv+(argcnt++), "%s/lib/crtn.o", devprefix); | |
28
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
449 } |
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
450 } else for (i=1; i<argc; i++) if (argv[i]) gcc_argv[argcnt++] = argv[i]; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
451 |
28
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
452 gcc_argv[argcnt++] = NULL; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
453 |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
454 if (verbose) { |
28
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
455 for ( i = 0 ; gcc_argv[i] ; i++ ) { |
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
456 printf("arg[%2i] = %s\n", i, gcc_argv[i]); |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
457 } |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
458 fflush(stdout); |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
459 } |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
460 |
42
7b0f34fbc35a
Fix inappropriate activation of profiling support, and add environment variable
Rob Landley <rob@landley.net>
parents:
30
diff
changeset
|
461 if (debug_wrapper) { |
217
01fd30185476
Use fprintf(stderr,...) instead of dprintf(2,...) to be more portable.
Rob Landley <rob@landley.net>
parents:
76
diff
changeset
|
462 fprintf(stderr, "outgoing: "); |
01fd30185476
Use fprintf(stderr,...) instead of dprintf(2,...) to be more portable.
Rob Landley <rob@landley.net>
parents:
76
diff
changeset
|
463 for(i=0; gcc_argv[i]; i++) fprintf(stderr, "%s ",gcc_argv[i]); |
01fd30185476
Use fprintf(stderr,...) instead of dprintf(2,...) to be more portable.
Rob Landley <rob@landley.net>
parents:
76
diff
changeset
|
464 fprintf(stderr, "\n\n"); |
42
7b0f34fbc35a
Fix inappropriate activation of profiling support, and add environment variable
Rob Landley <rob@landley.net>
parents:
30
diff
changeset
|
465 } |
7b0f34fbc35a
Fix inappropriate activation of profiling support, and add environment variable
Rob Landley <rob@landley.net>
parents:
30
diff
changeset
|
466 |
16
7946bc54424b
Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents:
14
diff
changeset
|
467 execvp(gcc_argv[0], gcc_argv); |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
468 fprintf(stderr, "%s: %s\n", cpp ? cpp : cc, strerror(errno)); |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
469 exit(EXIT_FAILURE); |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
470 } |