Was "Undefined symbol 'errno' when linking with wasi-libc", and in particular see bug #2228297 comment #3. +++ This bug was initially created as a clone of Bug #2228297 +++ Using the following simple reproducer and linking against the Fedora 38 wasm32-wasi-static libs results in a linker error $ cat e.c #include <errno.h> int main(void) { errno = 0; return errno; } $ clang --target=wasm32-wasi --sysroot=/usr/wasm32-wasi -o e.wasm e.c wasm-ld: error: /tmp/e-78d8d7.o: undefined symbol: errno wasm-ld: error: /tmp/e-78d8d7.o: undefined symbol: errno clang-16: error: linker command failed with exit code 1 (use -v to see invocation) However doing the same with the wasi-sysroot v20.0 tarball from https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sysroot-20.0.tar.gz works fine $ clang --target=wasm32-wasi --sysroot=/tmp/wasi-sysroot -o e.wasm e.c $ Reproducible: Always Steps to Reproduce: 1. Try to compile and link the above program Actual Results: Linker error wasm-ld: error: /tmp/e-78d8d7.o: undefined symbol: errno wasm-ld: error: /tmp/e-78d8d7.o: undefined symbol: errno clang-16: error: linker command failed with exit code 1 (use -v to see invocation) Expected Results: Successful compilation/linking. --- Additional comment from Andrew Clayton on 2023-08-01 18:37:09 PDT --- Forgot to add that looking for the errno definition in the libraries (with llvm-nm), from the the wasi-sysroot v20.0 tarball pulled from GitHub we see errno.o: 00000000 D errno in libc.a whereas in the libc.a from the Fedora 38 wasm32-wasi-static package we see errno.o: 00000000 D __EINVAL 00000004 D __ENOMEM and I only see references to 'U errno' and no 'D errno' in any of the packaged libraries/objects. --- Additional comment from Josh Stone on 2023-08-09 11:05:51 PDT --- That's curious. In wasm32-wasi-static's libc.a, I see *two* entries that look like: errno.o: 00000000 D __EINVAL 00000004 D __ENOMEM Whereas in rust-std-static-wasm32-wasi, which still bundles its own copy, there is one entry like that, and another with "D errno". (They only other difference in those libc.a symbols is having dlmalloc.o vs. emmalloc.o) --- Additional comment from Josh Stone on 2023-08-09 11:22:27 PDT --- There are two separate errno.c sources that create errno.o objects in libc.a: libc-bottom-half/cloudlibc/src/libc/errno/errno.c (errno) libc-bottom-half/sources/errno.c (__EINVAL and __ENOMEM) However, "%global toolchain clang" enables the post-install /usr/lib/rpm/redhat/brp-llvm-compile-lto-elf, which unpacks the archive (ar x), looks for LLVM bitcode to compile in each object, and then re-packs them (ar r). So with two errno.o, the second overwrites the first while unpacking, and then that's also written on top of the first in the archive when repacking. I think we could undefine %__brp_llvm_compile_lto_elf (or redefine it to %{nil}) to skip that step. --- Additional comment from Andrew Clayton on 2023-08-11 08:00:22 PDT --- Sounds good. Happy to test any new builds... --- Additional comment from Jan Staněk on 2023-08-14 02:26:25 PDT --- Thanks both of you for the report and the suggested fix, it now works on my machine :) Update should follow shortly. --- Additional comment from Fedora Update System on 2023-08-14 02:44:06 PDT --- FEDORA-2023-d36d498dc0 has been submitted as an update to Fedora 40. https://bodhi.fedoraproject.org/updates/FEDORA-2023-d36d498dc0 --- Additional comment from Fedora Update System on 2023-08-14 02:45:37 PDT --- FEDORA-2023-d36d498dc0 has been pushed to the Fedora 40 stable repository. If problem still persists, please make note of it in this bug report. --- Additional comment from Jan Staněk on 2023-08-14 03:08:53 PDT --- Note: I have trouble building this for F38 ATM, seems something is broken in koji: https://koji.fedoraproject.org/koji/taskinfo?taskID=104820303. The builds will be incoming once that is resolved. --- Additional comment from Fedora Update System on 2023-08-16 02:51:32 PDT --- FEDORA-2023-1276d16f5b has been submitted as an update to Fedora 39. https://bodhi.fedoraproject.org/updates/FEDORA-2023-1276d16f5b --- Additional comment from Fedora Update System on 2023-08-16 02:54:37 PDT --- FEDORA-2023-1276d16f5b has been pushed to the Fedora 39 stable repository. If problem still persists, please make note of it in this bug report.
Fedora Linux 38 entered end-of-life (EOL) status on 2024-05-21. Fedora Linux 38 is no longer maintained, which means that it will not receive any further security or bug fix updates. As a result we are closing this bug. If you can reproduce this bug against a currently maintained version of Fedora Linux please feel free to reopen this bug against that version. Note that the version field may be hidden. Click the "Show advanced fields" button if you do not see the version field. If you are unable to reopen this bug, please file a new report against an active release. Thank you for reporting this bug and we are sorry it could not be fixed.