- would parse linker args in two different places - would mess up "tcc -v ..." output: tcc -v test.c -> test.c +> test.c - would use function "tcc_load_alacarte()" to do the contrary of what its name suggests. This reverts commit 19a169ceb896f78205bc23b847938c58f14d1dda.
Unified · Split
| @@ -1419,11 +1419,9 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags, · 1418 unmodified lines | |||
| 1419 | ret = tcc_load_ldscript(s1); | 1419 | ret = tcc_load_ldscript(s1); |
| 1420 | #endif | 1420 | #endif |
| 1421 | if (ret < 0) | 1421 | if (ret < 0) |
| 1422 | tcc_error_noabort("%s: unrecognized file type (error=%d)", filename, ret); | 1422 | tcc_error_noabort("unrecognized file type"); |
| 1423 | 1423 | ||
| 1424 | the_end: | 1424 | the_end: |
| 1425 | if (s1->verbose) | ||
| 1426 | printf("+> %s\n", filename); | ||
| 1427 | tcc_close(); | 1425 | tcc_close(); |
| 1428 | return ret; | 1426 | return ret; |
| 1429 | } | 1427 | } |
| @@ -2321,16 +2319,6 @@ ST_FUNC int tcc_parse_args1(TCCState *s, int argc, char **argv) · 891 unmodified lines | |||
| 2321 | s->rdynamic = 1; | 2319 | s->rdynamic = 1; |
| 2322 | break; | 2320 | break; |
| 2323 | case TCC_OPTION_Wl: | 2321 | case TCC_OPTION_Wl: |
| 2324 | if (optarg && *optarg == '-') { | ||
| 2325 | int offs = 0; | ||
| 2326 | if (!strncmp("-no", optarg+1, 3)) | ||
| 2327 | offs += 3; | ||
| 2328 | if (!strcmp("-whole-archive", optarg+1 + offs)) { | ||
| 2329 | args_parser_add_file(s, "", (offs == 0) ? TCC_FILETYPE_AR_WHOLE_ON : | ||
| 2330 | TCC_FILETYPE_AR_WHOLE_OFF); | ||
| 2331 | break; | ||
| 2332 | } | ||
| 2333 | } | ||
| 2334 | if (pas->linker_arg.size) | 2322 | if (pas->linker_arg.size) |
| 2335 | --pas->linker_arg.size, cstr_ccat(&pas->linker_arg, ','); | 2323 | --pas->linker_arg.size, cstr_ccat(&pas->linker_arg, ','); |
| 2336 | cstr_cat(&pas->linker_arg, optarg, 0); | 2324 | cstr_cat(&pas->linker_arg, optarg, 0); |
| @@ -53,8 +53,6 @@ LIBTCCAPI int tcc_add_file(TCCState *s, const char *filename, int filetype); · 52 unmodified lines | |||
| 53 | #define TCC_FILETYPE_C 2 | 53 | #define TCC_FILETYPE_C 2 |
| 54 | #define TCC_FILETYPE_ASM 3 | 54 | #define TCC_FILETYPE_ASM 3 |
| 55 | #define TCC_FILETYPE_ASM_PP 4 | 55 | #define TCC_FILETYPE_ASM_PP 4 |
| 56 | #define TCC_FILETYPE_AR_WHOLE_OFF 5 | ||
| 57 | #define TCC_FILETYPE_AR_WHOLE_ON 6 | ||
| 58 | 56 | ||
| 59 | /* compile a string containing a C source. Return -1 if error. */ | 57 | /* compile a string containing a C source. Return -1 if error. */ |
| 60 | LIBTCCAPI int tcc_compile_string(TCCState *s, const char *buf); | 58 | LIBTCCAPI int tcc_compile_string(TCCState *s, const char *buf); |
| @@ -317,14 +317,6 @@ Generate an object file combining all input files. · 316 unmodified lines | |||
| 317 | @item -Wl,-rpath=path | 317 | @item -Wl,-rpath=path |
| 318 | Put custom search path for dynamic libraries into executable. | 318 | Put custom search path for dynamic libraries into executable. |
| 319 | 319 | ||
| 320 | @item -Wl,--whole-archive | ||
| 321 | Add a whole archive, not just the symbols of the archive that would | ||
| 322 | satisfy undefined symbols in the program. | ||
| 323 | |||
| 324 | @item -Wl,--no-whole-archive | ||
| 325 | Turn off the effect of the --whole-archive option for subsequent archive | ||
| 326 | files. | ||
| 327 | |||
| 328 | @item -Wl,--oformat=fmt | 320 | @item -Wl,--oformat=fmt |
| 329 | Use @var{fmt} as output format. The supported output formats are: | 321 | Use @var{fmt} as output format. The supported output formats are: |
| 330 | @table @code | 322 | @table @code |
| @@ -247,13 +247,6 @@ static int64_t getclock_us(void) · 246 unmodified lines | |||
| 247 | #endif | 247 | #endif |
| 248 | } | 248 | } |
| 249 | 249 | ||
| 250 | static void set_whole_archive(TCCState* s, int on) | ||
| 251 | { | ||
| 252 | s->whole_archive = on; | ||
| 253 | if (1 == s->verbose) | ||
| 254 | printf("%cwhole-archive>\n", s->whole_archive? '+' : '-'); | ||
| 255 | } | ||
| 256 | |||
| 257 | int main(int argc, char **argv) | 250 | int main(int argc, char **argv) |
| 258 | { | 251 | { |
| 259 | TCCState *s; | 252 | TCCState *s; |
| @@ -308,14 +301,6 @@ int main(int argc, char **argv) · 48 unmodified lines | |||
| 308 | for(i = ret = 0; i < s->nb_files && ret == 0; i++) { | 301 | for(i = ret = 0; i < s->nb_files && ret == 0; i++) { |
| 309 | int filetype = *(unsigned char *)s->files[i]; | 302 | int filetype = *(unsigned char *)s->files[i]; |
| 310 | const char *filename = s->files[i] + 1; | 303 | const char *filename = s->files[i] + 1; |
| 311 | if (filetype == TCC_FILETYPE_AR_WHOLE_ON || | ||
| 312 | filetype == TCC_FILETYPE_AR_WHOLE_OFF) | ||
| 313 | { | ||
| 314 | set_whole_archive(s, filetype == TCC_FILETYPE_AR_WHOLE_ON); | ||
| 315 | continue; | ||
| 316 | } | ||
| 317 | if (1 == s->verbose) | ||
| 318 | printf("-> %s\n", filename); | ||
| 319 | if (filename[0] == '-' && filename[1] == 'l') { | 304 | if (filename[0] == '-' && filename[1] == 'l') { |
| 320 | if (tcc_add_library(s, filename + 2) < 0) { | 305 | if (tcc_add_library(s, filename + 2) < 0) { |
| 321 | /* don't fail on -lm as it's harmless to skip math lib */ | 306 | /* don't fail on -lm as it's harmless to skip math lib */ |
| @@ -325,6 +310,8 @@ int main(int argc, char **argv) · 3 unmodified lines | |||
| 325 | } | 310 | } |
| 326 | } | 311 | } |
| 327 | } else { | 312 | } else { |
| 313 | if (1 == s->verbose) | ||
| 314 | printf("-> %s\n", filename); | ||
| 328 | if (!s->outfile) | 315 | if (!s->outfile) |
| 329 | s->outfile = default_outputfile(s, filename); | 316 | s->outfile = default_outputfile(s, filename); |
| 330 | if (tcc_add_file(s, filename, filetype) < 0) | 317 | if (tcc_add_file(s, filename, filetype) < 0) |
| @@ -348,7 +335,6 @@ int main(int argc, char **argv) · 17 unmodified lines | |||
| 348 | } | 335 | } |
| 349 | } | 336 | } |
| 350 | } | 337 | } |
| 351 | set_whole_archive(s, 0); | ||
| 352 | 338 | ||
| 353 | if (0 == ret) { | 339 | if (0 == ret) { |
| 354 | if (s->output_type == TCC_OUTPUT_MEMORY) { | 340 | if (s->output_type == TCC_OUTPUT_MEMORY) { |
| @@ -692,7 +692,6 @@ struct TCCState { · 691 unmodified lines | |||
| 692 | int rdynamic; /* if true, all symbols are exported */ | 692 | int rdynamic; /* if true, all symbols are exported */ |
| 693 | int symbolic; /* if true, resolve symbols in the current module first */ | 693 | int symbolic; /* if true, resolve symbols in the current module first */ |
| 694 | int alacarte_link; /* if true, only link in referenced objects from archive */ | 694 | int alacarte_link; /* if true, only link in referenced objects from archive */ |
| 695 | int whole_archive; /* if true, link in a whole *.a even when alacarte_link */ | ||
| 696 | 695 | ||
| 697 | char *tcc_lib_path; /* CONFIG_TCCDIR or -B option */ | 696 | char *tcc_lib_path; /* CONFIG_TCCDIR or -B option */ |
| 698 | char *soname; /* as specified on the command line (-soname) */ | 697 | char *soname; /* as specified on the command line (-soname) */ |
| @@ -3076,7 +3076,6 @@ static int tcc_load_alacarte(TCCState *s1, int fd, int size) · 3075 unmodified lines | |||
| 3076 | if(sym_index) { | 3076 | if(sym_index) { |
| 3077 | sym = &((ElfW(Sym) *)symtab_section->data)[sym_index]; | 3077 | sym = &((ElfW(Sym) *)symtab_section->data)[sym_index]; |
| 3078 | if(sym->st_shndx == SHN_UNDEF) { | 3078 | if(sym->st_shndx == SHN_UNDEF) { |
| 3079 | load_obj: | ||
| 3080 | off = get_be32(ar_index + i * 4) + sizeof(ArchiveHeader); | 3079 | off = get_be32(ar_index + i * 4) + sizeof(ArchiveHeader); |
| 3081 | ++bound; | 3080 | ++bound; |
| 3082 | lseek(fd, off, SEEK_SET); | 3081 | lseek(fd, off, SEEK_SET); |
| @@ -3086,8 +3085,6 @@ static int tcc_load_alacarte(TCCState *s1, int fd, int size) · 3 unmodified lines | |||
| 3086 | goto the_end; | 3085 | goto the_end; |
| 3087 | } | 3086 | } |
| 3088 | } | 3087 | } |
| 3089 | } else if (s1->whole_archive) { | ||
| 3090 | goto load_obj; | ||
| 3091 | } | 3088 | } |
| 3092 | } | 3089 | } |
| 3093 | } while(bound); | 3090 | } while(bound); |