gcc-uClibc.c 16 KB

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