History

Support linker options passed in several -Wl param

ld support arguments to multiple-letter options being passed in two ways: * -opt=arg * -opt arg libtool generate command line of the second form. This commit add support for the second form so that libtool works with tcc. The way it is done is to concatenate all -Wl options into one and then pass it to set_linker.

Thomas Preud'homme committed 14 years ago

Commit 7fb04821 parent 1736a712 files · +19 −2Browse files

Unified · Split

2 files
  1. libtcc.c +3 −0
  2. tcc.c +16 −2
libtcc.c+3−0
@@ -1566,6 +1566,9 @@ PUB_FUNC const char * tcc_set_linker(TCCState *s, char *option, int multi) · 1565 unmodified lines
1566 s->text_addr = strtoull(p, &end, 16);1566 s->text_addr = strtoull(p, &end, 16);
1567 s->has_text_addr = 1;1567 s->has_text_addr = 1;
1568 } else {1568 } else {
1569 char *comma_ptr = strchr(option, ',');
1570 if (comma_ptr)
1571 *comma_ptr = '\0';
1569 return option;1572 return option;
1570 }1573 }
1571 1574
tcc.c+16−2
@@ -280,6 +280,8 @@ static int parse_args(TCCState *s, int argc, char **argv) · 279 unmodified lines
280 const char *optarg, *p1, *r1;280 const char *optarg, *p1, *r1;
281 char *r;281 char *r;
282 int was_pthread;282 int was_pthread;
283 char *linker_arg = NULL;
284 unsigned long linker_argsize = 0;
283 285
284 was_pthread = 0; /* is set if commandline contains -pthread key */286 was_pthread = 0; /* is set if commandline contains -pthread key */
285 287
@@ -442,8 +444,17 @@ static int parse_args(TCCState *s, int argc, char **argv) · 156 unmodified lines
442 s->rdynamic = 1;444 s->rdynamic = 1;
443 break;445 break;
444 case TCC_OPTION_Wl:446 case TCC_OPTION_Wl:
445 if ((r = (char *) tcc_set_linker(s, (char *)optarg, TRUE)))447 if (!linker_arg) {
446 tcc_error("unsupported linker option '%s'", r);448 linker_argsize = strlen(optarg) + 1;
449 linker_arg = tcc_malloc(linker_argsize);
450 pstrcpy(linker_arg, linker_argsize, optarg);
451 }
452 else {
453 linker_argsize += strlen(optarg) + 1;
454 linker_arg = tcc_realloc(linker_arg, linker_argsize);
455 pstrcat(linker_arg, linker_argsize, ",");
456 pstrcat(linker_arg, linker_argsize, optarg);
457 }
447 break;458 break;
448 case TCC_OPTION_E:459 case TCC_OPTION_E:
449 output_type = TCC_OUTPUT_PREPROCESS;460 output_type = TCC_OUTPUT_PREPROCESS;
@@ -465,6 +476,9 @@ static int parse_args(TCCState *s, int argc, char **argv) · 15 unmodified lines
465 }476 }
466 }477 }
467 }478 }
479 if ((r = (char *) tcc_set_linker(s, (char *)linker_arg, TRUE)))
480 tcc_error("unsupported linker option '%s'", r);
481 tcc_free(linker_arg);
468 /* fixme: these options could be different on your platform */482 /* fixme: these options could be different on your platform */
469 if (was_pthread && output_type != TCC_OUTPUT_OBJ) {483 if (was_pthread && output_type != TCC_OUTPUT_OBJ) {
470 dynarray_add((void ***)&files, &nb_files, "-lpthread");484 dynarray_add((void ***)&files, &nb_files, "-lpthread");

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t