diff options
| author | Sergei Trofimovich <st@anti-virus.by> | 2011-01-04 11:17:52 +0200 |
|---|---|---|
| committer | Sergei Trofimovich <st@anti-virus.by> | 2011-01-04 11:17:52 +0200 |
| commit | 0a50e6c933cb3d470494c203e90808cef6873b06 (patch) | |
| tree | 8b8f7a193219a5e6f30ea9f927f6db0fe2b163de /tcc.c | |
| parent | d97a25fbdd80ad005be41e9d47d6aefe2a5f6cae (diff) | |
| download | tinycc-0a50e6c933cb3d470494c203e90808cef6873b06.tar.gz tinycc-0a50e6c933cb3d470494c203e90808cef6873b06.tar.bz2 | |
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>
Diffstat (limited to 'tcc.c')
| -rw-r--r-- | tcc.c | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -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; } |
