- 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 | 1419 | ret = tcc_load_ldscript(s1); |
| 1420 | 1420 | #endif |
| 1421 | 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 | 1424 | the_end: |
| 1425 | − if (s1->verbose) | |
| 1426 | − printf("+> %s\n", filename); | |
| 1427 | 1425 | tcc_close(); |
| 1428 | 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 | 2319 | s->rdynamic = 1; |
| 2322 | 2320 | break; |
| 2323 | 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 | 2322 | if (pas->linker_arg.size) |
| 2335 | 2323 | --pas->linker_arg.size, cstr_ccat(&pas->linker_arg, ','); |
| 2336 | 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 | 53 | #define TCC_FILETYPE_C 2 |
| 54 | 54 | #define TCC_FILETYPE_ASM 3 |
| 55 | 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 | 57 | /* compile a string containing a C source. Return -1 if error. */ |
| 60 | 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 | 317 | @item -Wl,-rpath=path |
| 318 | 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 | 320 | @item -Wl,--oformat=fmt |
| 329 | 321 | Use @var{fmt} as output format. The supported output formats are: |
| 330 | 322 | @table @code |
| @@ -247,13 +247,6 @@ static int64_t getclock_us(void) · 246 unmodified lines | ||
| 247 | 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 | 250 | int main(int argc, char **argv) |
| 258 | 251 | { |
| 259 | 252 | TCCState *s; |
| @@ -308,14 +301,6 @@ int main(int argc, char **argv) · 48 unmodified lines | ||
| 308 | 301 | for(i = ret = 0; i < s->nb_files && ret == 0; i++) { |
| 309 | 302 | int filetype = *(unsigned char *)s->files[i]; |
| 310 | 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 | 304 | if (filename[0] == '-' && filename[1] == 'l') { |
| 320 | 305 | if (tcc_add_library(s, filename + 2) < 0) { |
| 321 | 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 | 312 | } else { |
| 313 | + if (1 == s->verbose) | |
| 314 | + printf("-> %s\n", filename); | |
| 328 | 315 | if (!s->outfile) |
| 329 | 316 | s->outfile = default_outputfile(s, filename); |
| 330 | 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 | 339 | if (0 == ret) { |
| 354 | 340 | if (s->output_type == TCC_OUTPUT_MEMORY) { |
| @@ -692,7 +692,6 @@ struct TCCState { · 691 unmodified lines | ||
| 692 | 692 | int rdynamic; /* if true, all symbols are exported */ |
| 693 | 693 | int symbolic; /* if true, resolve symbols in the current module first */ |
| 694 | 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 | 696 | char *tcc_lib_path; /* CONFIG_TCCDIR or -B option */ |
| 698 | 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 | 3076 | if(sym_index) { |
| 3077 | 3077 | sym = &((ElfW(Sym) *)symtab_section->data)[sym_index]; |
| 3078 | 3078 | if(sym->st_shndx == SHN_UNDEF) { |
| 3079 | − load_obj: | |
| 3080 | 3079 | off = get_be32(ar_index + i * 4) + sizeof(ArchiveHeader); |
| 3081 | 3080 | ++bound; |
| 3082 | 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 | 3085 | goto the_end; |
| 3087 | 3086 | } |
| 3088 | 3087 | } |
| 3089 | − } else if (s1->whole_archive) { | |
| 3090 | − goto load_obj; | |
| 3091 | 3088 | } |
| 3092 | 3089 | } |
| 3093 | 3090 | } while(bound); |