History

tcc: add -m32 option to x86_64 cross compilers

Henry Kroll III committed 15 years ago

Commit bb7bb371 parent 33f86ad2 files · +35 −1Browse files

Unified · Split

2 files
  1. tcc.c +34 −1
  2. tcc.h +1 −0
tcc.c+34−1
@@ -212,6 +212,36 @@ static int expand_args(char ***pargv, const char *str) · 211 unmodified lines
212 return argc;212 return argc;
213}213}
214 214
215void exec_other_tcc(TCCState *s, int argc,char **argv,int optarg)
216{
217#ifdef TCC_TARGET_X86_64
218#define WIN32_CAST
219 char arg[20]="i386-tcc";
220 char sep='/',*tcc;
221 if (32 == optarg) {/* -m32 launches 32 bit tcc */
222#ifdef TCC_TARGET_PE
223#ifdef _WIN32
224#define WIN32_CAST (const char**)(const char *)
225 strcpy(arg,"tcc.exe");
226 sep='\\';
227#else
228 strcpy(arg,"i386-win32-tcc");
229#endif
230#endif
231 if (!(tcc=strrchr(argv[0],sep)))
232 tcc=argv[0];
233 else tcc++;
234 if (0<s->verbose) printf("%s->%s\n",tcc,arg);
235 if (strcmp(tcc,arg)) {
236 execvp(arg, WIN32_CAST (argv));
237 error("cross compiler not found!");
238 exit(1);
239#undef WIN32_CAST
240 } else warning("-m32 infinite loop prevented");
241 } else warning("usupported option \"-m%s\"",optarg);
242#endif
243}
244
215static int parse_args(TCCState *s, int argc, char **argv)245static int parse_args(TCCState *s, int argc, char **argv)
216{246{
217 int optind;247 int optind;
@@ -334,7 +364,10 @@ static int parse_args(TCCState *s, int argc, char **argv) · 116 unmodified lines
334 output_type = TCC_OUTPUT_DLL;364 output_type = TCC_OUTPUT_DLL;
335 break;365 break;
336 case TCC_OPTION_soname:366 case TCC_OPTION_soname:
337 s->soname = optarg; 367 s->soname = optarg;
368 break;
369 case TCC_OPTION_m:
370 exec_other_tcc(s,argc+1,argv-1,atoi(optarg));
338 break;371 break;
339 case TCC_OPTION_o:372 case TCC_OPTION_o:
340 multiple_files = 1;373 multiple_files = 1;
tcc.h+1−0
@@ -44,6 +44,7 @@ · 43 unmodified lines
44 44
45#ifdef _WIN3245#ifdef _WIN32
46#include <windows.h>46#include <windows.h>
47#include <process.h>
47#include <sys/timeb.h>48#include <sys/timeb.h>
48#include <io.h> /* open, close etc. */49#include <io.h> /* open, close etc. */
49#include <direct.h> /* getcwd */50#include <direct.h> /* getcwd */