Mercurial > hg > aboriginal
annotate sources/toys/ccwrap.old @ 1682:64316ca2bc9b
Remove redundant list assignment in ccwrap that screws up ordering and puts the -L entries in the wrong order.
author | Rob Landley <rob@landley.net> |
---|---|
date | Fri, 05 Sep 2014 23:54:01 -0500 |
parents | 586b011cb706 |
children |
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 |
943
7f2e6bdfcdcb
Remove the old GIMME_AN_S logic, instead make ccwrap autodetect presence of libgcc_s.so. Also fix a typo causing a nasty bug with the two dash version of --static.
Rob Landley <rob@landley.net>
parents:
937
diff
changeset
|
5 * Copyright (C) 2006-2010 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 * |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
7 * Wrapper to use make a C compiler relocatable. |
812
4e1e6aa7f445
Convince gcc to build/install libgcc_eh.a even for --disable-shared compilers, and tell the wrapper to expect it.
Rob Landley <rob@landley.net>
parents:
807
diff
changeset
|
8 * |
4e1e6aa7f445
Convince gcc to build/install libgcc_eh.a even for --disable-shared compilers, and tell the wrapper to expect it.
Rob Landley <rob@landley.net>
parents:
807
diff
changeset
|
9 * Licensed under GPLv2. |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
10 */ |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
11 |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
12 // No, we don't need to check the return value from asprintf(). |
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
13 |
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
14 #undef _FORTIFY_SOURCE |
888 | 15 |
16
7946bc54424b
Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents:
14
diff
changeset
|
16 #define _GNU_SOURCE |
433
c7a1631711f4
Smallish wrapper cleanups, more to come.
Rob Landley <rob@landley.net>
parents:
403
diff
changeset
|
17 #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
|
18 #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
|
19 #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
|
20 #include <stdarg.h> |
76
5703436a408e
Update the uClibc snapshot and make config changes it needs.
Rob Landley <rob@landley.net>
parents:
65
diff
changeset
|
21 #include <string.h> |
57
f393a630a5b3
Weird ordering dependency. I think it's a uClibc bug?
Rob Landley <rob@landley.net>
parents:
56
diff
changeset
|
22 #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
|
23 #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
|
24 #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
|
25 #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
|
26 #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
|
27 |
1148
66c29043b5ca
Tweak ccwrap.c to handle compiler versions that only provide crtbegin.o and crtend.o without T and S versions.
Rob Landley <rob@landley.net>
parents:
1106
diff
changeset
|
28 static char *topdir, *devprefix; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
29 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
|
30 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
|
31 |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
32 // For C++ |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
33 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
|
34 |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
35 // 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
|
36 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
|
37 { |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
38 // 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
|
39 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
|
40 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
|
41 |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
42 // 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
|
43 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
|
44 } |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
45 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
|
46 } |
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 // 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
|
49 |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
50 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
|
51 { |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
52 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
|
53 |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
54 if (index(filename, '/') && is_file(filename, has_exe)) |
863
4bfe2b34dd9f
Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents:
839
diff
changeset
|
55 return realpath(filename, NULL); |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
56 |
1104
6ab5dfe6b035
Check for null $PATH after checking for dir/filename (which doesn't need $PATH).
Rob Landley <rob@landley.net>
parents:
948
diff
changeset
|
57 while (path) { |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
58 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
|
59 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
|
60 |
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
|
61 // 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
|
62 // 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
|
63 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
|
64 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
|
65 else { |
16
7946bc54424b
Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents:
14
diff
changeset
|
66 char *str2 = str; |
7946bc54424b
Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents:
14
diff
changeset
|
67 |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
68 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
|
69 str2 = str+len; |
7946bc54424b
Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents:
14
diff
changeset
|
70 *(str2++) = '/'; |
7946bc54424b
Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents:
14
diff
changeset
|
71 strcpy(str2, filename); |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
72 } |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
73 |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
74 // If it's not a directory, return it. |
863
4bfe2b34dd9f
Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents:
839
diff
changeset
|
75 if (is_file(str, has_exe)) { |
4bfe2b34dd9f
Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents:
839
diff
changeset
|
76 char *s = realpath(str, NULL); |
4bfe2b34dd9f
Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents:
839
diff
changeset
|
77 free(str); |
1104
6ab5dfe6b035
Check for null $PATH after checking for dir/filename (which doesn't need $PATH).
Rob Landley <rob@landley.net>
parents:
948
diff
changeset
|
78 free(cwd); |
863
4bfe2b34dd9f
Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents:
839
diff
changeset
|
79 return s; |
4bfe2b34dd9f
Largeish refactoring/simplification of run-emulator.sh and associated code. Now automatically sets up the distcc trick if the appropriate $ARCH-cc toolchain is in the $PATH (or the current directory).
Rob Landley <rob@landley.net>
parents:
839
diff
changeset
|
80 } else free(str); |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
81 |
1106
33ad2278b2af
Last tweak to this file introduced a bug looping endlessly, failing to proceed past the separator. Oops.
Rob Landley <rob@landley.net>
parents:
1105
diff
changeset
|
82 if (next) next++; |
1104
6ab5dfe6b035
Check for null $PATH after checking for dir/filename (which doesn't need $PATH).
Rob Landley <rob@landley.net>
parents:
948
diff
changeset
|
83 path = next; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
84 } |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
85 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
|
86 |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
87 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
|
88 } |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
89 |
1148
66c29043b5ca
Tweak ccwrap.c to handle compiler versions that only provide crtbegin.o and crtend.o without T and S versions.
Rob Landley <rob@landley.net>
parents:
1106
diff
changeset
|
90 // Some compiler versions don't provide separate T and S versions of begin/end, |
66c29043b5ca
Tweak ccwrap.c to handle compiler versions that only provide crtbegin.o and crtend.o without T and S versions.
Rob Landley <rob@landley.net>
parents:
1106
diff
changeset
|
91 // so fall back to the base version if they're not there. |
66c29043b5ca
Tweak ccwrap.c to handle compiler versions that only provide crtbegin.o and crtend.o without T and S versions.
Rob Landley <rob@landley.net>
parents:
1106
diff
changeset
|
92 |
66c29043b5ca
Tweak ccwrap.c to handle compiler versions that only provide crtbegin.o and crtend.o without T and S versions.
Rob Landley <rob@landley.net>
parents:
1106
diff
changeset
|
93 char *find_TSpath(char *base, int use_shared, int use_static_linking) |
66c29043b5ca
Tweak ccwrap.c to handle compiler versions that only provide crtbegin.o and crtend.o without T and S versions.
Rob Landley <rob@landley.net>
parents:
1106
diff
changeset
|
94 { |
66c29043b5ca
Tweak ccwrap.c to handle compiler versions that only provide crtbegin.o and crtend.o without T and S versions.
Rob Landley <rob@landley.net>
parents:
1106
diff
changeset
|
95 int i; |
66c29043b5ca
Tweak ccwrap.c to handle compiler versions that only provide crtbegin.o and crtend.o without T and S versions.
Rob Landley <rob@landley.net>
parents:
1106
diff
changeset
|
96 char *temp; |
66c29043b5ca
Tweak ccwrap.c to handle compiler versions that only provide crtbegin.o and crtend.o without T and S versions.
Rob Landley <rob@landley.net>
parents:
1106
diff
changeset
|
97 |
66c29043b5ca
Tweak ccwrap.c to handle compiler versions that only provide crtbegin.o and crtend.o without T and S versions.
Rob Landley <rob@landley.net>
parents:
1106
diff
changeset
|
98 asprintf(&temp, base, devprefix, |
66c29043b5ca
Tweak ccwrap.c to handle compiler versions that only provide crtbegin.o and crtend.o without T and S versions.
Rob Landley <rob@landley.net>
parents:
1106
diff
changeset
|
99 use_shared ? "S.o" : use_static_linking ? "T.o" : ".o"); |
66c29043b5ca
Tweak ccwrap.c to handle compiler versions that only provide crtbegin.o and crtend.o without T and S versions.
Rob Landley <rob@landley.net>
parents:
1106
diff
changeset
|
100 |
66c29043b5ca
Tweak ccwrap.c to handle compiler versions that only provide crtbegin.o and crtend.o without T and S versions.
Rob Landley <rob@landley.net>
parents:
1106
diff
changeset
|
101 if (!is_file(temp, 0)) { |
66c29043b5ca
Tweak ccwrap.c to handle compiler versions that only provide crtbegin.o and crtend.o without T and S versions.
Rob Landley <rob@landley.net>
parents:
1106
diff
changeset
|
102 free(temp); |
66c29043b5ca
Tweak ccwrap.c to handle compiler versions that only provide crtbegin.o and crtend.o without T and S versions.
Rob Landley <rob@landley.net>
parents:
1106
diff
changeset
|
103 asprintf(&temp, base, devprefix, ".o"); |
66c29043b5ca
Tweak ccwrap.c to handle compiler versions that only provide crtbegin.o and crtend.o without T and S versions.
Rob Landley <rob@landley.net>
parents:
1106
diff
changeset
|
104 } |
66c29043b5ca
Tweak ccwrap.c to handle compiler versions that only provide crtbegin.o and crtend.o without T and S versions.
Rob Landley <rob@landley.net>
parents:
1106
diff
changeset
|
105 |
66c29043b5ca
Tweak ccwrap.c to handle compiler versions that only provide crtbegin.o and crtend.o without T and S versions.
Rob Landley <rob@landley.net>
parents:
1106
diff
changeset
|
106 return temp; |
66c29043b5ca
Tweak ccwrap.c to handle compiler versions that only provide crtbegin.o and crtend.o without T and S versions.
Rob Landley <rob@landley.net>
parents:
1106
diff
changeset
|
107 } |
66c29043b5ca
Tweak ccwrap.c to handle compiler versions that only provide crtbegin.o and crtend.o without T and S versions.
Rob Landley <rob@landley.net>
parents:
1106
diff
changeset
|
108 |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
109 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
|
110 { |
1327
64d310e39a12
Teach ccwrap to switch off -xc after command line sources listed, so cc doesn't try to interpret libc and such as C sources.
Rob Landley <rob@landley.net>
parents:
1286
diff
changeset
|
111 int linking = 1, use_static_linking = 0, use_shared_libgcc, used_x = 0; |
549
2edf40b17ee2
Select crtbegin.o and crtend.o variants more accurately for -static and -shared.
Rob Landley <rob@landley.net>
parents:
548
diff
changeset
|
112 int use_stdinc = 1, use_start = 1, use_stdlib = 1, use_shared = 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
|
113 int source_count = 0, verbose = 0; |
1286
5035607b3cda
Rip out the code gratuitously reordering libraries. It serves no purpose other than to break mixed -lblah and ../blah.a compiles that care about order.
Rob Landley <rob@landley.net>
parents:
1250
diff
changeset
|
114 int i, argcnt, lplen; |
5035607b3cda
Rip out the code gratuitously reordering libraries. It serves no purpose other than to break mixed -lblah and ../blah.a compiles that care about order.
Rob Landley <rob@landley.net>
parents:
1250
diff
changeset
|
115 char **cc_argv, **libpath; |
1148
66c29043b5ca
Tweak ccwrap.c to handle compiler versions that only provide crtbegin.o and crtend.o without T and S versions.
Rob Landley <rob@landley.net>
parents:
1106
diff
changeset
|
116 char *dlstr; |
748
897fb219ead7
Teach ccwrap to handle --print-prog-name=ld and such.
Rob Landley <rob@landley.net>
parents:
684
diff
changeset
|
117 char *cc, *toolprefix; |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
118 char *debug_wrapper=getenv("CCWRAP_DEBUG"); |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
119 |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
120 // For C++ |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
121 |
547 | 122 char *cpp = NULL; |
748
897fb219ead7
Teach ccwrap to handle --print-prog-name=ld and such.
Rob Landley <rob@landley.net>
parents:
684
diff
changeset
|
123 int prefixlen, 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
|
124 |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
125 // For profiling |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
126 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
|
127 |
42
7b0f34fbc35a
Fix inappropriate activation of profiling support, and add environment variable
Rob Landley <rob@landley.net>
parents:
30
diff
changeset
|
128 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
|
129 fprintf(stderr,"incoming: "); |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
130 for(cc_argv=argv;*cc_argv;cc_argv++) |
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
131 fprintf(stderr,"%s ",*cc_argv); |
217
01fd30185476
Use fprintf(stderr,...) instead of dprintf(2,...) to be more portable.
Rob Landley <rob@landley.net>
parents:
76
diff
changeset
|
132 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
|
133 } |
28
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
134 |
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
135 // Allocate space for new command line |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
136 cc_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
|
137 |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
138 // 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
|
139 if(!(topdir = find_in_path(getenv("PATH"), argv[0], 1))) { |
839
1067e99efbdc
ccwrap shouldn't segfault if PATH isn't exported. (Thanks to Wangji Hoan for spotting this bug.)
Rob Landley <rob@landley.net>
parents:
812
diff
changeset
|
140 fprintf(stderr, "can't find %s in $PATH (did you export it?)\n", argv[0]); |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
141 exit(1); |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
142 } else { |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
143 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
|
144 |
1105
345f49b45123
Another fix for unexported $PATH.
Rob Landley <rob@landley.net>
parents:
1104
diff
changeset
|
145 if (!path) path = ""; |
345f49b45123
Another fix for unexported $PATH.
Rob Landley <rob@landley.net>
parents:
1104
diff
changeset
|
146 |
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
|
147 // 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
|
148 *rindex(topdir,'/') = 0; |
1452 | 149 asprintf(&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
|
150 putenv(temp); |
16
7946bc54424b
Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents:
14
diff
changeset
|
151 |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
152 // The directory above the wrapper script should have include, cc, |
65
79295919b775
Ok, when appending .. instead of truncating at /, remember the "stop truncating"
Rob Landley <rob@landley.net>
parents:
64
diff
changeset
|
153 // 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
|
154 // 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
|
155 // 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
|
156 strcat(topdir,"/.."); |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
157 } |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
158 |
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
159 // 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
|
160 // cross-prefix.) |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
161 cc = getenv("CCWRAP_CC"); |
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
162 if (!cc) cc = "rawcc"; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
163 |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
164 // Check end of name, since there could be a cross-prefix on the thing |
748
897fb219ead7
Teach ccwrap to handle --print-prog-name=ld and such.
Rob Landley <rob@landley.net>
parents:
684
diff
changeset
|
165 toolprefix = strrchr(argv[0], '/'); |
897fb219ead7
Teach ccwrap to handle --print-prog-name=ld and such.
Rob Landley <rob@landley.net>
parents:
684
diff
changeset
|
166 if (!toolprefix) toolprefix = argv[0]; |
800
d20b91530061
Be a little more consistent about space vs tab indentation.
Rob Landley <rob@landley.net>
parents:
748
diff
changeset
|
167 else toolprefix++; |
748
897fb219ead7
Teach ccwrap to handle --print-prog-name=ld and such.
Rob Landley <rob@landley.net>
parents:
684
diff
changeset
|
168 |
897fb219ead7
Teach ccwrap to handle --print-prog-name=ld and such.
Rob Landley <rob@landley.net>
parents:
684
diff
changeset
|
169 prefixlen = strlen(toolprefix); |
807
d0b74a631587
Teach ccwrap.c to use arch-specific WRAPPER_TOPDIR values, to avoid interfering with canadian cross.
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
170 if (prefixlen>=3 && !strcmp(toolprefix+prefixlen-3, "gcc")) prefixlen -= 3; |
800
d20b91530061
Be a little more consistent about space vs tab indentation.
Rob Landley <rob@landley.net>
parents:
748
diff
changeset
|
171 else if (!strcmp(toolprefix+prefixlen-2, "cc")) prefixlen -= 2; |
748
897fb219ead7
Teach ccwrap to handle --print-prog-name=ld and such.
Rob Landley <rob@landley.net>
parents:
684
diff
changeset
|
172 else if (!strcmp(toolprefix+prefixlen-2, "ld")) { |
800
d20b91530061
Be a little more consistent about space vs tab indentation.
Rob Landley <rob@landley.net>
parents:
748
diff
changeset
|
173 prefixlen -= 2; |
433
c7a1631711f4
Smallish wrapper cleanups, more to come.
Rob Landley <rob@landley.net>
parents:
403
diff
changeset
|
174 |
c7a1631711f4
Smallish wrapper cleanups, more to come.
Rob Landley <rob@landley.net>
parents:
403
diff
changeset
|
175 // TODO: put support for wrapping the linker here. |
1519
83de80c10db8
Upgrade to uClibc 0.9.33.1 (and use NPTL), and busybox 1.19.4.
Rob Landley <rob@landley.net>
parents:
1452
diff
changeset
|
176 } else if (!strcmp(toolprefix+prefixlen-3, "cpp")) { |
83de80c10db8
Upgrade to uClibc 0.9.33.1 (and use NPTL), and busybox 1.19.4.
Rob Landley <rob@landley.net>
parents:
1452
diff
changeset
|
177 prefixlen -=3; |
83de80c10db8
Upgrade to uClibc 0.9.33.1 (and use NPTL), and busybox 1.19.4.
Rob Landley <rob@landley.net>
parents:
1452
diff
changeset
|
178 linking = 0; |
433
c7a1631711f4
Smallish wrapper cleanups, more to come.
Rob Landley <rob@landley.net>
parents:
403
diff
changeset
|
179 |
28
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
180 // Wrapping the c++ compiler? |
748
897fb219ead7
Teach ccwrap to handle --print-prog-name=ld and such.
Rob Landley <rob@landley.net>
parents:
684
diff
changeset
|
181 } else if (!strcmp(toolprefix+prefixlen-2, "++")) { |
897fb219ead7
Teach ccwrap to handle --print-prog-name=ld and such.
Rob Landley <rob@landley.net>
parents:
684
diff
changeset
|
182 int len = strlen(cc); |
433
c7a1631711f4
Smallish wrapper cleanups, more to come.
Rob Landley <rob@landley.net>
parents:
403
diff
changeset
|
183 cpp = alloca(len+1); |
c7a1631711f4
Smallish wrapper cleanups, more to come.
Rob Landley <rob@landley.net>
parents:
403
diff
changeset
|
184 strcpy(cpp, cc); |
c7a1631711f4
Smallish wrapper cleanups, more to come.
Rob Landley <rob@landley.net>
parents:
403
diff
changeset
|
185 cpp[len-1]='+'; |
c7a1631711f4
Smallish wrapper cleanups, more to come.
Rob Landley <rob@landley.net>
parents:
403
diff
changeset
|
186 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
|
187 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
|
188 } |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
189 |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
190 devprefix = getenv("CCWRAP_TOPDIR"); |
807
d0b74a631587
Teach ccwrap.c to use arch-specific WRAPPER_TOPDIR values, to avoid interfering with canadian cross.
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
191 if (!devprefix) { |
d0b74a631587
Teach ccwrap.c to use arch-specific WRAPPER_TOPDIR values, to avoid interfering with canadian cross.
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
192 char *temp, *temp2; |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
193 asprintf(&temp, "%.*sCCWRAP_TOPDIR", prefixlen, toolprefix); |
807
d0b74a631587
Teach ccwrap.c to use arch-specific WRAPPER_TOPDIR values, to avoid interfering with canadian cross.
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
194 temp2 = temp; |
d0b74a631587
Teach ccwrap.c to use arch-specific WRAPPER_TOPDIR values, to avoid interfering with canadian cross.
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
195 while (*temp2) { |
d0b74a631587
Teach ccwrap.c to use arch-specific WRAPPER_TOPDIR values, to avoid interfering with canadian cross.
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
196 if (*temp2 == '-') *temp2='_'; |
d0b74a631587
Teach ccwrap.c to use arch-specific WRAPPER_TOPDIR values, to avoid interfering with canadian cross.
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
197 temp2++; |
d0b74a631587
Teach ccwrap.c to use arch-specific WRAPPER_TOPDIR values, to avoid interfering with canadian cross.
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
198 } |
d0b74a631587
Teach ccwrap.c to use arch-specific WRAPPER_TOPDIR values, to avoid interfering with canadian cross.
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
199 devprefix = getenv(temp); |
d0b74a631587
Teach ccwrap.c to use arch-specific WRAPPER_TOPDIR values, to avoid interfering with canadian cross.
Rob Landley <rob@landley.net>
parents:
800
diff
changeset
|
200 } |
547 | 201 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
|
202 |
943
7f2e6bdfcdcb
Remove the old GIMME_AN_S logic, instead make ccwrap autodetect presence of libgcc_s.so. Also fix a typo causing a nasty bug with the two dash version of --static.
Rob Landley <rob@landley.net>
parents:
937
diff
changeset
|
203 // Do we have libgcc_s.so? |
7f2e6bdfcdcb
Remove the old GIMME_AN_S logic, instead make ccwrap autodetect presence of libgcc_s.so. Also fix a typo causing a nasty bug with the two dash version of --static.
Rob Landley <rob@landley.net>
parents:
937
diff
changeset
|
204 |
7f2e6bdfcdcb
Remove the old GIMME_AN_S logic, instead make ccwrap autodetect presence of libgcc_s.so. Also fix a typo causing a nasty bug with the two dash version of --static.
Rob Landley <rob@landley.net>
parents:
937
diff
changeset
|
205 asprintf(&dlstr, "%s/lib/libgcc_s.so", devprefix); |
7f2e6bdfcdcb
Remove the old GIMME_AN_S logic, instead make ccwrap autodetect presence of libgcc_s.so. Also fix a typo causing a nasty bug with the two dash version of --static.
Rob Landley <rob@landley.net>
parents:
937
diff
changeset
|
206 use_shared_libgcc = is_file(dlstr, 0); |
7f2e6bdfcdcb
Remove the old GIMME_AN_S logic, instead make ccwrap autodetect presence of libgcc_s.so. Also fix a typo causing a nasty bug with the two dash version of --static.
Rob Landley <rob@landley.net>
parents:
937
diff
changeset
|
207 free(dlstr); |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
208 |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
209 // Figure out where the dynamic linker is. |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
210 dlstr = getenv("CCWRAP_DYNAMIC_LINKER"); |
63
89cf9497824e
Teach the native build about ld-uClibc.so.0 can living in /tools.
Rob Landley <rob@landley.net>
parents:
57
diff
changeset
|
211 if (!dlstr) dlstr = "/lib/ld-uClibc.so.0"; |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
212 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
|
213 |
434
116c10067f4a
Replace variable "n" with something greppable.
Rob Landley <rob@landley.net>
parents:
433
diff
changeset
|
214 lplen = 0; |
433
c7a1631711f4
Smallish wrapper cleanups, more to come.
Rob Landley <rob@landley.net>
parents:
403
diff
changeset
|
215 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
|
216 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
|
217 |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
218 // Parse the incoming compiler arguments. |
18
eaf7a8d5e697
Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents:
16
diff
changeset
|
219 |
548
b826a6168464
Coding style and whitespace cleanups, and remove one unnecessary if(cpp).
Rob Landley <rob@landley.net>
parents:
547
diff
changeset
|
220 for (i=1; i<argc; i++) { |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
221 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
|
222 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
|
223 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
|
224 { |
71f438cde285
Make compiler wrapper parse -M options correctly, so uClibc make utils works.
Rob Landley <rob@landley.net>
parents:
447
diff
changeset
|
225 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
|
226 |
71f438cde285
Make compiler wrapper parse -M options correctly, so uClibc make utils works.
Rob Landley <rob@landley.net>
parents:
447
diff
changeset
|
227 // -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
|
228 // 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
|
229 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
|
230 } |
71f438cde285
Make compiler wrapper parse -M options correctly, so uClibc make utils works.
Rob Landley <rob@landley.net>
parents:
447
diff
changeset
|
231 // fall through |
71f438cde285
Make compiler wrapper parse -M options correctly, so uClibc make utils works.
Rob Landley <rob@landley.net>
parents:
447
diff
changeset
|
232 |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
233 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
|
234 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
|
235 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
|
236 linking = 0; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
237 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
|
238 |
eaf7a8d5e697
Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents:
16
diff
changeset
|
239 case 'L': /* library path */ |
434
116c10067f4a
Replace variable "n" with something greppable.
Rob Landley <rob@landley.net>
parents:
433
diff
changeset
|
240 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
|
241 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
|
242 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
|
243 argv[i] = 0; |
434
116c10067f4a
Replace variable "n" with something greppable.
Rob Landley <rob@landley.net>
parents:
433
diff
changeset
|
244 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
|
245 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
|
246 } |
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
|
247 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
|
248 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
|
249 |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
250 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
|
251 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
|
252 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
|
253 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
|
254 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
|
255 |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
256 case 'n': |
548
b826a6168464
Coding style and whitespace cleanups, and remove one unnecessary if(cpp).
Rob Landley <rob@landley.net>
parents:
547
diff
changeset
|
257 if (!strcmp(nostdinc,argv[i])) use_stdinc = 0; |
1148
66c29043b5ca
Tweak ccwrap.c to handle compiler versions that only provide crtbegin.o and crtend.o without T and S versions.
Rob Landley <rob@landley.net>
parents:
1106
diff
changeset
|
258 else if (!strcmp("-nostartfiles",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
|
259 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
|
260 use_start = 0; |
1148
66c29043b5ca
Tweak ccwrap.c to handle compiler versions that only provide crtbegin.o and crtend.o without T and S versions.
Rob Landley <rob@landley.net>
parents:
1106
diff
changeset
|
261 } else if (!strcmp("-nodefaultlibs",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
|
262 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
|
263 argv[i] = 0; |
548
b826a6168464
Coding style and whitespace cleanups, and remove one unnecessary if(cpp).
Rob Landley <rob@landley.net>
parents:
547
diff
changeset
|
264 } else if (!strcmp(nostdlib,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
|
265 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
|
266 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
|
267 use_stdlib = 0; |
548
b826a6168464
Coding style and whitespace cleanups, and remove one unnecessary if(cpp).
Rob Landley <rob@landley.net>
parents:
547
diff
changeset
|
268 } else if (!strcmp(nostdinc_plus,argv[i])) |
b826a6168464
Coding style and whitespace cleanups, and remove one unnecessary if(cpp).
Rob Landley <rob@landley.net>
parents:
547
diff
changeset
|
269 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
|
270 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
|
271 |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
272 case 's': |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
273 if (!strcmp(argv[i],"-static")) { |
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
274 use_static_linking = 1; |
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
275 use_shared_libgcc=0; |
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
276 } |
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
277 if (!strcmp(argv[i],"-static-libgcc")) |
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
278 use_shared_libgcc = 0; |
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
279 if (!strcmp(argv[i],"-shared-libgcc")) |
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
280 use_shared_libgcc = 1; |
548
b826a6168464
Coding style and whitespace cleanups, and remove one unnecessary if(cpp).
Rob Landley <rob@landley.net>
parents:
547
diff
changeset
|
281 if (!strcmp("-shared",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
|
282 use_start = 0; |
549
2edf40b17ee2
Select crtbegin.o and crtend.o variants more accurately for -static and -shared.
Rob Landley <rob@landley.net>
parents:
548
diff
changeset
|
283 use_shared = 1; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
284 } |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
285 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
|
286 |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
287 case 'W': /* -static could be passed directly to ld */ |
548
b826a6168464
Coding style and whitespace cleanups, and remove one unnecessary if(cpp).
Rob Landley <rob@landley.net>
parents:
547
diff
changeset
|
288 if (!strncmp("-Wl,",argv[i],4)) { |
684
222886c9b3f5
Fix wrapper so it doesn't misinterpret -static-libgcc as -static.
Rob Landley <rob@landley.net>
parents:
550
diff
changeset
|
289 char *temp = strstr(argv[i], ",-static"); |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
290 if (temp && (!temp[7] || temp[7]==',')) { |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
291 use_static_linking = 1; |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
292 use_shared_libgcc=0; |
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
293 } |
548
b826a6168464
Coding style and whitespace cleanups, and remove one unnecessary if(cpp).
Rob Landley <rob@landley.net>
parents:
547
diff
changeset
|
294 if (strstr(argv[i],"--dynamic-linker")) dlstr = 0; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
295 } |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
296 break; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
297 |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
298 case 'p': |
20
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
299 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
|
300 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
|
301 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
|
302 |
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
303 temp = argv[i]+7; |
748
897fb219ead7
Teach ccwrap to handle --print-prog-name=ld and such.
Rob Landley <rob@landley.net>
parents:
684
diff
changeset
|
304 if (!strncmp(temp, "prog-name=", 10)) { |
897fb219ead7
Teach ccwrap to handle --print-prog-name=ld and such.
Rob Landley <rob@landley.net>
parents:
684
diff
changeset
|
305 printf("%.*s%s\n", prefixlen, toolprefix, temp+10); |
897fb219ead7
Teach ccwrap to handle --print-prog-name=ld and such.
Rob Landley <rob@landley.net>
parents:
684
diff
changeset
|
306 exit(0); |
897fb219ead7
Teach ccwrap to handle --print-prog-name=ld and such.
Rob Landley <rob@landley.net>
parents:
684
diff
changeset
|
307 } else if (!strcmp(temp, "search-dirs")) { |
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 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
|
309 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
|
310 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
|
311 temp2 = ""; |
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
312 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
|
313 } 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
|
314 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
|
315 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
|
316 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
|
317 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
|
318 |
20
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
319 // 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
|
320 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
|
321 if (itemp == lplen) |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
322 asprintf(&temp, "%s/cc/lib/%s", devprefix, |
550
64779e0f6c28
Make spurious gcc 4.3 warnings shut up. (What a horrible compiler.)
Rob Landley <rob@landley.net>
parents:
549
diff
changeset
|
323 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
|
324 else if (itemp == lplen+1) |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
325 asprintf(&temp, "%s/lib/%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
|
326 |
905
023b577fb865
Break up sources/sections/binutils-gcc.sh into binutils, gcc, and ccwrap, plus more gcc->cc cleanup.
Rob Landley <rob@landley.net>
parents:
888
diff
changeset
|
327 // This is so "include" finds the cc internal |
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
|
328 // 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
|
329 else if (itemp == lplen+2) |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
330 asprintf(&temp, "%s/cc/%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
|
331 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
|
332 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
|
333 break; |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
334 } 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
|
335 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
|
336 |
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
|
337 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
|
338 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
|
339 |
20
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
340 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
|
341 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
|
342 } |
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
343 |
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
|
344 |
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
|
345 |
20
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
346 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
|
347 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
|
348 |
44067ab61cd2
Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents:
19
diff
changeset
|
349 // Profiling. |
42
7b0f34fbc35a
Fix inappropriate activation of profiling support, and add environment variable
Rob Landley <rob@landley.net>
parents:
30
diff
changeset
|
350 } 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
|
351 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
|
352 |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
353 case 'f': |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
354 // profiling |
549
2edf40b17ee2
Select crtbegin.o and crtend.o variants more accurately for -static and -shared.
Rob Landley <rob@landley.net>
parents:
548
diff
changeset
|
355 if (strcmp("-fprofile-arcs",argv[i]) == 0) 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
|
356 break; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
357 |
1327
64d310e39a12
Teach ccwrap to switch off -xc after command line sources listed, so cc doesn't try to interpret libc and such as C sources.
Rob Landley <rob@landley.net>
parents:
1286
diff
changeset
|
358 case 'x': |
64d310e39a12
Teach ccwrap to switch off -xc after command line sources listed, so cc doesn't try to interpret libc and such as C sources.
Rob Landley <rob@landley.net>
parents:
1286
diff
changeset
|
359 used_x++; |
64d310e39a12
Teach ccwrap to switch off -xc after command line sources listed, so cc doesn't try to interpret libc and such as C sources.
Rob Landley <rob@landley.net>
parents:
1286
diff
changeset
|
360 break; |
64d310e39a12
Teach ccwrap to switch off -xc after command line sources listed, so cc doesn't try to interpret libc and such as C sources.
Rob Landley <rob@landley.net>
parents:
1286
diff
changeset
|
361 |
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
|
362 // --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
|
363 |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
364 case '-': |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
365 if (!strncmp(argv[i],"--print-",8) |
1250
be39ef99f183
And e2fsprogs needs "--shared", not just "-shared". I'm not sure playing whack-a-mole with --long -> -long option conversion is the best way for the wrapper to approach this, but until somebody explains the logic of which longopts gcc accepts a single dash for and which it doesn't...
Rob Landley <rob@landley.net>
parents:
1189
diff
changeset
|
366 || !strncmp(argv[i],"--static",8) |
be39ef99f183
And e2fsprogs needs "--shared", not just "-shared". I'm not sure playing whack-a-mole with --long -> -long option conversion is the best way for the wrapper to approach this, but until somebody explains the logic of which longopts gcc accepts a single dash for and which it doesn't...
Rob Landley <rob@landley.net>
parents:
1189
diff
changeset
|
367 || !strncmp(argv[i],"--shared",8)) |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
368 { |
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
|
369 argv[i]++; |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
370 i--; |
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
371 continue; |
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
372 } else if (!strcmp("--no-ctors", 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
|
373 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
|
374 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
|
375 } |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
376 break; |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
377 } |
548
b826a6168464
Coding style and whitespace cleanups, and remove one unnecessary if(cpp).
Rob Landley <rob@landley.net>
parents:
547
diff
changeset
|
378 // assume it is an existing source file |
b826a6168464
Coding style and whitespace cleanups, and remove one unnecessary if(cpp).
Rob Landley <rob@landley.net>
parents:
547
diff
changeset
|
379 } else ++source_count; |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
380 } |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
381 |
28
a6a06bf0c541
Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents:
22
diff
changeset
|
382 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
|
383 |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
384 cc_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
|
385 |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
386 if (cpp) cc_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
|
387 |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
388 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
|
389 //#if defined HAS_ELF && ! defined HAS_MMU |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
390 // cc_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
|
391 //#endif |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
392 cc_argv[argcnt++] = nostdlib; |
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
393 if (use_static_linking) cc_argv[argcnt++] = "-static"; |
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
394 else if (dlstr) cc_argv[argcnt++] = dlstr; |
548
b826a6168464
Coding style and whitespace cleanups, and remove one unnecessary if(cpp).
Rob Landley <rob@landley.net>
parents:
547
diff
changeset
|
395 for (i=0; i<lplen; i++) |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
396 if (libpath[i]) cc_argv[argcnt++] = libpath[i]; |
547 | 397 |
398 // just to be safe: | |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
399 asprintf(cc_argv+(argcnt++), "-Wl,-rpath-link,%s/lib", devprefix); |
547 | 400 |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
401 asprintf(cc_argv+(argcnt++), "-L%s/lib", devprefix); |
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
402 asprintf(cc_argv+(argcnt++), "-L%s/cc/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
|
403 } |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
404 if (use_stdinc && source_count) { |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
405 cc_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
|
406 |
447
4ed02d53fc92
Add C++ support to native compiler, based on uClibc++.
Rob Landley <rob@landley.net>
parents:
441
diff
changeset
|
407 if (cpp) { |
1148
66c29043b5ca
Tweak ccwrap.c to handle compiler versions that only provide crtbegin.o and crtend.o without T and S versions.
Rob Landley <rob@landley.net>
parents:
1106
diff
changeset
|
408 if (use_nostdinc_plus) cc_argv[argcnt++] = "-nostdinc++"; |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
409 cc_argv[argcnt++] = "-isystem"; |
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
410 asprintf(cc_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
|
411 } |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
412 |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
413 cc_argv[argcnt++] = "-isystem"; |
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
414 asprintf(cc_argv+(argcnt++), "%s/include", devprefix); |
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
415 cc_argv[argcnt++] = "-isystem"; |
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
416 asprintf(cc_argv+(argcnt++), "%s/cc/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
|
417 } |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
418 |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
419 cc_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
|
420 |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
421 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
|
422 |
547 | 423 if (profile) |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
424 asprintf(cc_argv+(argcnt++), "%s/lib/gcrt1.o", devprefix); |
547 | 425 |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
426 if (ctor_dtor) { |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
427 asprintf(cc_argv+(argcnt++), "%s/lib/crti.o", devprefix); |
1148
66c29043b5ca
Tweak ccwrap.c to handle compiler versions that only provide crtbegin.o and crtend.o without T and S versions.
Rob Landley <rob@landley.net>
parents:
1106
diff
changeset
|
428 cc_argv[argcnt++]=find_TSpath("%s/cc/lib/crtbegin%s", |
66c29043b5ca
Tweak ccwrap.c to handle compiler versions that only provide crtbegin.o and crtend.o without T and S versions.
Rob Landley <rob@landley.net>
parents:
1106
diff
changeset
|
429 use_shared, use_static_linking); |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
430 } |
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
|
431 if (use_start && !profile) |
1189
9cf24282eecf
Use Scrt1.o when building a shared library.
Rob Landley <rob@landley.net>
parents:
1148
diff
changeset
|
432 asprintf(cc_argv+(argcnt++), "%s/lib/%scrt1.o", devprefix, use_shared ? "S" : ""); |
16
7946bc54424b
Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents:
14
diff
changeset
|
433 |
7946bc54424b
Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents:
14
diff
changeset
|
434 // 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
|
435 |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
436 for (i=1; i<argc; i++) if (argv[i]) cc_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
|
437 |
1327
64d310e39a12
Teach ccwrap to switch off -xc after command line sources listed, so cc doesn't try to interpret libc and such as C sources.
Rob Landley <rob@landley.net>
parents:
1286
diff
changeset
|
438 if (used_x) cc_argv[argcnt++] = "-xnone"; |
64d310e39a12
Teach ccwrap to switch off -xc after command line sources listed, so cc doesn't try to interpret libc and such as C sources.
Rob Landley <rob@landley.net>
parents:
1286
diff
changeset
|
439 |
948
ce8d2ff56908
Redo library sequencing, add -lgcc before -gcc_s (because that's what gcc expects).
Rob Landley <rob@landley.net>
parents:
947
diff
changeset
|
440 // Add standard libraries |
ce8d2ff56908
Redo library sequencing, add -lgcc before -gcc_s (because that's what gcc expects).
Rob Landley <rob@landley.net>
parents:
947
diff
changeset
|
441 |
13
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
442 if (use_stdlib) { |
447
4ed02d53fc92
Add C++ support to native compiler, based on uClibc++.
Rob Landley <rob@landley.net>
parents:
441
diff
changeset
|
443 if (cpp) { |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
444 cc_argv[argcnt++] = "-lstdc++"; |
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
445 cc_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
|
446 } |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
447 |
948
ce8d2ff56908
Redo library sequencing, add -lgcc before -gcc_s (because that's what gcc expects).
Rob Landley <rob@landley.net>
parents:
947
diff
changeset
|
448 // libgcc can call libc which can call libgcc |
ce8d2ff56908
Redo library sequencing, add -lgcc before -gcc_s (because that's what gcc expects).
Rob Landley <rob@landley.net>
parents:
947
diff
changeset
|
449 |
1449
5b79ffca554a
Make ccwrap use --start-group and --end-group rather than specifying the same libraries multiple times.
Rob Landley <rob@landley.net>
parents:
1327
diff
changeset
|
450 cc_argv[argcnt++] = "-Wl,--start-group,--as-needed"; |
948
ce8d2ff56908
Redo library sequencing, add -lgcc before -gcc_s (because that's what gcc expects).
Rob Landley <rob@landley.net>
parents:
947
diff
changeset
|
451 cc_argv[argcnt++] = "-lgcc"; |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
452 if (!use_static_linking && use_shared_libgcc) |
1449
5b79ffca554a
Make ccwrap use --start-group and --end-group rather than specifying the same libraries multiple times.
Rob Landley <rob@landley.net>
parents:
1327
diff
changeset
|
453 cc_argv[argcnt++] = "-lgcc_s"; |
948
ce8d2ff56908
Redo library sequencing, add -lgcc before -gcc_s (because that's what gcc expects).
Rob Landley <rob@landley.net>
parents:
947
diff
changeset
|
454 else cc_argv[argcnt++] = "-lgcc_eh"; |
ce8d2ff56908
Redo library sequencing, add -lgcc before -gcc_s (because that's what gcc expects).
Rob Landley <rob@landley.net>
parents:
947
diff
changeset
|
455 cc_argv[argcnt++] = "-lc"; |
1449
5b79ffca554a
Make ccwrap use --start-group and --end-group rather than specifying the same libraries multiple times.
Rob Landley <rob@landley.net>
parents:
1327
diff
changeset
|
456 cc_argv[argcnt++] = "-Wl,--no-as-needed,--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
|
457 } |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
458 if (ctor_dtor) { |
1148
66c29043b5ca
Tweak ccwrap.c to handle compiler versions that only provide crtbegin.o and crtend.o without T and S versions.
Rob Landley <rob@landley.net>
parents:
1106
diff
changeset
|
459 cc_argv[argcnt++] = find_TSpath("%s/cc/lib/crtend%s", use_shared, 0); |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
460 asprintf(cc_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
|
461 } |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
462 } else for (i=1; i<argc; i++) if (argv[i]) cc_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
|
463 |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
464 cc_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
|
465 |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
466 if (verbose) { |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
467 for (i=0; cc_argv[i]; i++) printf("arg[%2i] = %s\n", i, cc_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
|
468 fflush(stdout); |
d34028ce8602
A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
469 } |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
470 |
42
7b0f34fbc35a
Fix inappropriate activation of profiling support, and add environment variable
Rob Landley <rob@landley.net>
parents:
30
diff
changeset
|
471 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
|
472 fprintf(stderr, "outgoing: "); |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
473 for (i=0; cc_argv[i]; i++) fprintf(stderr, "%s ",cc_argv[i]); |
217
01fd30185476
Use fprintf(stderr,...) instead of dprintf(2,...) to be more portable.
Rob Landley <rob@landley.net>
parents:
76
diff
changeset
|
474 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
|
475 } |
7b0f34fbc35a
Fix inappropriate activation of profiling support, and add environment variable
Rob Landley <rob@landley.net>
parents:
30
diff
changeset
|
476 |
937
f2b4d7297c9d
Largeish cleanup of ccwrap.c. Remove lots of uclibc-isms, put rawcc in tools/bin.
Rob Landley <rob@landley.net>
parents:
935
diff
changeset
|
477 execvp(cc_argv[0], cc_argv); |
14
8b4600334a3d
Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents:
13
diff
changeset
|
478 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
|
479 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
|
480 } |