annotate sources/toys/gcc-uClibc.c @ 42:7b0f34fbc35a

Fix inappropriate activation of profiling support, and add environment variable DEBUG_WRAPPER to show before and after arguments, rather than commenting out the code when it's not needed.
author Rob Landley <rob@landley.net>
date Sun, 17 Dec 2006 14:19:51 -0500
parents 8cfc981a9b8e
children 74a09b4b2d57
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
22
775c1fdc1730 Minor cleanup on the wrapper script (much more cleanup needed before it's
Rob Landley <rob@landley.net>
parents: 20
diff changeset
5 * Copyright (C) 2006 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
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
11 #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
12 #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
13 #include <stdarg.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 <string.h>
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
15 #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
16 #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
17 #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
18 #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
19
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
20 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
21 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
22 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
23 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
24 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
25 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
26
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
27 // For C++
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
28 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
29
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
30
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
31 // 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
32 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
33 {
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
34 // 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
35 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
36 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
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 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
39 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
40 }
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
41 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
42 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
43
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
44 // 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
45
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
46 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
47 {
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
48 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
49
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
50 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
51 return strdup(filename);
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
52
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
53 for (;;) {
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
54 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
55 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
56
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
57 str = malloc(strlen(filename) + (len ? len : strlen(cwd)) + 2);
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
58 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
59 else {
16
7946bc54424b Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents: 14
diff changeset
60 char *str2 = str;
7946bc54424b Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents: 14
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 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
63 str2 = str+len;
7946bc54424b Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents: 14
diff changeset
64 *(str2++) = '/';
7946bc54424b Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents: 14
diff changeset
65 strcpy(str2, filename);
14
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
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
68 // 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
69 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
70 else free(str);
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
71
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
72 if (!next) break;
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
73 path += len;
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
74 path++;
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
75 }
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
76 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
77
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
78 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
79 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
80
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
81 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
82 {
20
44067ab61cd2 Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents: 19
diff changeset
83 int use_build_dir = 0, 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
84 int use_stdinc = 1, use_start = 1, use_stdlib = 1, use_pic = 0;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
85 int source_count = 0, use_rpath = 0, verbose = 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
86 int i, argcnt, liblen, n, sawM = 0, sawdotoa = 0, sawcES = 0;
16
7946bc54424b Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents: 14
diff changeset
87 char **gcc_argv, **libraries, **libpath;
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
88 char *dlstr, *incstr, *devprefix, *libstr, *build_dlstr = 0;
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
89 char *cc, *ep, *rpath_link[2], *rpath[2], *uClibc_inc[2], *our_lib_path[2];
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
90 char *crt0_path[2], *crtbegin_path[2], *crtend_path[2];
42
7b0f34fbc35a Fix inappropriate activation of profiling support, and add environment variable
Rob Landley <rob@landley.net>
parents: 30
diff changeset
91 char *debug_wrapper=getenv("DEBUG_WRAPPER");
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
92
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
93 // For C++
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
94
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
95 char *crti_path[2], *crtn_path[2], *cpp = NULL;
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
96 int len, ctor_dtor = 1, cplusplus = 0, 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
97
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
98 // For profiling
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
99 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
100 char *gcrt1_path[2];
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
101
42
7b0f34fbc35a Fix inappropriate activation of profiling support, and add environment variable
Rob Landley <rob@landley.net>
parents: 30
diff changeset
102 if(debug_wrapper) {
7b0f34fbc35a Fix inappropriate activation of profiling support, and add environment variable
Rob Landley <rob@landley.net>
parents: 30
diff changeset
103 dprintf(2,"incoming: ");
7b0f34fbc35a Fix inappropriate activation of profiling support, and add environment variable
Rob Landley <rob@landley.net>
parents: 30
diff changeset
104 for(gcc_argv=argv;*gcc_argv;gcc_argv++) dprintf(2,"%s ",*gcc_argv);
7b0f34fbc35a Fix inappropriate activation of profiling support, and add environment variable
Rob Landley <rob@landley.net>
parents: 30
diff changeset
105 dprintf(2,"\n\n");
7b0f34fbc35a Fix inappropriate activation of profiling support, and add environment variable
Rob Landley <rob@landley.net>
parents: 30
diff changeset
106 }
28
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
107
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
108 // Allocate space for new command line
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
109 gcc_argv = __builtin_alloca(sizeof(char*) * (argc + 128));
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
110
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
111 // 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
112 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
113 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
114 exit(1);
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
115 } else {
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
116 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
117
16
7946bc54424b Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents: 14
diff changeset
118 // Add that directory to the start of $PATH. (Better safe than sorry.)
7946bc54424b Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents: 14
diff changeset
119 *rindex(topdir,'/') = 0;
7946bc54424b Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents: 14
diff changeset
120 temp = malloc(strlen(topdir)+strlen(path)+7);
7946bc54424b Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents: 14
diff changeset
121 sprintf(temp,"PATH=%s:%s",topdir,path);
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
122 putenv(temp);
16
7946bc54424b Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents: 14
diff changeset
123
7946bc54424b Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents: 14
diff changeset
124 temp = rindex(topdir,'/');
7946bc54424b Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents: 14
diff changeset
125 if(temp) *temp=0;
30
8cfc981a9b8e Make the wrapper script happy if the current directory is in the cross compiler
Rob Landley <rob@landley.net>
parents: 29
diff changeset
126 else {
8cfc981a9b8e Make the wrapper script happy if the current directory is in the cross compiler
Rob Landley <rob@landley.net>
parents: 29
diff changeset
127 // Are we in the same directory as the compiler?
8cfc981a9b8e Make the wrapper script happy if the current directory is in the cross compiler
Rob Landley <rob@landley.net>
parents: 29
diff changeset
128 if (!strcmp(".",topdir)) topdir="..";
8cfc981a9b8e Make the wrapper script happy if the current directory is in the cross compiler
Rob Landley <rob@landley.net>
parents: 29
diff changeset
129 // Are we right above it?
8cfc981a9b8e Make the wrapper script happy if the current directory is in the cross compiler
Rob Landley <rob@landley.net>
parents: 29
diff changeset
130 else topdir=".";
8cfc981a9b8e Make the wrapper script happy if the current directory is in the cross compiler
Rob Landley <rob@landley.net>
parents: 29
diff changeset
131 // If somebody makes a subdirectory under bin and calls gcc via
8cfc981a9b8e Make the wrapper script happy if the current directory is in the cross compiler
Rob Landley <rob@landley.net>
parents: 29
diff changeset
132 // "..", I really don't care.
8cfc981a9b8e Make the wrapper script happy if the current directory is in the cross compiler
Rob Landley <rob@landley.net>
parents: 29
diff changeset
133 }
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
134 }
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
135
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
136 // 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
137 // cross-prefix.)
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
138 cc = getenv("UCLIBC_CC");
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 16
diff changeset
139 if (!cc) cc = "gcc-unwrapped";
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
140
16
7946bc54424b Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents: 14
diff changeset
141
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
142 // 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
143 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
144 if (!strcmp(argv[0]+len-2, "ld")) {
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
145 // We're wrapping the linker.
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
146 // Wrapping the c++ compiler?
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
147 } else if (!strcmp(argv[0]+len-3, "g++") || !strcmp(argv[0]+len-3, "c++")) {
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
148 len = strlen(cc);
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
149 if (strcmp(cc+len-3, "gcc")==0) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
150 cpp = strdup(cc);
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
151 cpp[len-1]='+';
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
152 cpp[len-2]='+';
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
153 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
154 cplusplus = 1;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
155 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
156 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
157
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
158 devprefix = getenv("UCLIBC_DEVEL_PREFIX");
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
159 if (!devprefix) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
160 devprefix = topdir;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
161 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
162
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
163 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
164 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
165
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
166 ep = getenv("UCLIBC_ENV");
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
167 if (!ep) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
168 ep = "";
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
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
171 if (strstr(ep,"build") != 0) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
172 use_build_dir = 1;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
173 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
174
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
175 if (strstr(ep,"rpath") != 0) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
176 use_rpath = 1;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
177 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
178
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
179
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 16
diff changeset
180 asprintf(rpath_link,"-Wl,-rpath-link,%s/lib", devprefix);
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 16
diff changeset
181 asprintf(rpath, "-Wl,-rpath,%s/lib", devprefix);
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 16
diff changeset
182 asprintf(uClibc_inc, "%s/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
183
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
184 //#ifdef CTOR_DTOR
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 16
diff changeset
185 asprintf(crt0_path, "%s/lib/crt1.o", devprefix);
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 16
diff changeset
186 asprintf(crti_path, "%s/lib/crti.o", devprefix);
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 16
diff changeset
187 asprintf(crtn_path, "%s/lib/crtn.o", devprefix);
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
188 //#else
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 16
diff changeset
189 // *crt0_path = asprintf("%s/lib/crt0.o", devprefix);
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
190 //#endif
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
191
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
192 // profiling
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 16
diff changeset
193 asprintf(gcrt1_path, "%s/lib/gcrt1.o", devprefix, "/lib/gcrt1.o");
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 16
diff changeset
194 asprintf(our_lib_path, "-L%s/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
195
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
196 // Figure out where the dynamic linker is.
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
197 dlstr = getenv("UCLIBC_GCC_DLOPT");
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 16
diff changeset
198 if (!dlstr) dlstr = "-Wl,--dynamic-linker,/lib/ld-uClibc.so.0";
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
199
28
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
200 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
201 libraries = __builtin_alloca(sizeof(char*) * (argc));
28
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
202 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
203
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
204 n = 0;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
205 libpath = __builtin_alloca(sizeof(char*) * (argc));
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
206 libpath[n] = '\0';
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
207
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 16
diff changeset
208 // 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
209
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
210 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
211 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
212 switch (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
213 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
214 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
215 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
216 case 'M': /* generate dependencies */
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
217 linking = 0;
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 16
diff changeset
218 if (argv[i][1] == 'M') sawM = 1;
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 16
diff changeset
219 else sawcES = 1;
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
220 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
221
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 16
diff changeset
222 case 'L': /* library path */
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
223 libpath[n++] = argv[i];
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
224 libpath[n] = '\0';
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) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
226 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
227 libpath[n++] = argv[++i];
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
228 libpath[n] = '\0';
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
229 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
230 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
231 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
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 '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
234 libraries[liblen++] = argv[i];
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
235 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
236 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 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
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
239 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
240 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
241 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
242 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
243 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
244
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
245 case 'n':
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
246 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
247 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
248 } 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
249 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
250 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
251 } 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
252 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
253 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
254 } 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
255 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
256 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
257 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
258 } else if (strcmp(nostdinc_plus,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
259 if (cplusplus==1) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
260 use_nostdinc_plus = 0;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
261 }
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 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
264
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
265 case 's':
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
266 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
267 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
268 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
269 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
270 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
271 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
272 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
273 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
274
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
275 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
276 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
277 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
278 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
279 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
280 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
281 dlstr = 0;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
282 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
283 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
284 break;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
285
20
44067ab61cd2 Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents: 19
diff changeset
286 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
287 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
288 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
289 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
290 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
291
44067ab61cd2 Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents: 19
diff changeset
292 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
293 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
294 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
295 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
296 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
297 temp2 = "";
44067ab61cd2 Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents: 19
diff changeset
298 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
299 } 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
300 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
301 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
302 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
303 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
304
20
44067ab61cd2 Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents: 19
diff changeset
305 // 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
306 for(itemp=0;;itemp++) {
44067ab61cd2 Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents: 19
diff changeset
307 if (itemp == n) {
44067ab61cd2 Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents: 19
diff changeset
308 asprintf(&temp, "%s/gcc/lib/%s", devprefix, temp2);
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 (itemp == n+1) {
44067ab61cd2 Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents: 19
diff changeset
310 // This is so "include" finds the gcc internal
44067ab61cd2 Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents: 19
diff changeset
311 // include dir. The uClibc build needs this.
44067ab61cd2 Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents: 19
diff changeset
312 asprintf(&temp, "%s/gcc/%s", devprefix, temp2);
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 (itemp == n+2) {
44067ab61cd2 Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents: 19
diff changeset
314 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
315 break;
44067ab61cd2 Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents: 19
diff changeset
316 } else {
44067ab61cd2 Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents: 19
diff changeset
317 asprintf(&temp, "%s/%s", libpath[itemp],
44067ab61cd2 Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents: 19
diff changeset
318 temp2);
44067ab61cd2 Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents: 19
diff changeset
319 }
44067ab61cd2 Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents: 19
diff changeset
320 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
321 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
322 }
44067ab61cd2 Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents: 19
diff changeset
323
44067ab61cd2 Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents: 19
diff changeset
324 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
325 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
326
44067ab61cd2 Switch linking back on as the default, add support for -print-search-dirs,
Rob Landley <rob@landley.net>
parents: 19
diff changeset
327 // Profiling.
42
7b0f34fbc35a Fix inappropriate activation of profiling support, and add environment variable
Rob Landley <rob@landley.net>
parents: 30
diff changeset
328 } 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
329 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
330
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
331 case 'f':
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
332 /* 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
333 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
334 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
335 } 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
336 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
337
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
338 // profiling
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
339 } 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
340 profile = 1;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
341 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
342 break;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
343
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
344 // --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
345
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
346 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
347 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
348 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
349 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
350 } 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
351 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
352 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
353 } 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
354 printf("uClibc ");
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
355 fflush(stdout);
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 } else if (strcmp("--uclibc-use-build-dir",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
358 use_build_dir = 1;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
359 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
360 } else if (strcmp("--uclibc-use-rpath",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
361 use_rpath = 1;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
362 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
363 } 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
364 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
365 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
366 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
367 } 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
368 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
369 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
370 } 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
371 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
372 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
373 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
374 break;
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 } 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
377 char *p = strchr (argv[i], '\0') - 2;
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 16
diff changeset
378 if (p > argv[i] && sawM && (!strcmp(p, ".o") || !strcmp(p, ".a")))
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
379 sawdotoa = 1;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
380 ++source_count;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
381 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
382 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
383
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
384 if (sawdotoa && sawM && !sawcES)
b5ffd82d9ae5 Two problems: 1) Needed to parse -print-file-name= to make the uClibc build
Rob Landley <rob@landley.net>
parents: 18
diff changeset
385 linking = 1;
b5ffd82d9ae5 Two problems: 1) Needed to parse -print-file-name= to make the uClibc build
Rob Landley <rob@landley.net>
parents: 18
diff changeset
386
28
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
387 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
388 if (ctor_dtor) {
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 16
diff changeset
389 asprintf(crtbegin_path, "%s/gcc/lib/crtbegin.o", devprefix);
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 16
diff changeset
390 asprintf(crtbegin_path+1, "%s/gcc/lib/crtbeginS.o", devprefix);
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 16
diff changeset
391 asprintf(crtend_path, "%s/gcc/lib/crtend.o", devprefix);
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 16
diff changeset
392 asprintf(crtend_path+1, "%s/gcc/lib/crtendS.o", devprefix);
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
393 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
394
28
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
395 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
396
28
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
397 if (cplusplus) 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
398
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
399 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
400 //#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
401 // 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
402 //#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
403 gcc_argv[argcnt++] = nostdlib;
13
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_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
405 gcc_argv[argcnt++] = static_linking;
16
7946bc54424b Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents: 14
diff changeset
406 } else {
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
407 if (dlstr && use_build_dir) {
28
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
408 gcc_argv[argcnt++] = build_dlstr;
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
409 } else if (dlstr) {
28
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
410 gcc_argv[argcnt++] = dlstr;
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 if (use_rpath) {
28
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
413 gcc_argv[argcnt++] = rpath[use_build_dir];
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
414 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
415 }
28
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
416 for ( i = 0 ; i < n ; i++ )
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
417 if (libpath[i]) gcc_argv[argcnt++] = libpath[i];
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
418 gcc_argv[argcnt++] = rpath_link[use_build_dir]; /* just to be safe */
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
419 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
420 gcc_argv[argcnt++] = libstr;
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
421 gcc_argv[argcnt++] = our_lib_path[use_build_dir];
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
422 if (!use_build_dir)
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
423 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
424 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
425 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
426 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
427
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
428 if (cplusplus) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
429 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
430 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
431 }
28
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
432 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
433 asprintf(gcc_argv+(argcnt++), "%sc++/4.1.1", uClibc_inc[use_build_dir]);
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 16
diff changeset
434 //char *cppinc;
22
775c1fdc1730 Minor cleanup on the wrapper script (much more cleanup needed before it's
Rob Landley <rob@landley.net>
parents: 20
diff changeset
435 //#define TARGET_DIR "gcc/armv4l-unknown-linux/gnu/4.1.1"
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 16
diff changeset
436 //xstrcat(&cppinc, uClibc_inc[use_build_dir], "c++/4.1.1/" TARGET_DIR, NULL);
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++] = "-isystem";
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++] = cppinc;
18
eaf7a8d5e697 Managed to get a working toolchain, with wrapper script, to build a hello
Rob Landley <rob@landley.net>
parents: 16
diff changeset
439 //xstrcat(&cppinc, uClibc_inc[use_build_dir], "c++/4.1.1", NULL);
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++] = "-isystem";
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++] = cppinc;
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
442 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
443
28
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
444 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
445 gcc_argv[argcnt++] = uClibc_inc[use_build_dir];
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
446 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
447 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
448 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
449 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
450
28
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
451 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
452
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
453 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
454
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
455 if (profile) {
28
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
456 gcc_argv[argcnt++] = gcrt1_path[use_build_dir];
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) {
28
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
459 gcc_argv[argcnt++] = crti_path[use_build_dir];
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
460 if (use_pic) {
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 gcc_argv[argcnt++] = crtbegin_path[1];
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
462 } else {
28
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
463 gcc_argv[argcnt++] = crtbegin_path[0];
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
464 }
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 (use_start) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
467 if (!profile) {
28
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
468 gcc_argv[argcnt++] = crt0_path[use_build_dir];
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
469 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
470 }
16
7946bc54424b Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents: 14
diff changeset
471
7946bc54424b Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents: 14
diff changeset
472 // 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
473
28
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
474 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
475
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
476 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
477 //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
478 gcc_argv[argcnt++] = "-lgcc";
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
479 // gcc_argv[argcnt++] = "-lgcc_eh";
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
480 }
28
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
481 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
482 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
483 if (use_stdlib) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
484 if (cplusplus) {
28
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
485 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
486 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
487 }
28
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
488 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
489 gcc_argv[argcnt++] = "-lgcc";
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
490 // gcc_argv[argcnt++] = "-lgcc_eh";
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
491 //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
492 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
493 if (ctor_dtor) {
28
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
494 gcc_argv[argcnt++] = crtend_path[use_pic ? 1 : 0];
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
495 gcc_argv[argcnt++] = crtn_path[use_build_dir];
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
496 }
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
497 } 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
498
28
a6a06bf0c541 Replace single character variable names with ones that are easier to grep for.
Rob Landley <rob@landley.net>
parents: 22
diff changeset
499 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
500
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
501 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
502 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
503 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
504 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
505 fflush(stdout);
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
506 }
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
507
42
7b0f34fbc35a Fix inappropriate activation of profiling support, and add environment variable
Rob Landley <rob@landley.net>
parents: 30
diff changeset
508 if (debug_wrapper) {
7b0f34fbc35a Fix inappropriate activation of profiling support, and add environment variable
Rob Landley <rob@landley.net>
parents: 30
diff changeset
509 dprintf(2, "outgoing: ");
7b0f34fbc35a Fix inappropriate activation of profiling support, and add environment variable
Rob Landley <rob@landley.net>
parents: 30
diff changeset
510 for(i=0; gcc_argv[i]; i++) dprintf(2, "%s ",gcc_argv[i]);
7b0f34fbc35a Fix inappropriate activation of profiling support, and add environment variable
Rob Landley <rob@landley.net>
parents: 30
diff changeset
511 dprintf(2, "\n\n");
7b0f34fbc35a Fix inappropriate activation of profiling support, and add environment variable
Rob Landley <rob@landley.net>
parents: 30
diff changeset
512 }
7b0f34fbc35a Fix inappropriate activation of profiling support, and add environment variable
Rob Landley <rob@landley.net>
parents: 30
diff changeset
513
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
514 //no need to free memory from xstrcat because we never return...
16
7946bc54424b Some more work on the wrapper. Still doesn't work yet.
Rob Landley <rob@landley.net>
parents: 14
diff changeset
515 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
516 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
517 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
518 }