-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
Zig Version
0.12.0-dev.1333+8b1073341
Steps to Reproduce and Observed Behavior
Zig can compile against many specific glibc versions successfully:
$ zig build-exe hello.zig -lc -target x86-linux-gnu.2.33
$ zig build-exe hello.zig -lc -target aarch64-linux-gnu.2.33
$ zig build-exe hello.zig -lc -target x86-linux-gnu.2.17
$ zig build-exe hello.zig -lc -target aarch64-linux-gnu.2.17
However, if the glibc version gets too old, errors crop up. E.g., on x86 (and x86_64) glibc versions before v2.16 fail due to the getauxval symbol used by start.zig:
$ zig build-exe hello.zig -lc -target x86-linux-gnu.2.15
error: ld.lld: undefined symbol: getauxval
note: referenced by start.zig:476 (/home/pat/projects/ziglang/zig/lib/std/start.zig:476)
note: hello.o:(main)
note: referenced by start.zig:477 (/home/pat/projects/ziglang/zig/lib/std/start.zig:477)
note: hello.o:(main)
On aarch64, there are a ton of errors at v2.16 and earlier (these look extra suspicious, like the glibc runtime libraries are being mis-built?):
$ zig build-exe hello.zig -lc -target aarch64-linux-gnu.2.16
error: ld.lld: undefined symbol: __libc_start_main
note: referenced by start-2.33.S:92 (/home/pat/projects/ziglang/zig/lib/libc/glibc/sysdeps/aarch64/start-2.33.S:92)
note: /home/pat/.cache/zig/o/3fec5149eac3449eef162626281b911d/Scrt1.o:(.text+0x30)
error: ld.lld: undefined symbol: abort
note: referenced by start-2.33.S:95 (/home/pat/projects/ziglang/zig/lib/libc/glibc/sysdeps/aarch64/start-2.33.S:95)
note: /home/pat/.cache/zig/o/3fec5149eac3449eef162626281b911d/Scrt1.o:(.text+0x34)
note: referenced by os.zig:608 (/home/pat/projects/ziglang/zig/lib/std/os.zig:608)
note: hello.o:(os.abort)
error: ld.lld: undefined symbol: __fxstat64
note: referenced by fstat64-2.32.c:51 (/home/pat/projects/ziglang/zig/lib/libc/glibc/io/fstat64-2.32.c:51)
note: /home/pat/.cache/zig/o/79fd86fc882e9274904ca70a9f85d0f1/fstat64-2.32.o:(fstat64) in archive /home/pat/.cache/zig/o/be11b83084d20d5d4a81b606d601713a/libc_nonshared.a
error: ld.lld: undefined symbol: __stack_chk_guard
...
(lots more missing symbols)
Zig claims support going back to 2.0.0!
$ zig4 targets | jq -c '.glibc'
["2.0.0","2.1.0","2.1.1","2.1.2","2.1.3","2.2.0","2.2.1","2.2.2","2.2.3","2.2.4","2.2.5","2.2.6","2.3.0","2.3.2","2.3.3","2.3.4","2.4.0","2.5.0","2.6.0","2.7.0","2.8.0","2.9.0","2.10.0","2.11.0","2.12.0","2.13.0","2.14.0","2.15.0","2.16.0","2.17.0","2.18.0","2.19.0","2.20.0","2.21.0","2.22.0","2.23.0","2.24.0","2.25.0","2.26.0","2.27.0","2.28.0","2.29.0","2.30.0","2.31.0","2.32.0","2.33.0","2.34.0","2.35.0","2.36.0","2.37.0","2.38.0"]
For context, GNU glibc v2.17 is from 2012, and 2.0.0 is from the previous millennium (see https://sourceware.org/glibc/wiki/Glibc%20Timeline).
Should these older versions work? Or is cutting things off at 2.17 (or maybe 2.20 from 2014?) a reasonable "fix"?
Expected Behavior
hello.zig compiles against all the supported glibc versions on all the supported architectures.