gcc-uClibc.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. /*
  2. * Copyright (C) 2000 Manuel Novoa III
  3. * Copyright (C) 2002 Erik Andersen
  4. *
  5. * This is a crude wrapper to use uClibc with gcc.
  6. * It was originally written to work around ./configure for ext2fs-utils.
  7. * It certainly can be improved, but it works for me in the normal cases.
  8. *
  9. * April 7, 2001
  10. *
  11. * A bug was fixed in building the gcc command line when dynamic linking.
  12. * The functions dlopen, etc. now work. At this time, you must make sure
  13. * the correct libdl.so is included however. It is safest to, for example,
  14. * add /lib/libdl.so.1 if using ld-linux.so.1 rather than adding -ldl to the
  15. * command line.
  16. *
  17. * Note: This is only a problem if devel and target archs are the same. To
  18. * avoid the problem, you can use a customized dynamic linker.
  19. *
  20. *
  21. * April 18, 2001
  22. *
  23. * The wrapper now works with either installed and uninstalled uClibc versions.
  24. * If you want to use the uninstalled header files and libs, either include
  25. * the string "build" in the invocation name such as
  26. * 'ln -s <ARCH>-uclibc-gcc <ARCH>-uclibc-gcc-build'
  27. * or include it in the environment variable setting of UCLIBC_GCC.
  28. * Note: This automatically enables the "rpath" behavior described below.
  29. *
  30. * The wrapper will now pass the location of the uClibc shared libs used to
  31. * the linker with the "-rpath" option if the invocation name includes the
  32. * string "rpath" or if the environment variable UCLIBC_GCC include it (as
  33. * with "build" above). This is primarily intended to be used on devel
  34. * platforms of the same arch as the target. A good place to use this feature
  35. * would be in the uClibc/test directory.
  36. *
  37. * The wrapper now displays the command line passed to gcc when '-v' is used.
  38. *
  39. * May 31, 2001
  40. *
  41. * "rpath" and "build" behavior are now decoupled. You can of course get
  42. * the old "build" behavior by setting UCLIBC_GCC="rpath-build". Order
  43. * isn't important here, as only the substrings are searched for.
  44. *
  45. * Added environment variable check for UCLIBC_GCC_DLOPT to let user specify
  46. * an alternative dynamic linker at runtime without using command line args.
  47. * Since this wouldn't commonly be used, I made it easy on myself. You have
  48. * to match the option you would have passed to the gcc wrapper. As an
  49. * example,
  50. *
  51. * export UCLIBC_GCC_DLOPT="-Wl,--dynamic-linker,/lib/ld-alt-linker.so.3"
  52. *
  53. * This is really only useful if target arch == devel arch and DEVEL_PREFIX
  54. * isn't empty. It involves a recompile, but you can at least test apps
  55. * on your devel system if combined with the "rpath" behavor if by using
  56. * LD_LIBRARY_PATH, etc.
  57. *
  58. * Also added check for "-Wl,--dynamic-linker" on the command line. The
  59. * use default dynamic linker or the envirnment-specified dynamic linker
  60. * is disabled in that case.
  61. *
  62. * Added options --uclibc-use-build-dir and --uclibc-use-rpath so that those
  63. * behaviors can be invoked from the command line.
  64. *
  65. */
  66. /*
  67. *
  68. * TODO:
  69. * Check/modify gcc-specific environment variables?
  70. */
  71. #include <stdio.h>
  72. #include <stdlib.h>
  73. #include <stdarg.h>
  74. #include <string.h>
  75. #include <unistd.h>
  76. #include <sys/stat.h>
  77. #include <sys/wait.h>
  78. #include "gcc-uClibc.h"
  79. static char *our_usr_lib_path = "-L"UCLIBC_DEVEL_PREFIX"/lib";
  80. static char static_linking[] = "-static";
  81. static char nostdinc[] = "-nostdinc";
  82. static char nostartfiles[] = "-nostartfiles";
  83. static char nodefaultlibs[] = "-nodefaultlibs";
  84. static char nostdlib[] = "-nostdlib";
  85. #ifdef __UCLIBC_CTOR_DTOR__
  86. static char nostdinc_plus[] = "-nostdinc++";
  87. #endif
  88. /* Include a local implementation of basename, since this
  89. * uses the host system's C lib, and CYGWIN apparently
  90. * doesn't provide an implementation of basename(). */
  91. char *basename(const char *path)
  92. {
  93. register const char *s;
  94. register const char *p;
  95. p = s = path;
  96. while (*s) {
  97. if (*s++ == '/') {
  98. p = s;
  99. }
  100. }
  101. return (char *) p;
  102. }
  103. char *dirname(char *path)
  104. {
  105. static const char null_or_empty_or_noslash[] = ".";
  106. register char *s;
  107. register char *last;
  108. char *first;
  109. last = s = path;
  110. if (s != NULL) {
  111. LOOP:
  112. while (*s && (*s != '/')) ++s;
  113. first = s;
  114. while (*s == '/') ++s;
  115. if (*s) {
  116. last = first;
  117. goto LOOP;
  118. }
  119. if (last == path) {
  120. if (*last != '/') {
  121. goto DOT;
  122. }
  123. if ((*++last == '/') && (last[1] == 0)) {
  124. ++last;
  125. }
  126. }
  127. *last = 0;
  128. return path;
  129. }
  130. DOT:
  131. return (char *) null_or_empty_or_noslash;
  132. }
  133. extern void *xmalloc(size_t size)
  134. {
  135. void *ptr = malloc(size);
  136. if (!ptr) {
  137. fprintf(stderr, "memory exhausted");
  138. exit(EXIT_FAILURE);
  139. }
  140. return ptr;
  141. }
  142. void xstrcat(char **string, ...)
  143. {
  144. const char *c;
  145. va_list p;
  146. /* Don't bother to calculate how big exerything
  147. * will be, just be careful to not overflow... */
  148. va_start(p, string);
  149. *string = xmalloc(BUFSIZ);
  150. **string = '\0';
  151. while(1) {
  152. if (!(c = va_arg(p, const char *)))
  153. break;
  154. strcat(*string, c);
  155. }
  156. va_end(p);
  157. }
  158. int main(int argc, char **argv)
  159. {
  160. int use_build_dir = 0, linking = 1, use_static_linking = 0;
  161. int use_stdinc = 1, use_start = 1, use_stdlib = 1, use_pic = 0;
  162. int source_count = 0, use_rpath = 0, verbose = 0;
  163. int i, j, k, l, m, n;
  164. char ** gcc_argv;
  165. char ** gcc_argument;
  166. char ** libraries;
  167. char ** libpath;
  168. char *dlstr;
  169. char *incstr;
  170. char *devprefix;
  171. char *builddir;
  172. char *libstr;
  173. char *build_dlstr = 0;
  174. char *ep;
  175. char *rpath_link[2];
  176. char *rpath[2];
  177. char *uClibc_inc[2];
  178. char *our_lib_path[2];
  179. char *crt0_path[2];
  180. char *crtbegin_path[2];
  181. char *crtend_path[2];
  182. const char *application_name;
  183. #ifdef __UCLIBC_CTOR_DTOR__
  184. char *crti_path[2];
  185. char *crtn_path[2];
  186. int len;
  187. int ctor_dtor = 1, cplusplus = 0, use_nostdinc_plus = 0;
  188. char *GPLUSPLUS_BIN = NULL;
  189. #endif
  190. #ifdef __UCLIBC_PROFILING__
  191. int profile = 0;
  192. char *gcrt1_path[2];
  193. #endif
  194. application_name = basename(argv[0]);
  195. if (application_name[0] == '-')
  196. application_name++;
  197. #ifdef __UCLIBC_CTOR_DTOR__
  198. /* We must use strstr since g++ might be named like a
  199. * cross compiler (i.e. arm-linux-g++). We must also
  200. * search carefully, in case we are searching something
  201. * like /opt/c++/gcc-3.1/bin/arm-linux-g++ or some similar
  202. * perversion... */
  203. len = strlen(application_name);
  204. if ((strcmp(application_name+len-3, "g++")==0) ||
  205. (strcmp(application_name+len-3, "c++")==0)) {
  206. char *gcc_bin = GCC_BIN;
  207. len = strlen(gcc_bin);
  208. if (strcmp(gcc_bin+len-3, "gcc")==0) {
  209. GPLUSPLUS_BIN = strdup(gcc_bin);
  210. GPLUSPLUS_BIN[len-1]='+';
  211. GPLUSPLUS_BIN[len-2]='+';
  212. }
  213. cplusplus = 1;
  214. use_nostdinc_plus = 1;
  215. }
  216. #endif
  217. devprefix = getenv("UCLIBC_DEVEL_PREFIX");
  218. if (!devprefix) {
  219. devprefix = UCLIBC_DEVEL_PREFIX;
  220. }
  221. builddir = getenv("UCLIBC_BUILD_DIR");
  222. if (!builddir) {
  223. builddir = UCLIBC_BUILD_DIR;
  224. }
  225. incstr = getenv("UCLIBC_GCC_INC");
  226. libstr = getenv("UCLIBC_GCC_LIB");
  227. xstrcat(&(rpath_link[0]), "-Wl,-rpath-link,", devprefix, "/lib", NULL);
  228. xstrcat(&(rpath_link[1]), "-Wl,-rpath-link,", builddir, "/lib", NULL);
  229. xstrcat(&(rpath[0]), "-Wl,-rpath,", devprefix, "/lib", NULL);
  230. xstrcat(&(rpath[1]), "-Wl,-rpath,", builddir, "/lib", NULL);
  231. xstrcat(&(uClibc_inc[0]), devprefix, "/include/", NULL);
  232. xstrcat(&(uClibc_inc[1]), builddir, "/include/", NULL);
  233. #ifdef __UCLIBC_CTOR_DTOR__
  234. xstrcat(&(crt0_path[0]), devprefix, "/lib/crt1.o", NULL);
  235. xstrcat(&(crt0_path[1]), builddir, "/lib/crt1.o", NULL);
  236. xstrcat(&(crti_path[0]), devprefix, "/lib/crti.o", NULL);
  237. xstrcat(&(crti_path[1]), builddir, "/lib/crti.o", NULL);
  238. xstrcat(&(crtn_path[0]), devprefix, "/lib/crtn.o", NULL);
  239. xstrcat(&(crtn_path[1]), builddir, "/lib/crtn.o", NULL);
  240. #else
  241. xstrcat(&(crt0_path[0]), devprefix, "/lib/crt0.o", NULL);
  242. xstrcat(&(crt0_path[1]), builddir, "/lib/crt0.o", NULL);
  243. #endif
  244. #ifdef __UCLIBC_PROFILING__
  245. xstrcat(&(gcrt1_path[0]), devprefix, "/lib/gcrt1.o", NULL);
  246. xstrcat(&(gcrt1_path[1]), builddir, "/lib/gcrt1.o", NULL);
  247. #endif
  248. xstrcat(&(our_lib_path[0]), "-L", devprefix, "/lib", NULL);
  249. xstrcat(&(our_lib_path[1]), "-L", builddir, "/lib", NULL);
  250. #ifdef __UCLIBC_HAS_SHARED__
  251. build_dlstr = "-Wl,--dynamic-linker," BUILD_DYNAMIC_LINKER;
  252. dlstr = getenv("UCLIBC_GCC_DLOPT");
  253. if (!dlstr) {
  254. dlstr = "-Wl,--dynamic-linker," DYNAMIC_LINKER;
  255. }
  256. #endif
  257. ep = getenv("UCLIBC_GCC");
  258. if (!ep) {
  259. ep = "";
  260. }
  261. if (strstr(ep,"build") != 0) {
  262. use_build_dir = 1;
  263. }
  264. if (strstr(ep,"rpath") != 0) {
  265. use_rpath = 1;
  266. }
  267. m = 0;
  268. libraries = __builtin_alloca(sizeof(char*) * (argc));
  269. libraries[m] = '\0';
  270. n = 0;
  271. libpath = __builtin_alloca(sizeof(char*) * (argc));
  272. libpath[n] = '\0';
  273. for ( i = 1 ; i < argc ; i++ ) {
  274. if (argv[i][0] == '-') { /* option */
  275. switch (argv[i][1]) {
  276. case 'c': /* compile or assemble */
  277. case 'S': /* generate assembler code */
  278. case 'E': /* preprocess only */
  279. case 'M': /* generate dependencies */
  280. linking = 0;
  281. break;
  282. case 'L': /* library */
  283. libpath[n++] = argv[i];
  284. libpath[n] = '\0';
  285. if (argv[i][2] == 0) {
  286. argv[i] = '\0';
  287. libpath[n++] = argv[++i];
  288. libpath[n] = '\0';
  289. }
  290. argv[i] = '\0';
  291. break;
  292. case 'l': /* library */
  293. libraries[m++] = argv[i];
  294. libraries[m] = '\0';
  295. argv[i] = '\0';
  296. break;
  297. case 'v': /* verbose */
  298. if (argv[i][2] == 0) verbose = 1;
  299. printf("Invoked as %s\n", argv[0]);
  300. break;
  301. case 'n':
  302. if (strcmp(nostdinc,argv[i]) == 0) {
  303. use_stdinc = 0;
  304. } else if (strcmp(nostartfiles,argv[i]) == 0) {
  305. #ifdef __UCLIBC_CTOR_DTOR__
  306. ctor_dtor = 0;
  307. #endif
  308. use_start = 0;
  309. } else if (strcmp(nodefaultlibs,argv[i]) == 0) {
  310. use_stdlib = 0;
  311. argv[i] = '\0';
  312. } else if (strcmp(nostdlib,argv[i]) == 0) {
  313. #ifdef __UCLIBC_CTOR_DTOR__
  314. ctor_dtor = 0;
  315. #endif
  316. use_start = 0;
  317. use_stdlib = 0;
  318. }
  319. #ifdef __UCLIBC_CTOR_DTOR__
  320. else if (strcmp(nostdinc_plus,argv[i]) == 0) {
  321. if (cplusplus==1) {
  322. use_nostdinc_plus = 0;
  323. }
  324. }
  325. #endif
  326. break;
  327. case 's':
  328. if (strstr(argv[i],static_linking) != NULL) {
  329. use_static_linking = 1;
  330. }
  331. if (strcmp("-shared",argv[i]) == 0) {
  332. use_start = 0;
  333. use_pic = 1;
  334. }
  335. break;
  336. case 'W': /* -static could be passed directly to ld */
  337. if (strncmp("-Wl,",argv[i],4) == 0) {
  338. if (strstr(argv[i],static_linking) != 0) {
  339. use_static_linking = 1;
  340. }
  341. if (strstr(argv[i],"--dynamic-linker") != 0) {
  342. dlstr = 0;
  343. }
  344. }
  345. break;
  346. #ifdef __UCLIBC_PROFILING__
  347. case 'p':
  348. if (strcmp("-pg",argv[i]) == 0) {
  349. profile = 1;
  350. }
  351. break;
  352. #endif
  353. case 'f':
  354. /* Check if we are doing PIC */
  355. if (strcmp("-fPIC",argv[i]) == 0) {
  356. use_pic = 1;
  357. } else if (strcmp("-fpic",argv[i]) == 0) {
  358. use_pic = 1;
  359. }
  360. #ifdef __UCLIBC_PROFILING__
  361. else if (strcmp("-fprofile-arcs",argv[i]) == 0) {
  362. profile = 1;
  363. }
  364. #endif
  365. break;
  366. case '-':
  367. if (strstr(argv[i]+1,static_linking) != NULL) {
  368. use_static_linking = 1;
  369. argv[i]='\0';
  370. } else if (strcmp("--uclibc-use-build-dir",argv[i]) == 0) {
  371. use_build_dir = 1;
  372. argv[i]='\0';
  373. } else if (strcmp("--uclibc-use-rpath",argv[i]) == 0) {
  374. use_rpath = 1;
  375. argv[i]='\0';
  376. }
  377. #ifdef __UCLIBC_CTOR_DTOR__
  378. else if (strcmp("--uclibc-no-ctors",argv[i]) == 0) {
  379. ctor_dtor = 0;
  380. argv[i]='\0';
  381. }
  382. #endif
  383. break;
  384. }
  385. } else { /* assume it is an existing source file */
  386. ++source_count;
  387. }
  388. }
  389. gcc_argv = __builtin_alloca(sizeof(char*) * (argc + 64));
  390. gcc_argument = __builtin_alloca(sizeof(char*) * (argc + 20));
  391. i = 0; k = 0;
  392. #ifdef __UCLIBC_CTOR_DTOR__
  393. if (ctor_dtor) {
  394. struct stat statbuf;
  395. if (stat(LIBGCC_DIR, &statbuf)!=0 ||
  396. !S_ISDIR(statbuf.st_mode))
  397. {
  398. /* Bummer, gcc has moved things on us... */
  399. int status, gcc_pipe[2];
  400. pid_t pid, wpid;
  401. pipe(gcc_pipe);
  402. if (!(pid = fork())) {
  403. char *argv[4];
  404. close(gcc_pipe[0]);
  405. close(1);
  406. close(2);
  407. dup2(gcc_pipe[1], 1);
  408. dup2(gcc_pipe[1], 2);
  409. argv[0] = GCC_BIN;
  410. argv[2] = "-print-libgcc-file-name";
  411. argv[3] = NULL;
  412. execvp(argv[0], argv);
  413. close(gcc_pipe[1]);
  414. _exit(-1);
  415. }
  416. wpid=0;
  417. while (wpid != pid) {
  418. wpid = wait(&status);
  419. }
  420. close(gcc_pipe[1]);
  421. if (WIFEXITED(status)) {
  422. char buf[1024], *dir;
  423. status = read(gcc_pipe[0], buf, sizeof(buf));
  424. if (status < 0) {
  425. goto crash_n_burn;
  426. }
  427. dir = dirname(buf);
  428. xstrcat(&(crtbegin_path[0]), dir, "crtbegin.o", NULL);
  429. xstrcat(&(crtbegin_path[1]), dir, "crtbeginS.o", NULL);
  430. xstrcat(&(crtend_path[0]), dir, "crtend.o", NULL);
  431. xstrcat(&(crtend_path[1]), dir, "crtendS.o", NULL);
  432. } else {
  433. crash_n_burn:
  434. fprintf(stderr, "Unable to locale crtbegin.o provided by gcc");
  435. exit(EXIT_FAILURE);
  436. }
  437. close(gcc_pipe[0]);
  438. } else {
  439. xstrcat(&(crtbegin_path[0]), LIBGCC_DIR, "crtbegin.o", NULL);
  440. xstrcat(&(crtbegin_path[1]), LIBGCC_DIR, "crtbeginS.o", NULL);
  441. xstrcat(&(crtend_path[0]), LIBGCC_DIR, "crtend.o", NULL);
  442. xstrcat(&(crtend_path[1]), LIBGCC_DIR, "crtendS.o", NULL);
  443. }
  444. }
  445. if (cplusplus && GPLUSPLUS_BIN)
  446. gcc_argv[i++] = GPLUSPLUS_BIN;
  447. else
  448. #endif
  449. gcc_argv[i++] = GCC_BIN;
  450. for ( j = 1 ; j < argc ; j++ ) {
  451. if (argv[j]=='\0') {
  452. continue;
  453. } else {
  454. gcc_argument[k++] = argv[j];
  455. gcc_argument[k] = '\0';
  456. }
  457. }
  458. if (linking && source_count) {
  459. #if defined __HAVE_ELF__ && ! defined __UCLIBC_HAS_MMU__
  460. gcc_argv[i++] = "-Wl,-elf2flt";
  461. #endif
  462. gcc_argv[i++] = nostdlib;
  463. if (use_static_linking) {
  464. gcc_argv[i++] = static_linking;
  465. }
  466. if (!use_static_linking) {
  467. if (dlstr && use_build_dir) {
  468. gcc_argv[i++] = build_dlstr;
  469. } else if (dlstr) {
  470. gcc_argv[i++] = dlstr;
  471. }
  472. if (use_rpath) {
  473. gcc_argv[i++] = rpath[use_build_dir];
  474. }
  475. }
  476. for ( l = 0 ; l < n ; l++ ) {
  477. if (libpath[l]) gcc_argv[i++] = libpath[l];
  478. }
  479. gcc_argv[i++] = rpath_link[use_build_dir]; /* just to be safe */
  480. if( libstr )
  481. gcc_argv[i++] = libstr;
  482. gcc_argv[i++] = our_lib_path[use_build_dir];
  483. if (!use_build_dir) {
  484. gcc_argv[i++] = our_usr_lib_path;
  485. }
  486. }
  487. if (use_stdinc && source_count) {
  488. gcc_argv[i++] = nostdinc;
  489. #ifdef __UCLIBC_CTOR_DTOR__
  490. if (cplusplus) {
  491. char *cppinc;
  492. if (use_nostdinc_plus) {
  493. gcc_argv[i++] = nostdinc_plus;
  494. }
  495. xstrcat(&cppinc, uClibc_inc[use_build_dir], "g++/", NULL);
  496. gcc_argv[i++] = "-isystem";
  497. gcc_argv[i++] = cppinc;
  498. xstrcat(&cppinc, uClibc_inc[use_build_dir], "g++-v3/", NULL);
  499. gcc_argv[i++] = "-isystem";
  500. gcc_argv[i++] = cppinc;
  501. }
  502. #endif
  503. gcc_argv[i++] = "-isystem";
  504. gcc_argv[i++] = uClibc_inc[use_build_dir];
  505. gcc_argv[i++] = "-iwithprefix";
  506. gcc_argv[i++] = "include";
  507. if( incstr )
  508. gcc_argv[i++] = incstr;
  509. }
  510. if (linking && source_count) {
  511. #ifdef __UCLIBC_PROFILING__
  512. if (profile) {
  513. gcc_argv[i++] = gcrt1_path[use_build_dir];
  514. }
  515. #endif
  516. #ifdef __UCLIBC_CTOR_DTOR__
  517. if (ctor_dtor) {
  518. gcc_argv[i++] = crti_path[use_build_dir];
  519. if (use_pic) {
  520. gcc_argv[i++] = crtbegin_path[1];
  521. } else {
  522. gcc_argv[i++] = crtbegin_path[0];
  523. }
  524. }
  525. #endif
  526. if (use_start) {
  527. #ifdef __UCLIBC_PROFILING__
  528. if (!profile)
  529. #endif
  530. {
  531. gcc_argv[i++] = crt0_path[use_build_dir];
  532. }
  533. }
  534. for ( l = 0 ; l < k ; l++ ) {
  535. if (gcc_argument[l]) gcc_argv[i++] = gcc_argument[l];
  536. }
  537. if (use_stdlib) {
  538. //gcc_argv[i++] = "-Wl,--start-group";
  539. gcc_argv[i++] = "-lgcc";
  540. }
  541. for ( l = 0 ; l < m ; l++ ) {
  542. if (libraries[l]) gcc_argv[i++] = libraries[l];
  543. }
  544. if (use_stdlib) {
  545. #ifdef __UCLIBC_CTOR_DTOR__
  546. if (cplusplus) {
  547. gcc_argv[ i++ ] = "-lstdc++";
  548. gcc_argv[ i++ ] = "-lm";
  549. }
  550. #endif
  551. gcc_argv[i++] = "-lc";
  552. gcc_argv[i++] = "-lgcc";
  553. //gcc_argv[i++] = "-Wl,--end-group";
  554. }
  555. #ifdef __UCLIBC_CTOR_DTOR__
  556. if (ctor_dtor) {
  557. if (use_pic) {
  558. gcc_argv[i++] = crtend_path[1];
  559. } else {
  560. gcc_argv[i++] = crtend_path[0];
  561. }
  562. gcc_argv[i++] = crtn_path[use_build_dir];
  563. }
  564. #endif
  565. } else {
  566. for ( l = 0 ; l < k ; l++ ) {
  567. if (gcc_argument[l]) gcc_argv[i++] = gcc_argument[l];
  568. }
  569. }
  570. gcc_argv[i++] = NULL;
  571. if (verbose) {
  572. for ( j = 0 ; gcc_argv[j] ; j++ ) {
  573. printf("arg[%2i] = %s\n", j, gcc_argv[j]);
  574. }
  575. fflush(stdout);
  576. }
  577. //no need to free memory from xstrcat because we never return...
  578. #ifdef __UCLIBC_CTOR_DTOR__
  579. if (cplusplus && GPLUSPLUS_BIN)
  580. return execvp(GPLUSPLUS_BIN, gcc_argv);
  581. else
  582. #endif
  583. return execvp(GCC_BIN, gcc_argv);
  584. }