mirror of https://github.com/rui314/chibicc
Add -L option
This commit is contained in:
parent
4e5de36a36
commit
c8df7874c6
12
main.c
12
main.c
|
@ -291,6 +291,18 @@ static void parse_args(int argc, char **argv) {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!strcmp(argv[i], "-L")) {
|
||||
strarray_push(&ld_extra_args, "-L");
|
||||
strarray_push(&ld_extra_args, argv[++i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strncmp(argv[i], "-L", 2)) {
|
||||
strarray_push(&ld_extra_args, "-L");
|
||||
strarray_push(&ld_extra_args, argv[i] + 2);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strcmp(argv[i], "-hashmap-test")) {
|
||||
hashmap_test();
|
||||
exit(0);
|
||||
|
|
|
@ -288,4 +288,11 @@ echo 'int foo(); int bar=3; int main() { foo(); }' > $tmp/bar.c
|
|||
$chibicc -fPIC -shared -o $tmp/foo.so $tmp/foo.c $tmp/bar.c
|
||||
check -shared
|
||||
|
||||
# -L
|
||||
echo 'extern int bar; int foo() { return bar; }' > $tmp/foo.c
|
||||
$chibicc -fPIC -shared -o $tmp/libfoobar.so $tmp/foo.c
|
||||
echo 'int foo(); int bar=3; int main() { foo(); }' > $tmp/bar.c
|
||||
$chibicc -o $tmp/foo $tmp/bar.c -L$tmp -lfoobar
|
||||
check -L
|
||||
|
||||
echo OK
|
||||
|
|
Loading…
Reference in New Issue