-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behavioros-linuxLinuxLinux
Milestone
Description
Zig Version
0.10.0-dev.3672+cd5a9ba1f
Steps to Reproduce
testresolv.c
#include <stdio.h>
#include <resolv.h>
int main() {
printf("res_query: %p\n", res_query);
printf("dn_expand: %p\n", dn_expand);
}Compile for x86_64-linux-gnu.2.33:
$ ZIG_VERBOSE_LINK=1 zig cc --target=x86_64-linux-gnu.2.33 -lresolv testresolv.c -o testresolv
LLD Link... ld.lld -error-limit=0 -O0 -z stack-size=16777216 --gc-sections --eh-frame-hdr -znow -m elf_x86_64 -o /home/motiejus/.cache/zig/o/cb35c829f307f454aa748de0e579d29a/testresolv /home/motiejus/.cache/zig/o/479dd8cc8de0fb41dd40abf62f254c4a/Scrt1.o /home/motiejus/.cache/zig/o/e7beca82c5577aea9885d59a7e4096da/crti.o -dynamic-linker /lib64/ld-linux-x86-64.so.2 /home/motiejus/.cache/zig/o/db5fa2707fb80a202fbe609594d23cc2/testresolv.o /home/motiejus/.cache/zig/o/8d7a9daa5963045c0ecc7ac066259b7f/libcompiler_rt.a --as-needed /home/motiejus/.cache/zig/o/1ccb25741ec2e9c844aced091e012f89/libm.so.6 /home/motiejus/.cache/zig/o/1ccb25741ec2e9c844aced091e012f89/libpthread.so.0 /home/motiejus/.cache/zig/o/1ccb25741ec2e9c844aced091e012f89/libc.so.6 /home/motiejus/.cache/zig/o/1ccb25741ec2e9c844aced091e012f89/libdl.so.2 /home/motiejus/.cache/zig/o/1ccb25741ec2e9c844aced091e012f89/librt.so.1 /home/motiejus/.cache/zig/o/1ccb25741ec2e9c844aced091e012f89/libld.so.2 /home/motiejus/.cache/zig/o/1ccb25741ec2e9c844aced091e012f89/libutil.so.1 /home/motiejus/.cache/zig/o/729209225ef10d542a54765aaf478e99/libc_nonshared.a /home/motiejus/.cache/zig/o/9a75a4492a68987917fb40c469decd3b/crtn.o --allow-shlib-undefined
ld.lld: error: undefined symbol: res_query
>>> referenced by testresolv.c:5 (/home/motiejus/x/testresolv.c:5)
>>> /home/motiejus/.cache/zig/o/db5fa2707fb80a202fbe609594d23cc2/testresolv.o:(main)
ld.lld: error: undefined symbol: dn_expand
>>> referenced by testresolv.c:6 (/home/motiejus/x/testresolv.c:6)
>>> /home/motiejus/.cache/zig/o/db5fa2707fb80a202fbe609594d23cc2/testresolv.o:(main)
If we use gnu.2.34, when it was moved from libresolv.so to libc.so, it compiles successfully:
$ zig cc --target=x86_64-linux-gnu.2.34 testresolv.c -o testresolv && ./testresolv
res_query: 0x7fb2b12ffa40
dn_expand: 0x7fb2b12f6810
There are a few issues:
-lresolvis a "libc name", which causes it to be skipped from the linker line.libresolv.sostub is not built together with the rest of glibc stubs:
ls /home/motiejus/.cache/zig/o/1ccb25741ec2e9c844aced091e012f89/*.so* | xargs -n1 basename
libc.so.6
libdl.so.2
libld.so.2
libm.so.6
libpthread.so.0
librt.so.1
libutil.so.1
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behavioros-linuxLinuxLinux