When emerging dev-lang/zig on Gentoo Prefix with sys-devel/lld:16, the last step of compilation, compiling stage3/bin/zig, failed with [19/19] cd /tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0 && /tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/build/zig2 build --prefix /tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/build/stage3 --zig-lib-dir /tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/lib -Dconfig_h=/tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/build/config.h -Denable-llvm -Doptimize=ReleaseFast -Dno-langref -Dno-autodocs -Dtarget=native -Dcpu=native -Dversion-string=0.11.0 FAILED: stage3/bin/zig /tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/build/stage3/bin/zig cd /tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0 && /tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/build/zig2 build --prefix /tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/build/stage3 --zig-lib-dir /tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/lib -Dconfig_h=/tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/build/config.h -Denable-llvm -Doptimize=ReleaseFast -Dno-langref -Dno-autodocs -Dtarget=native -Dcpu=native -Dversion-string=0.11.0 zig build-exe zig ReleaseFast native: error: the following command failed with 5 compilation errors: /tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/build/zig2 build-exe --stack 33554432 /tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/src/main.zig /tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/build/zigcpp/libzigcpp.a /home/wuyy/gentoo_prefix/usr/lib/llvm/16/lib64/libclang-cpp.so.16 /home/wuyy/gentoo_prefix/usr/lib/llvm/16/lib64/liblldMinGW.so /home/wuyy/gentoo_prefix/usr/lib/llvm/16/lib64/liblldELF.so /home/wuyy/gentoo_prefix/usr/lib/llvm/16/lib64/liblldCOFF.so /home/wuyy/gentoo_prefix/usr/lib/llvm/16/lib64/liblldWasm.so /home/wuyy/gentoo_prefix/usr/lib/llvm/16/lib64/liblldMachO.so /home/wuyy/gentoo_prefix/usr/lib/llvm/16/lib64/liblldCommon.so /home/wuyy/gentoo_prefix/usr/lib/llvm/16/lib64/libLLVM-16.so /home/wuyy/gentoo_prefix/usr/lib/gcc/x86_64-pc-linux-gnu/13/libstdc++.so -lunwind -lc -OReleaseFast --cache-dir /tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/zig-cache --global-cache-dir /tmp/portage/dev-lang/zig-0.11.0/homedir/.cache/zig --name zig --mod build_options::/tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/zig-cache/c/8be3380d7aa95aa051fdfc613f919a48/options.zig --deps build_options -I /home/wuyy/gentoo_prefix/usr/lib/llvm/16/include -I /home/wuyy/gentoo_prefix/usr/lib/llvm/16/include -L /home/wuyy/gentoo_prefix/usr/lib/llvm/16/lib64 -I /home/wuyy/gentoo_prefix/usr/lib/llvm/16/include --zig-lib-dir /tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/lib --listen=- Build Summary: 2/5 steps succeeded; 1 failed (disable with --summary none) install transitive failure +- install zig transitive failure +- zig build-exe zig ReleaseFast native 5 errors error: ld.lld: undefined symbol: __libc_single_threaded note: referenced by zig_clang_cc1_main.cpp note: zig_clang_cc1_main.cpp.o:(cc1_main(llvm::ArrayRef<char const*>, char const*, void*)) in archive /tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/build/zigcpp/libzigcpp.a note: referenced by zig_clang_cc1_main.cpp note: zig_clang_cc1_main.cpp.o:(cc1_main(llvm::ArrayRef<char const*>, char const*, void*)) in archive /tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/build/zigcpp/libzigcpp.a note: referenced by zig_clang_cc1_main.cpp note: zig_clang_cc1_main.cpp.o:(cc1_main(llvm::ArrayRef<char const*>, char const*, void*)) in archive /tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/build/zigcpp/libzigcpp.a note: referenced 6 more times error: ld.lld: undefined symbol: pthread_attr_setstacksize note: referenced by Thread.zig:699 (/tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/lib/std/Thread.zig:699) note: /tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/zig-cache/o/96df9fe3edb2ed3b0deecf123f3b66fe/zig.o:(Thread.Pool.init) note: referenced by Thread.zig:699 (/tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/lib/std/Thread.zig:699) note: /tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/zig-cache/o/96df9fe3edb2ed3b0deecf123f3b66fe/zig.o:(main.serve) error: ld.lld: undefined symbol: pthread_attr_setguardsize note: referenced by Thread.zig:700 (/tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/lib/std/Thread.zig:700) note: /tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/zig-cache/o/96df9fe3edb2ed3b0deecf123f3b66fe/zig.o:(Thread.Pool.init) note: referenced by Thread.zig:700 (/tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/lib/std/Thread.zig:700) note: /tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/zig-cache/o/96df9fe3edb2ed3b0deecf123f3b66fe/zig.o:(main.serve) error: ld.lld: undefined symbol: pthread_create note: referenced by Thread.zig:703 (/tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/lib/std/Thread.zig:703) note: /tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/zig-cache/o/96df9fe3edb2ed3b0deecf123f3b66fe/zig.o:(Thread.Pool.init) note: referenced by Thread.zig:703 (/tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/lib/std/Thread.zig:703) note: /tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/zig-cache/o/96df9fe3edb2ed3b0deecf123f3b66fe/zig.o:(main.serve) error: ld.lld: undefined symbol: pthread_join note: referenced by Thread.zig:731 (/tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/lib/std/Thread.zig:731) note: /tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/zig-cache/o/96df9fe3edb2ed3b0deecf123f3b66fe/zig.o:(Thread.Pool.join) note: referenced by Thread.zig:731 (/tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/lib/std/Thread.zig:731) note: /tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/zig-cache/o/96df9fe3edb2ed3b0deecf123f3b66fe/zig.o:(main.serve) note: referenced by Thread.zig:731 (/tmp/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/lib/std/Thread.zig:731) Reproducible: Always
Created attachment 871468 [details] build.log
Created attachment 871469 [details] emerge --info
Similar to https://github.com/ziglang/zig/issues/11137, and it may be caused by detecting the wrong libc version, like https://github.com/ziglang/zig/issues/6469, but this is prefix, so maybe zig is looking into hosts' libc
Update: On another prefix with Debian host (the original bug report is produced on RHEL 8 host where /lib64 -> /usr/lib64 contains libm.so and other libraries), the error messages are: ``` FAILED: stage3/bin/zig /fast/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/build/stage3/bin/zig cd /fast/portage/dev-lang/zig-0.11.0/work/zig-0.11.0 && /fast/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/build/zig2 build --prefix /fast/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/build/stage3 --zig-lib-dir /fast/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/lib -Dconfig_h=/fast/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/build/config.h -Denable-llvm -Doptimize=ReleaseFast -Dno-langref -Dno-autodocs -Dtarget=native -Dcpu=native -Dversion-string=0.11.0 zig build-exe zig ReleaseFast native: error: the following command failed with 1 compilation errors: /fast/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/build/zig2 build-exe --stack 33554432 /fast/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/src/main.zig /fast/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/build/zigcpp/libzigcpp.a /opt/gentoo/usr/lib/llvm/16/lib64/libclang-cpp.so.16 /opt/gentoo/usr/lib/llvm/16/lib64/liblldMinGW.so /opt/gentoo/usr/lib/llvm/16/lib64/liblldELF.so /opt/gentoo/usr/lib/llvm/16/lib64/liblldCOFF.so /opt/gentoo/usr/lib/llvm/16/lib64/liblldWasm.so /opt/gentoo/usr/lib/llvm/16/lib64/liblldMachO.so /opt/gentoo/usr/lib/llvm/16/lib64/liblldCommon.so /opt/gentoo/usr/lib/llvm/16/lib64/libLLVM-16.so /opt/gentoo/usr/lib/gcc/x86_64-pc-linux-gnu/13/libstdc++.so -lunwind -lc -OReleaseFast --cache-dir /fast/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/zig-cache --global-cache-dir /fast/portage/dev-lang/zig-0.11.0/homedir/.cache/zig --name zig --mod build_options::/fast/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/zig-cache/c/8be3380d7aa95aa051fdfc613f919a48/options.zig --deps build_options -I /opt/gentoo/usr/lib/llvm/16/include -I /opt/gentoo/usr/lib/llvm/16/include -L /opt/gentoo/usr/lib/llvm/16/lib64 -I /opt/gentoo/usr/lib/llvm/16/include --zig-lib-dir /fast/portage/dev-lang/zig-0.11.0/work/zig-0.11.0/lib --listen=- Build Summary: 2/5 steps succeeded; 1 failed (disable with --summary none) install transitive failure +- install zig transitive failure +- zig build-exe zig ReleaseFast native 1 errors error: ld.lld: cannot open /lib64/libm.so.6: No such file or directory ``` So it's more evident that something goes wrong when zig detects system lib locations
Can you share output of: * getconf GNU_LIBC_VERSION * zig2 build-exe --show-builtin on both systems please? Thanks in advance!
(In reply to Eric Joldasov from comment #5) > Can you share output of: > > * getconf GNU_LIBC_VERSION They both omit glibc 2.37 While if I run /usr/bin/getconf GNU_LIBC_VERSION, RHEL 8 gives glibc 2.28 and Debian 12 gives glibc 2.36 > * zig2 build-exe --show-builtin The output of ${BUILD_DIR}/zig2 build-exe --show-builtin will be uploaded as attachments
Created attachment 871619 [details] zig2-show-builtin-RHEL8
Created attachment 871620 [details] zig2-show-builtin-Debian12
I see, thanks! Guess I need to return getconf patch for a while.
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=42ac667416fe133255c3baca620e9af61315cb3b commit 42ac667416fe133255c3baca620e9af61315cb3b Author: Eric Joldasov <bratishkaerik@getgoogleoff.me> AuthorDate: 2023-10-10 03:12:16 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2023-10-27 02:53:03 +0000 dev-lang/zig: patch 0.11.0 to use getconf when detecting glibc version Bug: https://bugs.gentoo.org/914731 Bug: https://bugs.gentoo.org/914101 Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me> Signed-off-by: Sam James <sam@gentoo.org> .../zig/files/zig-0.11.0-first-try-getconf.patch | 109 +++++++++++++++++++++ .../{zig-0.11.0.ebuild => zig-0.11.0-r1.ebuild} | 4 + 2 files changed, 113 insertions(+)
Sorry, after applying the patch, the `./zig2 build-exe --show-builtin` command shows glibc version to 2.36, but not 2.37 which is the output of `getconf GNU_LIBC_VERSION`. And the build error remains the same. And I noticed that, before applying this patch, both system `./zig2 build-exe --show-builtin` gives glibc version 2.19, despite the Gentoo prefix has 2.37, while RHEL 8 has 2.19 and Debian 12 has 2.36. After the patch, `./zig2 build-exe --show-builtin` both gives 2.36. It looks very weird. I will add the output prefixed with "new-" in attachments.
Created attachment 873664 [details] new-zig2-show-builtin-Debian12
Created attachment 873665 [details] new-zig2-show-builtin-RHEL8
Hello, could you please re-test this again with latest dev-lang/zig-0.11.0 ebuild? Thanks in advance.
(In reply to Eric Joldasov from comment #14) > Hello, could you please re-test this again with latest dev-lang/zig-0.11.0 > ebuild? Thanks in advance. I just tried with latest portage commit 54b20cb55a644f07faa7f426118e4ff9b6c4d8e9 and the issue remains the same. I think the https://bugs.gentoo.org/attachment.cgi?id=873664(In reply to Yiyang Wu from comment #11) > Sorry, after applying the patch, the `./zig2 build-exe --show-builtin` > command shows glibc version to 2.36, but not 2.37 which is the output of > `getconf GNU_LIBC_VERSION`. And the build error remains the same. > > And I noticed that, before applying this patch, both system `./zig2 > build-exe --show-builtin` gives glibc version 2.19, despite the Gentoo > prefix has 2.37, while RHEL 8 has 2.19 and Debian 12 has 2.36. After the > patch, `./zig2 build-exe --show-builtin` both gives 2.36. It looks very > weird. > > I will add the output prefixed with "new-" in attachments. Above are my test results after the fix, and I didn't notice any new commit introduced to dev-lang/zig-0.11.0 since then. So I guess the issue is still here.
(In reply to Yiyang Wu from comment #15) > (In reply to Eric Joldasov from comment #14) > > Hello, could you please re-test this again with latest dev-lang/zig-0.11.0 > > ebuild? Thanks in advance. > > I just tried with latest portage commit > 54b20cb55a644f07faa7f426118e4ff9b6c4d8e9 and the issue remains the same. > > I think the https://bugs.gentoo.org/attachment.cgi?id=873664(In reply to > Yiyang Wu from comment #11) > > Sorry, after applying the patch, the `./zig2 build-exe --show-builtin` > > command shows glibc version to 2.36, but not 2.37 which is the output of > > `getconf GNU_LIBC_VERSION`. And the build error remains the same. > > > > And I noticed that, before applying this patch, both system `./zig2 > > build-exe --show-builtin` gives glibc version 2.19, despite the Gentoo > > prefix has 2.37, while RHEL 8 has 2.19 and Debian 12 has 2.36. After the > > patch, `./zig2 build-exe --show-builtin` both gives 2.36. It looks very > > weird. > > > > I will add the output prefixed with "new-" in attachments. > > Above are my test results after the fix, and I didn't notice any new commit > introduced to dev-lang/zig-0.11.0 since then. So I guess the issue is still > here. Hello, and thanks again. Sentence with "portage commit" confused me a little, do you refer to main repository? If yes: seems like new fix was included before this commit. https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=08419414eebb1bb26e9e72cffb66ce81a0e64751 commit with fix; IIUC you refer to this? https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=54b20cb55a644f07faa7f426118e4ff9b6c4d8e9 . It contains two new commits for zig package. You can verify if new patch is here by checking whether dev-lang/zig-9999 has new `llvm` use flag in your tree.
(In reply to Eric Joldasov from comment #16) > Hello, and thanks again. Sentence with "portage commit" confused me a > little, do you refer to main repository? If yes: seems like new fix was > included before this commit. > > https://gitweb.gentoo.org/repo/gentoo.git/commit/ > ?id=08419414eebb1bb26e9e72cffb66ce81a0e64751 commit with fix; IIUC you refer > to this? > https://gitweb.gentoo.org/repo/gentoo.git/commit/ > ?id=54b20cb55a644f07faa7f426118e4ff9b6c4d8e9 . It contains two new commits > for zig package. You can verify if new patch is here by checking whether > dev-lang/zig-9999 has new `llvm` use flag in your tree. Yes, I was using https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=54b20cb55a644f07faa7f426118e4ff9b6c4d8e9 which contains the two new commits, and I also confirms that dev-lang/zig-9999 has new `llvm` use flag in my tree.