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 linker error when library specified by extern declaration is not found #19815
Comments
I'm pretty sure the library name (after |
Don't know if it actually is case sensitive, but even if it were, the llvm backend wouldn't crash. Regardless i tested with extern "c" all of the examples above and I get the same results. |
@Vexu I think you may have misunderstood, it's a bug not a weird error message. This function declaration exists, you can call it and it works like any other function when using the LLVM backend. It's just that when you use the self-hosted backend it doesn't compile giving this error message. But the expected behaviour should be that the program compiles and runs normally. |
I was testing with a release build of Zig, when using a debug build it panics if the library is not specified on the command line. I am able to build it with the self-hosted backend when using Stack trace
|
I tried it too with the 0.12.0 version but I'm getting different results. Using I also tried to omit the library in the command line and it doesn't crash, but it gives the FileNotFound error, which I guess has to be expected since I told him not to look for libomp. Weirdly enough if I omit only
|
Zig Version
0.12.0
Steps to Reproduce and Observed Behavior
I tried to use a function that's not accessible through the
omp.h
header ( or any other accessible header file for that matter ) that is declared here __kmpc_push_proc_bind(). I have rewritten in zig the function declaration, like when doing binary patching, and I get an error when using the self-hosted linker.Command :
zig build-exe repro.zig -fno-llvm -fno-lld -lc -lomp
Result:
error: unexpected error: parsing library failed with error FileNotFound
note: while parsing
Command :
zig build-exe repro.zig -fllvm -fno-lld -lc -lomp
Result:
error: unexpected error: parsing library failed with error FileNotFound
note: while parsing
When using the llvm backend normally it compiles
Command :
zig build-exe repro.zig -lc -lomp
Result: no error
This doesn't happen if I try to call a function using
@cImport("omp.h");
, like for exampleI haven't tested with other libraries if I can replicate the same result and this was tested with llvm version of openmp, not the gnu one.
Expected Behavior
They both compile.
The text was updated successfully, but these errors were encountered: