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

lld-link error with Zig 0.8.0 on Windows, undefined symbols '_fseeki64' and '_ftelli64' #9402

Closed
foxnne opened this issue Jul 17, 2021 · 3 comments · Fixed by #9766
Closed
Labels
bug Observed behavior contradicts documented or intended behavior os-windows
Milestone

Comments

@foxnne
Copy link
Sponsor

foxnne commented Jul 17, 2021

I'm trying to build this library: zip and prior to 0.8.0 I had no issues, but since I get the following errors on the same system:

lld-link: error: undefined symbol: __declspec(dllimport) _fseeki64
>>> referenced by C:\Users\tiltf\dev\proj\pixi\src\deps\upaya\src\deps\zip\zip\src\zip.c
>>>               C:\Users\tiltf\dev\proj\pixi\zig-cache\o\0089258faf0b49636b95f3ebd593c111\zip.obj

lld-link: error: undefined symbol: __declspec(dllimport) _ftelli64
>>> referenced by C:\Users\tiltf\dev\proj\pixi\src\deps\upaya\src\deps\zip\zip\src\zip.c
>>>               C:\Users\tiltf\dev\proj\pixi\zig-cache\o\0089258faf0b49636b95f3ebd593c111\zip.obj
error: LLDReportedFailure

This is the project if its relevant: pixi

These errors happen regardless of if the project was built using -Dtarget=native-native-msvc or not.

Any information would be amazing! Thanks

@Vexu Vexu added bug Observed behavior contradicts documented or intended behavior os-windows labels Aug 6, 2021
@Vexu Vexu added this to the 0.10.0 milestone Aug 6, 2021
@aicarambazigalo
Copy link

aicarambazigalo commented Aug 31, 2021

here's some info, apparently (I haven't tested): https://github.com/kuba--/zip/issues/193#issuecomment-866678569
(edit: ok i've tested, it seemed to have worked, but still getting some unrelated compilation errors, so couldn't runtime test it)

@MasterQ32
Copy link
Contributor

MasterQ32 commented Sep 11, 2021

This is definitly a bug in the mingw64-distribution of zig. My minimal reproduction to come to this conclusion is:

  1. create main.c (see below)
  2. compile executable with mingw64 v8.0.0
    • docker run --rm -ti -v `pwd`:/mnt mmozeiko/mingw-w64 x86_64-w64-mingw32-gcc -O2 main.c
  3. compile executable with zig
    • zig build-exe -lc -target x86_64-windows-gnu main.c
    • zig cc -lc -target x86_64-windows-gnu main.c

Step 2 will compile just fine (verified with wine64), step 3 will fail with

[felix@denkplatte-v2 ftelli64]$ zig build-exe -lc -target x86_64-windows-gnu main.c
lld-link: error: undefined symbol: __declspec(dllimport) _fseeki64
>>> referenced by /home/felix/projects/experiments/ftelli64/main.c:5
>>>               /home/felix/.cache/zig/o/8e813e8c453fb18e5207eaa1df3543b7/main.obj:(main)

lld-link: error: undefined symbol: __declspec(dllimport) _ftelli64
>>> referenced by /home/felix/projects/experiments/ftelli64/main.c:6
>>>               /home/felix/.cache/zig/o/8e813e8c453fb18e5207eaa1df3543b7/main.obj:(main)
thread 9568 panic: attempt to unwrap error: LLDReportedFailure

or

[felix@denkplatte-v2 ftelli64]$ zig cc -lc -target x86_64-windows-gnu main.c
lld-link: error: undefined symbol: __declspec(dllimport) _fseeki64
>>> referenced by /home/felix/.cache/zig/o/3ade1f56a9fc259cc21654390898a457/main.obj:(main)

lld-link: error: undefined symbol: __declspec(dllimport) _ftelli64
>>> referenced by /home/felix/.cache/zig/o/3ade1f56a9fc259cc21654390898a457/main.obj:(main)
exit code: 1

main.c looks like this:

#include <stdio.h>

int main(int argc, char ** argv) {
  FILE * f = fopen(argv[0], "rb");
  _fseeki64(f, 10, SEEK_SET);
  __int64 pos = _ftelli64(f);
  fclose(f);
  printf("offset = %lld\n", pos);
  return 0;
}

This behaviour is also broken on current master (0.9.0-dev.952+0c091feb5)

@michal-z
Copy link
Contributor

The problem is that mingw64-distrbution of zig does not include mingw-w64-crt/stdio/fseeki64.c file. Implementation of _ftelli64 and _fseeki64 is there.

michal-z added a commit to michal-z/zig that referenced this issue Sep 14, 2021
andrewrk pushed a commit that referenced this issue Sep 15, 2021
…#9402). (#9766)

* Added fseeki64.c from mingw-w64 9.0.0. This file was missing in Zig distribution. This file contains implementation for _fseeki64 and _ftelli64 functions.
@andrewrk andrewrk modified the milestones: 0.10.0, 0.9.0 Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior os-windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants