From 3f8225509b0b8af534ba0856b2aeb01a3310d826 Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Sat, 23 Dec 2017 14:14:57 +0100 Subject: [PATCH] Fix -pthread option handling adding -pthread confused option parsing as the number of file counting came out wrong. Simplify and fit it, can be handled purely within option parsing, no need for a state flag. --- libtcc.c | 5 +++-- tcc.c | 3 --- tcc.h | 1 - 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/libtcc.c b/libtcc.c index 1e9dd971..9bc6597d 100644 --- a/libtcc.c +++ b/libtcc.c @@ -1742,13 +1742,14 @@ reparse: tcc_set_lib_path(s, optarg); break; case TCC_OPTION_l: +add_lib: args_parser_add_file(s, optarg, AFF_TYPE_LIB); s->nb_libraries++; break; case TCC_OPTION_pthread: parse_option_D(s, "_REENTRANT"); - s->option_pthread = 1; - break; + optarg = "pthread"; + goto add_lib; case TCC_OPTION_bench: s->do_bench = 1; break; diff --git a/tcc.c b/tcc.c index cd887d17..4cc0657d 100644 --- a/tcc.c +++ b/tcc.c @@ -297,9 +297,6 @@ redo: tcc_error("cannot specify libraries with -c"); if (n > 1 && s->outfile) tcc_error("cannot specify output file with -c many files"); - } else { - if (s->option_pthread) - tcc_set_options(s, "-lpthread"); } if (s->do_bench) diff --git a/tcc.h b/tcc.h index cd679732..e5366cb0 100644 --- a/tcc.h +++ b/tcc.h @@ -817,7 +817,6 @@ struct TCCState { int do_bench; /* option -bench */ int gen_deps; /* option -MD */ char *deps_outfile; /* option -MF */ - int option_pthread; /* -pthread option */ int argc; char **argv; };