tcc: add -m32 option to x86_64 cross compilers
This commit is contained in:
parent
33f86ada92
commit
bb7bb37fe2
2 changed files with 35 additions and 1 deletions
35
tcc.c
35
tcc.c
|
@ -212,6 +212,36 @@ static int expand_args(char ***pargv, const char *str)
|
||||||
return argc;
|
return argc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void exec_other_tcc(TCCState *s, int argc,char **argv,int optarg)
|
||||||
|
{
|
||||||
|
#ifdef TCC_TARGET_X86_64
|
||||||
|
#define WIN32_CAST
|
||||||
|
char arg[20]="i386-tcc";
|
||||||
|
char sep='/',*tcc;
|
||||||
|
if (32 == optarg) {/* -m32 launches 32 bit tcc */
|
||||||
|
#ifdef TCC_TARGET_PE
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define WIN32_CAST (const char**)(const char *)
|
||||||
|
strcpy(arg,"tcc.exe");
|
||||||
|
sep='\\';
|
||||||
|
#else
|
||||||
|
strcpy(arg,"i386-win32-tcc");
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
if (!(tcc=strrchr(argv[0],sep)))
|
||||||
|
tcc=argv[0];
|
||||||
|
else tcc++;
|
||||||
|
if (0<s->verbose) printf("%s->%s\n",tcc,arg);
|
||||||
|
if (strcmp(tcc,arg)) {
|
||||||
|
execvp(arg, WIN32_CAST (argv));
|
||||||
|
error("cross compiler not found!");
|
||||||
|
exit(1);
|
||||||
|
#undef WIN32_CAST
|
||||||
|
} else warning("-m32 infinite loop prevented");
|
||||||
|
} else warning("usupported option \"-m%s\"",optarg);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static int parse_args(TCCState *s, int argc, char **argv)
|
static int parse_args(TCCState *s, int argc, char **argv)
|
||||||
{
|
{
|
||||||
int optind;
|
int optind;
|
||||||
|
@ -334,7 +364,10 @@ static int parse_args(TCCState *s, int argc, char **argv)
|
||||||
output_type = TCC_OUTPUT_DLL;
|
output_type = TCC_OUTPUT_DLL;
|
||||||
break;
|
break;
|
||||||
case TCC_OPTION_soname:
|
case TCC_OPTION_soname:
|
||||||
s->soname = optarg;
|
s->soname = optarg;
|
||||||
|
break;
|
||||||
|
case TCC_OPTION_m:
|
||||||
|
exec_other_tcc(s,argc+1,argv-1,atoi(optarg));
|
||||||
break;
|
break;
|
||||||
case TCC_OPTION_o:
|
case TCC_OPTION_o:
|
||||||
multiple_files = 1;
|
multiple_files = 1;
|
||||||
|
|
1
tcc.h
1
tcc.h
|
@ -44,6 +44,7 @@
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <process.h>
|
||||||
#include <sys/timeb.h>
|
#include <sys/timeb.h>
|
||||||
#include <io.h> /* open, close etc. */
|
#include <io.h> /* open, close etc. */
|
||||||
#include <direct.h> /* getcwd */
|
#include <direct.h> /* getcwd */
|
||||||
|
|
Loading…
Reference in a new issue