mirror of
https://github.com/frida/tinycc
synced 2024-11-24 08:39:37 +03:00
tcc.c: fix an error when you build an object file with '-pthread' key set
The problem was partially fixed by Henry in the following patch: tcc.c: skip -lpthread when -c option specified But that patch had one brawback: it is sensitive to argument order, as decision is taken during commandline parsing: $ tcc -c a.c -o a.o -pthread # 1. works fine tcc: error: file 'a.c' not found $ tcc -pthread -c a.c -o a.o # 2. blows tcc: error: cannot specify libraries with -c This patch fixes case 2. Signed-off-by: Sergei Trofimovich <st@anti-virus.by>
This commit is contained in:
parent
d97a25fbdd
commit
0a50e6c933
16
tcc.c
16
tcc.c
@ -294,6 +294,9 @@ static int parse_args(TCCState *s, int argc, char **argv)
|
||||
const TCCOption *popt;
|
||||
const char *optarg, *p1, *r1;
|
||||
char *r;
|
||||
int was_pthread;
|
||||
|
||||
was_pthread = 0; /* is set if commandline contains -pthread key */
|
||||
|
||||
optind = 0;
|
||||
while (optind < argc) {
|
||||
@ -375,11 +378,7 @@ static int parse_args(TCCState *s, int argc, char **argv)
|
||||
nb_libraries++;
|
||||
break;
|
||||
case TCC_OPTION_pthread:
|
||||
/* fixme: these options could be different on your platform */
|
||||
if(output_type != TCC_OUTPUT_OBJ){
|
||||
dynarray_add((void ***)&files, &nb_files, "-lpthread");
|
||||
nb_libraries++;
|
||||
}
|
||||
was_pthread = 1;
|
||||
tcc_define_symbol(s, "_REENTRANT", "1");
|
||||
break;
|
||||
case TCC_OPTION_bench:
|
||||
@ -494,6 +493,13 @@ static int parse_args(TCCState *s, int argc, char **argv)
|
||||
}
|
||||
}
|
||||
}
|
||||
/* fixme: these options could be different on your platform */
|
||||
if (was_pthread
|
||||
&& output_type != TCC_OUTPUT_OBJ)
|
||||
{
|
||||
dynarray_add((void ***)&files, &nb_files, "-lpthread");
|
||||
nb_libraries++;
|
||||
}
|
||||
return optind + 1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user