Skip to content
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

confusing error message when older glibc version does not contain needed symbol #6036

Open
fengb opened this issue Aug 11, 2020 · 5 comments
Labels
contributor friendly This issue is limited in scope and/or knowledge of Zig internals. enhancement Solving this issue will likely involve adding new logic or components to the codebase. upstream An issue with a third party project that Zig uses.
Milestone

Comments

@fengb
Copy link
Contributor

fengb commented Aug 11, 2020

This only happens when using linux-gnu as the target, linux-musl and native macos seem to work just fine:

// https://godbolt.org/z/eef9ro

const c = @cImport({
    @cInclude("unistd.h");
});

pub fn main() void {
    var buf: [100]u8 = undefined;
    _ = getentropy(&buf, 100);
}

The error message is extra confusing as it seems to ignore the defined symbol?

$ zig build-exe entropy.zig  -target x86_64-linux-gnu -lc
lld: error: undefined symbol: getentropy
>>> referenced by entropy.zig:7 (<source>:7)
>>>               ./output.s.o:(main.0)
>>> did you mean: getentropy
>>> defined in: ~/.cache/zig/stage1/h/3B3uryfs1rNlgbc_ZR0H2oqWZpNC9zRda78zj4AcDQhfg-i4ffjBlY2FFb-5kMPI/libc.so.6.0.0```
@daurnimator
Copy link
Contributor

Someone on discord reported the same issue; I think the fix was using a newer version of glibc as part of the target?

The error message reminds me of #5882

@fengb
Copy link
Contributor Author

fengb commented Aug 12, 2020

Aha! -target x86_64-linux-gnu.2.25 works fine. I think the major problem in this case is that while Zig detects the version does not contain the symbol, the generated error message makes no sense. Is this because we have a merged glibc and thus the symbol actually exists?

@andrewrk
Copy link
Member

andrewrk commented Aug 12, 2020

what version is your native system glibc?

@fengb
Copy link
Contributor Author

fengb commented Aug 12, 2020

I had errors in cross compilation. Native (glibc 2.31) seemed to work fine, although the reported version is a bit confused:

 "native": {
  "triple": "x86_64-linux.5.7.7...5.7.7-gnu.2.17",

@andrewrk andrewrk changed the title glibc cannot find getentropy confusing error message when older glibc version does not contain needed symbol Oct 4, 2020
@andrewrk andrewrk added enhancement Solving this issue will likely involve adding new logic or components to the codebase. upstream An issue with a third party project that Zig uses. labels Oct 4, 2020
@andrewrk andrewrk added this to the 0.8.0 milestone Oct 4, 2020
@andrewrk andrewrk added the contributor friendly This issue is limited in scope and/or knowledge of Zig internals. label Oct 4, 2020
@andrewrk
Copy link
Member

andrewrk commented Oct 4, 2020

although the reported version is a bit confused

covered by #6469

@andrewrk andrewrk modified the milestones: 0.8.0, 0.9.0 Nov 6, 2020
@andrewrk andrewrk modified the milestones: 0.9.0, 0.10.0 May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor friendly This issue is limited in scope and/or knowledge of Zig internals. enhancement Solving this issue will likely involve adding new logic or components to the codebase. upstream An issue with a third party project that Zig uses.
Projects
None yet
Development

No branches or pull requests

3 participants