gcc-uClibc.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  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_ENV.
  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_ENV 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_ENV="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 *cc;
  175. char *ep;
  176. char *rpath_link[2];
  177. char *rpath[2];
  178. char *uClibc_inc[2];
  179. char *our_lib_path[2];
  180. char *crt0_path[2];
  181. char *crtbegin_path[2];
  182. char *crtend_path[2];
  183. const char *application_name;
  184. #ifdef __UCLIBC_CTOR_DTOR__
  185. char *crti_path[2];
  186. char *crtn_path[2];
  187. int len;
  188. int ctor_dtor = 1, cplusplus = 0, use_nostdinc_plus = 0;
  189. char *GPLUSPLUS_BIN = NULL;
  190. #endif
  191. #ifdef __UCLIBC_PROFILING__
  192. int profile = 0;
  193. char *gcrt1_path[2];
  194. #endif
  195. cc = getenv("UCLIBC_CC");
  196. if (!cc) {
  197. cc = GCC_BIN;
  198. }
  199. application_name = basename(argv[0]);
  200. if (application_name[0] == '-')
  201. application_name++;
  202. #ifdef __UCLIBC_CTOR_DTOR__
  203. /* We must use strstr since g++ might be named like a
  204. * cross compiler (i.e. arm-linux-g++). We must also
  205. * search carefully, in case we are searching something
  206. * like /opt/c++/gcc-3.1/bin/arm-linux-g++ or some similar
  207. * perversion... */
  208. len = strlen(application_name);
  209. if ((strcmp(application_name+len-3, "g++")==0) ||
  210. (strcmp(application_name+len-3, "c++")==0)) {
  211. len = strlen(cc);
  212. if (strcmp(cc+len-3, "gcc")==0) {
  213. GPLUSPLUS_BIN = strdup(cc);
  214. GPLUSPLUS_BIN[len-1]='+';
  215. GPLUSPLUS_BIN[len-2]='+';
  216. }
  217. cplusplus = 1;
  218. use_nostdinc_plus = 1;
  219. }
  220. #endif
  221. devprefix = getenv("UCLIBC_DEVEL_PREFIX");
  222. if (!devprefix) {
  223. devprefix = UCLIBC_DEVEL_PREFIX;
  224. }
  225. builddir = getenv("UCLIBC_BUILD_DIR");
  226. if (!builddir) {
  227. builddir = UCLIBC_BUILD_DIR;
  228. }
  229. incstr = getenv("UCLIBC_GCC_INC");
  230. libstr = getenv("UCLIBC_GCC_LIB");
  231. ep = getenv("UCLIBC_ENV");
  232. if (!ep) {
  233. ep = "";
  234. }
  235. if (strstr(ep,"build") != 0) {
  236. use_build_dir = 1;
  237. }
  238. if (strstr(ep,"rpath") != 0) {
  239. use_rpath = 1;
  240. }
  241. xstrcat(&(rpath_link[0]), "-Wl,-rpath-link,", devprefix, "/lib", NULL);
  242. xstrcat(&(rpath_link[1]), "-Wl,-rpath-link,", builddir, "/lib", NULL);
  243. xstrcat(&(rpath[0]), "-Wl,-rpath,", devprefix, "/lib", NULL);
  244. xstrcat(&(rpath[1]), "-Wl,-rpath,", builddir, "/lib", NULL);
  245. xstrcat(&(uClibc_inc[0]), devprefix, "/include/", NULL);
  246. xstrcat(&(uClibc_inc[1]), builddir, "/include/", NULL);
  247. #ifdef __UCLIBC_CTOR_DTOR__
  248. xstrcat(&(crt0_path[0]), devprefix, "/lib/crt1.o", NULL);
  249. xstrcat(&(crt0_path[1]), builddir, "/lib/crt1.o", NULL);
  250. xstrcat(&(crti_path[0]), devprefix, "/lib/crti.o", NULL);
  251. xstrcat(&(crti_path[1]), builddir, "/lib/crti.o", NULL);
  252. xstrcat(&(crtn_path[0]), devprefix, "/lib/crtn.o", NULL);
  253. xstrcat(&(crtn_path[1]), builddir, "/lib/crtn.o", NULL);
  254. #else
  255. xstrcat(&(crt0_path[0]), devprefix, "/lib/crt0.o", NULL);
  256. xstrcat(&(crt0_path[1]), builddir, "/lib/crt0.o", NULL);
  257. #endif
  258. #ifdef __UCLIBC_PROFILING__
  259. xstrcat(&(gcrt1_path[0]), devprefix, "/lib/gcrt1.o", NULL);
  260. xstrcat(&(gcrt1_path[1]), builddir, "/lib/gcrt1.o", NULL);
  261. #endif
  262. xstrcat(&(our_lib_path[0]), "-L", devprefix, "/lib", NULL);
  263. xstrcat(&(our_lib_path[1]), "-L", builddir, "/lib", NULL);
  264. #ifdef __UCLIBC_HAS_SHARED__
  265. build_dlstr = "-Wl,--dynamic-linker," BUILD_DYNAMIC_LINKER;
  266. dlstr = getenv("UCLIBC_GCC_DLOPT");
  267. if (!dlstr) {
  268. dlstr = "-Wl,--dynamic-linker," DYNAMIC_LINKER;
  269. }
  270. #endif
  271. m = 0;
  272. libraries = __builtin_alloca(sizeof(char*) * (argc));
  273. libraries[m] = '\0';
  274. n = 0;
  275. libpath = __builtin_alloca(sizeof(char*) * (argc));
  276. libpath[n] = '\0';
  277. for ( i = 1 ; i < argc ; i++ ) {
  278. if (argv[i][0] == '-') { /* option */
  279. switch (argv[i][1]) {
  280. case 'c': /* compile or assemble */
  281. case 'S': /* generate assembler code */
  282. case 'E': /* preprocess only */
  283. case 'M': /* generate dependencies */
  284. linking = 0;
  285. break;
  286. case 'L': /* library */
  287. libpath[n++] = argv[i];
  288. libpath[n] = '\0';
  289. if (argv[i][2] == 0) {
  290. argv[i] = '\0';
  291. libpath[n++] = argv[++i];
  292. libpath[n] = '\0';
  293. }
  294. argv[i] = '\0';
  295. break;
  296. case 'l': /* library */
  297. libraries[m++] = argv[i];
  298. libraries[m] = '\0';
  299. argv[i] = '\0';
  300. break;
  301. case 'v': /* verbose */
  302. if (argv[i][2] == 0) verbose = 1;
  303. printf("Invoked as %s\n", argv[0]);
  304. break;
  305. case 'n':
  306. if (strcmp(nostdinc,argv[i]) == 0) {
  307. use_stdinc = 0;
  308. } else if (strcmp(nostartfiles,argv[i]) == 0) {
  309. #ifdef __UCLIBC_CTOR_DTOR__
  310. ctor_dtor = 0;
  311. #endif
  312. use_start = 0;
  313. } else if (strcmp(nodefaultlibs,argv[i]) == 0) {
  314. use_stdlib = 0;
  315. argv[i] = '\0';
  316. } else if (strcmp(nostdlib,argv[i]) == 0) {
  317. #ifdef __UCLIBC_CTOR_DTOR__
  318. ctor_dtor = 0;
  319. #endif
  320. use_start = 0;
  321. use_stdlib = 0;
  322. }
  323. #ifdef __UCLIBC_CTOR_DTOR__
  324. else if (strcmp(nostdinc_plus,argv[i]) == 0) {
  325. if (cplusplus==1) {
  326. use_nostdinc_plus = 0;
  327. }
  328. }
  329. #endif
  330. break;
  331. case 's':
  332. if (strstr(argv[i],static_linking) != NULL) {
  333. use_static_linking = 1;
  334. }
  335. if (strcmp("-shared",argv[i]) == 0) {
  336. use_start = 0;
  337. use_pic = 1;
  338. }
  339. break;
  340. case 'W': /* -static could be passed directly to ld */
  341. if (strncmp("-Wl,",argv[i],4) == 0) {
  342. if (strstr(argv[i],static_linking) != 0) {
  343. use_static_linking = 1;
  344. }
  345. if (strstr(argv[i],"--dynamic-linker") != 0) {
  346. dlstr = 0;
  347. }
  348. }
  349. break;
  350. #ifdef __UCLIBC_PROFILING__
  351. case 'p':
  352. if (strcmp("-pg",argv[i]) == 0) {
  353. profile = 1;
  354. }
  355. break;
  356. #endif
  357. case 'f':
  358. /* Check if we are doing PIC */
  359. if (strcmp("-fPIC",argv[i]) == 0) {
  360. use_pic = 1;
  361. } else if (strcmp("-fpic",argv[i]) == 0) {
  362. use_pic = 1;
  363. }
  364. #ifdef __UCLIBC_PROFILING__
  365. else if (strcmp("-fprofile-arcs",argv[i]) == 0) {
  366. profile = 1;
  367. }
  368. #endif
  369. break;
  370. case '-':
  371. if (strstr(argv[i]+1,static_linking) != NULL) {
  372. use_static_linking = 1;
  373. argv[i]='\0';
  374. } else if (strcmp("--uclibc-use-build-dir",argv[i]) == 0) {
  375. use_build_dir = 1;
  376. argv[i]='\0';
  377. } else if (strcmp("--uclibc-use-rpath",argv[i]) == 0) {
  378. use_rpath = 1;
  379. argv[i]='\0';
  380. }
  381. #ifdef __UCLIBC_CTOR_DTOR__
  382. else if (strcmp("--uclibc-no-ctors",argv[i]) == 0) {
  383. ctor_dtor = 0;
  384. argv[i]='\0';
  385. }
  386. #endif
  387. break;
  388. }
  389. } else { /* assume it is an existing source file */
  390. ++source_count;
  391. }
  392. }
  393. gcc_argv = __builtin_alloca(sizeof(char*) * (argc + 64));
  394. gcc_argument = __builtin_alloca(sizeof(char*) * (argc + 20));
  395. i = 0; k = 0;
  396. #ifdef __UCLIBC_CTOR_DTOR__
  397. if (ctor_dtor) {
  398. struct stat statbuf;
  399. if (stat(LIBGCC_DIR, &statbuf)!=0 ||
  400. !S_ISDIR(statbuf.st_mode))
  401. {
  402. /* Bummer, gcc has moved things on us... */
  403. int status, gcc_pipe[2];
  404. pid_t pid, wpid;
  405. pipe(gcc_pipe);
  406. if (!(pid = fork())) {
  407. char *argv[4];
  408. close(gcc_pipe[0]);
  409. close(1);
  410. close(2);
  411. dup2(gcc_pipe[1], 1);
  412. dup2(gcc_pipe[1], 2);
  413. argv[0] = cc;
  414. argv[2] = "-print-libgcc-file-name";
  415. argv[3] = NULL;
  416. execvp(argv[0], argv);
  417. close(gcc_pipe[1]);
  418. _exit(-1);
  419. }
  420. wpid=0;
  421. while (wpid != pid) {
  422. wpid = wait(&status);
  423. }
  424. close(gcc_pipe[1]);
  425. if (WIFEXITED(status)) {
  426. char buf[1024], *dir;
  427. status = read(gcc_pipe[0], buf, sizeof(buf));
  428. if (status < 0) {
  429. goto crash_n_burn;
  430. }
  431. dir = dirname(buf);
  432. xstrcat(&(crtbegin_path[0]), dir, "crtbegin.o", NULL);
  433. xstrcat(&(crtbegin_path[1]), dir, "crtbeginS.o", NULL);
  434. xstrcat(&(crtend_path[0]), dir, "crtend.o", NULL);
  435. xstrcat(&(crtend_path[1]), dir, "crtendS.o", NULL);
  436. } else {
  437. crash_n_burn:
  438. fprintf(stderr, "Unable to locale crtbegin.o provided by gcc");
  439. exit(EXIT_FAILURE);
  440. }
  441. close(gcc_pipe[0]);
  442. } else {
  443. xstrcat(&(crtbegin_path[0]), LIBGCC_DIR, "crtbegin.o", NULL);
  444. xstrcat(&(crtbegin_path[1]), LIBGCC_DIR, "crtbeginS.o", NULL);
  445. xstrcat(&(crtend_path[0]), LIBGCC_DIR, "crtend.o", NULL);
  446. xstrcat(&(crtend_path[1]), LIBGCC_DIR, "crtendS.o", NULL);
  447. }
  448. }
  449. if (cplusplus && GPLUSPLUS_BIN)
  450. gcc_argv[i++] = GPLUSPLUS_BIN;
  451. else
  452. #endif
  453. gcc_argv[i++] = cc;
  454. for ( j = 1 ; j < argc ; j++ ) {
  455. if (argv[j]=='\0') {
  456. continue;
  457. } else {
  458. gcc_argument[k++] = argv[j];
  459. gcc_argument[k] = '\0';
  460. }
  461. }
  462. if (linking && source_count) {
  463. #if defined __HAVE_ELF__ && ! defined __UCLIBC_HAS_MMU__
  464. gcc_argv[i++] = "-Wl,-elf2flt";
  465. #endif
  466. gcc_argv[i++] = nostdlib;
  467. if (use_static_linking) {
  468. gcc_argv[i++] = static_linking;
  469. }
  470. if (!use_static_linking) {
  471. if (dlstr && use_build_dir) {
  472. gcc_argv[i++] = build_dlstr;
  473. } else if (dlstr) {
  474. gcc_argv[i++] = dlstr;
  475. }
  476. if (use_rpath) {
  477. gcc_argv[i++] = rpath[use_build_dir];
  478. }
  479. }
  480. for ( l = 0 ; l < n ; l++ ) {
  481. if (libpath[l]) gcc_argv[i++] = libpath[l];
  482. }
  483. gcc_argv[i++] = rpath_link[use_build_dir]; /* just to be safe */
  484. if( libstr )
  485. gcc_argv[i++] = libstr;
  486. gcc_argv[i++] = our_lib_path[use_build_dir];
  487. if (!use_build_dir) {
  488. gcc_argv[i++] = our_usr_lib_path;
  489. }
  490. }
  491. if (use_stdinc && source_count) {
  492. gcc_argv[i++] = nostdinc;
  493. #ifdef __UCLIBC_CTOR_DTOR__
  494. if (cplusplus) {
  495. char *cppinc;
  496. if (use_nostdinc_plus) {
  497. gcc_argv[i++] = nostdinc_plus;
  498. }
  499. xstrcat(&cppinc, uClibc_inc[use_build_dir], "g++/", NULL);
  500. gcc_argv[i++] = "-isystem";
  501. gcc_argv[i++] = cppinc;
  502. xstrcat(&cppinc, uClibc_inc[use_build_dir], "g++-v3/", NULL);
  503. gcc_argv[i++] = "-isystem";
  504. gcc_argv[i++] = cppinc;
  505. }
  506. #endif
  507. gcc_argv[i++] = "-isystem";
  508. gcc_argv[i++] = uClibc_inc[use_build_dir];
  509. gcc_argv[i++] = "-iwithprefix";
  510. gcc_argv[i++] = "include";
  511. if( incstr )
  512. gcc_argv[i++] = incstr;
  513. }
  514. if (linking && source_count) {
  515. #ifdef __UCLIBC_PROFILING__
  516. if (profile) {
  517. gcc_argv[i++] = gcrt1_path[use_build_dir];
  518. }
  519. #endif
  520. #ifdef __UCLIBC_CTOR_DTOR__
  521. if (ctor_dtor) {
  522. gcc_argv[i++] = crti_path[use_build_dir];
  523. if (use_pic) {
  524. gcc_argv[i++] = crtbegin_path[1];
  525. } else {
  526. gcc_argv[i++] = crtbegin_path[0];
  527. }
  528. }
  529. #endif
  530. if (use_start) {
  531. #ifdef __UCLIBC_PROFILING__
  532. if (!profile)
  533. #endif
  534. {
  535. gcc_argv[i++] = crt0_path[use_build_dir];
  536. }
  537. }
  538. for ( l = 0 ; l < k ; l++ ) {
  539. if (gcc_argument[l]) gcc_argv[i++] = gcc_argument[l];
  540. }
  541. if (use_stdlib) {
  542. //gcc_argv[i++] = "-Wl,--start-group";
  543. gcc_argv[i++] = "-lgcc";
  544. }
  545. for ( l = 0 ; l < m ; l++ ) {
  546. if (libraries[l]) gcc_argv[i++] = libraries[l];
  547. }
  548. if (use_stdlib) {
  549. #ifdef __UCLIBC_CTOR_DTOR__
  550. if (cplusplus) {
  551. gcc_argv[ i++ ] = "-lstdc++";
  552. gcc_argv[ i++ ] = "-lm";
  553. }
  554. #endif
  555. gcc_argv[i++] = "-lc";
  556. gcc_argv[i++] = "-lgcc";
  557. //gcc_argv[i++] = "-Wl,--end-group";
  558. }
  559. #ifdef __UCLIBC_CTOR_DTOR__
  560. if (ctor_dtor) {
  561. if (use_pic) {
  562. gcc_argv[i++] = crtend_path[1];
  563. } else {
  564. gcc_argv[i++] = crtend_path[0];
  565. }
  566. gcc_argv[i++] = crtn_path[use_build_dir];
  567. }
  568. #endif
  569. } else {
  570. for ( l = 0 ; l < k ; l++ ) {
  571. if (gcc_argument[l]) gcc_argv[i++] = gcc_argument[l];
  572. }
  573. }
  574. gcc_argv[i++] = NULL;
  575. if (verbose) {
  576. for ( j = 0 ; gcc_argv[j] ; j++ ) {
  577. printf("arg[%2i] = %s\n", j, gcc_argv[j]);
  578. }
  579. fflush(stdout);
  580. }
  581. //no need to free memory from xstrcat because we never return...
  582. #ifdef __UCLIBC_CTOR_DTOR__
  583. if (cplusplus && GPLUSPLUS_BIN)
  584. return execvp(GPLUSPLUS_BIN, gcc_argv);
  585. else
  586. #endif
  587. return execvp(cc, gcc_argv);
  588. }