Add -L option

This commit is contained in:
Rui Ueyama 2020-09-13 15:34:58 +09:00
parent 4e5de36a36
commit c8df7874c6
2 changed files with 19 additions and 0 deletions

12
main.c
View File

@ -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);

View File

@ -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