-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
glibc undefined symbol: fcntl64 when using zig cc as a drop-in compiler #5882
Comments
In particular, I'm confused by |
Hmm that is indeed confusing. I think the next step towards troubleshooting this would be to hop into one of the LLVM chat rooms and ask LLD developers if they know why this could happen. |
One work around would be to try musl libc instead of glibc: |
This is the same problem I was running into here luvit/luvi#231 (comment):
Targeting musl should work unless you need dynamic loading (luvit/luvi#231 (comment)). |
@squeek502 yep, you're right that I missed your comment in the luvi repo. This is the exact same issue! I guess it's something in libuv that's causing the problem since I don't have luajit at all in this project. I tried |
Just a thought, maybe |
As in #6036, could you try using a newer glibc version as part of your target? |
Using c library triggers this errors, either as built.zig or in build-exe
main.zig
addition to init-exe generated build.zig
|
cross build libuv for linux on macos, failed with
|
After read how-to-force-linkage-to-older-libc-fcntl-instead-of-fcntl64, I found an alternative way to build libuv with make a fcntl.map file
And update use If x86_64-linux-gnu version below 2.17, maybe need more glibc api map, and I have not test that. aarch64-linux-gnu not pass, because has no fcntl@GLIBC_2.2.5 |
I've just bumped into this issue too, when compiling a native C project that extensively uses linker scripts for both visibility and versioning of symbols. A quick web search brings me to this issue, root cause was the |
can confirm this works if you add the
edit: |
I have the same problem building sqlite3 amalgamation (3.36.0) for glibc 2.27 or older:
I cannot use older glibc version, because some production hosts run 2.24; I also cannot use the musl target, because some applications expose NSS symbols, thus must be linked against glibc (vaguely mentioned in https://eng.uber.com/hadoop-container-blog/). Suggestion by @zhaozg (above) works! But ... is there a way to pass the asm line in a cflag directive instead of patching the source? In our case, sqlite is a dependency of a dependency, so even creating a patch is non-trivial to begin with, let alone maintain it during upgrades. |
Following @zhaozg 's suggestion I found a slightly different approach that does not require changing the source files: fcntl.h
fcntl.map
Compile command:
|
I created #9485, which captures the problem with a very small C file. |
Also ran into this compiling https://github.com/vrischmann/zig-sqlite with the included Both target suggestions above worked for me:
and
The error (might help someone else searching for this issue):
|
I stumbled upon this issue while trying to use the sqlite library. To add to the stopgap solutions provided above, here are some snippets for let's say there is a library
and for tests:
maybe these snippets help someone until a more automatic solution arrives... |
This commit upgrades glibc shared library stub-creating code to use the new abilists file which is generated by the new glibc-abi-tool project: https://github.com/ziglang/glibc-abi-tool/ The abilists file is different in these ways: * It additionally encodes whether a symbol is a function or an object, and if it is an object, it additionally encodes the size in bytes. * It additionally encodes migrations of symbols from one library to another between glibc versions. * It is binary data instead of ascii. * It is one file instead of three. * It is 165 KB instead of 200 KB. This solves a handful of bugs. Fixes #5882 Fixes #7667 Fixes #8714 Fixes #8896
Closing as a duplicate of #9485 since that one has a minimal reproduction test case. |
Note to followers of this issue: |
I had the same problem using raylib. "C:\Program Files\zig\zig.exe" run C:/Users/userName/IdeaProjects/new_/main.zig
error: lld-link: undefined symbol: InitWindow
note: referenced by C:\Users\userName\IdeaProjects\new_\main.zig:18
note: C:\Users\userName\AppData\Local\zig\o\f59599752f0cead73359b7fdc6eb46c9\main.exe.obj:(main.main)
error: lld-link: undefined symbol: SetTargetFPS
note: referenced by C:\Users\userName\IdeaProjects\new_\main.zig:19
note: C:\Users\userName\AppData\Local\zig\o\f59599752f0cead73359b7fdc6eb46c9\main.exe.obj:(main.main)
error: lld-link: undefined symbol: CloseWindow
note: referenced by C:\Users\userName\IdeaProjects\new_\main.zig:20
note: C:\Users\userName\AppData\Local\zig\o\f59599752f0cead73359b7fdc6eb46c9\main.exe.obj:(main.main)
error: lld-link: undefined symbol: WindowShouldClose
note: referenced by C:\Users\userName\IdeaProjects\new_\main.zig:21
note: C:\Users\userName\AppData\Local\zig\o\f59599752f0cead73359b7fdc6eb46c9\main.exe.obj:(main.main)
error: lld-link: undefined symbol: BeginDrawing
note: referenced by C:\Users\userName\IdeaProjects\new_\main.zig:22
note: C:\Users\userName\AppData\Local\zig\o\f59599752f0cead73359b7fdc6eb46c9\main.exe.obj:(main.main)
error: lld-link: undefined symbol: ClearBackground
note: referenced by C:\Users\userName\IdeaProjects\new_\main.zig:24
note: C:\Users\userName\AppData\Local\zig\o\f59599752f0cead73359b7fdc6eb46c9\main.exe.obj:(main.main)
error: lld-link: undefined symbol: DrawText
note: referenced by C:\Users\userName\IdeaProjects\new_\main.zig:25
note: C:\Users\userName\AppData\Local\zig\o\f59599752f0cead73359b7fdc6eb46c9\main.exe.obj:(main.main)
error: lld-link: undefined symbol: EndDrawing
note: referenced by C:\Users\userName\IdeaProjects\new_\main.zig:23
note: C:\Users\userName\AppData\Local\zig\o\f59599752f0cead73359b7fdc6eb46c9\main.exe.obj:(main.main) |
I'm trying to build a small test application with libuv embedded. I want to use zig cc because the caching system makes it much faster. The following command works for clang and gcc, but not zig cc.
Is there something special I need to pass in for this to build?
The text was updated successfully, but these errors were encountered: