kassane / sokol-d

D bindings for the sokol headers (https://github.com/floooh/sokol)
http://sokol-d.dub.pm/
zlib License
11 stars 5 forks source link

Windows-msvc: undefined identifier & symbol #9

Closed kassane closed 10 months ago

kassane commented 10 months ago

zig (v0.12.0/master) changes broken windows-build

commit: https://github.com/kassane/sokol-d/commit/c8f10530339fcd16cee7e927f7177255877f9f06 | https://github.com/kassane/sokol-d/actions/runs/7425932473/job/20208599249#step:6:1

previous (no error): https://github.com/kassane/sokol-d/actions/runs/7401550409/job/20137535727#step:6:1 (0.12.0-dev.1879+e19219fa0)

Errors

verbose output: https://github.com/kassane/sokol-d/actions/runs/7432883556/job/20225206794#step:6:40

C:\hostedtoolcache\windows\dc\ldc2-530d41be\x64\ldc2-530d41be-windows-multilib\bin\..\import\core\stdc\wchar_.d(172,9): Error: undefined identifier `FILE`
    int fwprintf(FILE* stream, const scope wchar_t* format, scope const ...);
        ^
C:\hostedtoolcache\windows\dc\ldc2-530d41be\x64\ldc2-530d41be-windows-multilib\bin\..\import\core\stdc\wchar_.d(174,9): Error: undefined identifier `FILE`
    int fwscanf(FILE* stream, const scope wchar_t* format, scope ...);
        ^
C:\hostedtoolcache\windows\dc\ldc2-530d41be\x64\ldc2-530d41be-windows-multilib\bin\..\import\core\stdc\wchar_.d(180,9): Error: undefined identifier `FILE`
    int vfwprintf(FILE* stream, const scope wchar_t* format, va_list arg);
        ^
C:\hostedtoolcache\windows\dc\ldc2-530d41be\x64\ldc2-530d41be-windows-multilib\bin\..\import\core\stdc\wchar_.d(182,9): Error: undefined identifier `FILE`
    int vfwscanf(FILE* stream, const scope wchar_t* format, va_list arg);
        ^
C:\hostedtoolcache\windows\dc\ldc2-530d41be\x64\ldc2-530d41be-windows-multilib\bin\..\import\core\stdc\wchar_.d(201,12): Error: undefined identifier `FILE`
    wint_t fgetwc(FILE* stream);
           ^
C:\hostedtoolcache\windows\dc\ldc2-530d41be\x64\ldc2-530d41be-windows-multilib\bin\..\import\core\stdc\wchar_.d(203,12): Error: undefined identifier `FILE`
    wint_t fputwc(wchar_t c, FILE* stream);
           ^
[...]

BetterC

_D4core8internal5array11duplication__T8_dupCtfeTxaTaZQpFNaNbNiNfMAxaZAa: pure nothrow @nogc @trusted immutable(char)[] core.internal.array.duplication._dup!(char, immutable(char))._dup(scope char[])

verbose output: https://github.com/kassane/sokol-d/actions/runs/7432883556/job/20225206794#step:6:119

lld-link: error: undefined symbol: __main
>>> referenced by D:\a\sokol-d\sokol-d\zig-cache\o\8441520852fd3bf30fcee699975c9b06\sgl_context.o:(main)

lld-link: error: undefined symbol: _D4core8internal5array11duplication__T8_dupCtfeTxaTaZQpFNaNbNiNfMAxaZAa
>>> referenced by D:\a\sokol-d\sokol-d\zig-cache\o\8441520852fd3bf30fcee699975c9b06\sgl_context.o:(_D4core8internal5array11duplication__T4_dupTxaTaZQlFNaNbNiNeMAxaZAa)

lld-link: error: undefined symbol: __assert
>>> referenced by D:\a\sokol-d\sokol-d\zig-cache\o\8441520852fd3bf30fcee699975c9b06\sgl_context.o:(_D4core8internal5array9appending__T17_d_arrayappendcTXHTAaTaZQBaFNaNbNcNiNeMNkKQxmZQBb)
>>> referenced by D:\a\sokol-d\sokol-d\zig-cache\o\8441520852fd3bf30fcee699975c9b06\sgl_context.o:(_D4core8internal5array9appending__T17_d_arrayappendcTXHTAyaTyaZQBcFNaNbNcNiNeMNkKQzmZQBd)

lld-link: error: undefined symbol: _D4core8internal5array11duplication__T8_dupCtfeTaTyaZQpFNaNbNiNfMAaZAya
>>> referenced by D:\a\sokol-d\sokol-d\zig-cache\o\8441520852fd3bf30fcee699975c9b06\sgl_context.o:(_D4core8internal5array11duplication__T4_dupTaTyaZQlFNaNbNiNeMAaZAya)
kassane commented 10 months ago

cause: --mtriple=x86_64-windows-gnu on commands (not changing windows abi) https://github.com/kassane/sokol-d/blob/1b0c50b0150f40ed63242db19d6f9c35490c3fd2/build.zig#L187-L189 New targets commands from zig toolchain :roll_eyes:

new target structures: https://github.com/ziglang/zig/blob/42389cb9c58cfe71db055142eb7b8cc15193ddf9/lib/std/Build.zig#L2238-L2245

/// A pair of target query and fully resolved target.
/// This type is generally required by build system API that need to be given a
/// target. The query is kept because the Zig toolchain needs to know which parts
/// of the target are "native". This can apply to the CPU, the OS, or even the ABI.
pub const ResolvedTarget = struct {
    query: Target.Query,
    result: Target,
};
kassane commented 10 months ago

New errors

After, try fix windows target...

resume

lld-link: warning: sokol.lib(sokol_log.obj): locally defined symbol imported: __acrt_iob_func (defined in libucrtd.lib(_file.obj)) [LNK4217]
lld-link: warning: sokol.lib(sokol_app.obj): locally defined symbol imported: __acrt_iob_func (defined in libucrtd.lib(_file.obj)) [LNK4217]
lld-link: warning: sokol.lib(sokol_app.obj): locally defined symbol imported: freopen_s (defined in libucrtd.lib(freopen.obj)) [LNK4217]
lld-link: error: undefined symbol: __declspec(dllimport) _assert
>>> referenced by D:\a\sokol-d\sokol-d\src\sokol\c\sokol_app.h:11186
>>>               sokol.lib(sokol_app.obj):(sapp_run)
>>> referenced by D:\a\sokol-d\sokol-d\src\sokol\c\sokol_app.h:2874
>>>               sokol.lib(sokol_app.obj):(_sapp_clear)
>>> referenced by D:\a\sokol-d\sokol-d\src\sokol\c\sokol_app.h:11288
>>>               sokol.lib(sokol_app.obj):(sapp_egl_get_display)
>>> referenced 793 more times

lld-link: error: undefined symbol: __mingw_vsnprintf
>>> referenced by C:\hostedtoolcache\windows\zig\master\x64\lib\libc\include\any-windows-any\stdio.h:469
>>>               sokol.lib(sokol_debugtext.obj):(vsnprintf)
[...]
 lld-link: error: undefined symbol: __declspec(dllimport) freopen_s
>>> referenced by D:\a\sokol-d\sokol-d\src\sokol\c\sokol_app.h:7651
>>>               sokol.lib(sokol_app.obj):(_sapp_win32_init_console)
>>> referenced by D:\a\sokol-d\sokol-d\src\sokol\c\sokol_app.h:7653
>>>               sokol.lib(sokol_app.obj):(_sapp_win32_init_console)
kassane commented 10 months ago

New errors

lld-link: warning: sokol.lib(sokol_log.obj): locally defined symbol imported: __acrt_iob_func (defined in libucrtd.lib(_file.obj)) [LNK4217]
lld-link: warning: sokol.lib(sokol_app.obj): locally defined symbol imported: __acrt_iob_func (defined in libucrtd.lib(_file.obj)) [LNK4217]
lld-link: warning: sokol.lib(sokol_app.obj): locally defined symbol imported: freopen_s (defined in libucrtd.lib(freopen.obj)) [LNK4217]
lld-link: error: undefined symbol: __declspec(dllimport) _assert
>>> referenced by D:\a\sokol-d\sokol-d\src\sokol\c\sokol_app.h:11186
>>>               sokol.lib(sokol_app.obj):(sapp_run)
>>> referenced by D:\a\sokol-d\sokol-d\src\sokol\c\sokol_app.h:2874
>>>               sokol.lib(sokol_app.obj):(_sapp_clear)
>>> referenced by D:\a\sokol-d\sokol-d\src\sokol\c\sokol_app.h:11288
>>>               sokol.lib(sokol_app.obj):(sapp_egl_get_display)
>>> referenced 793 more times

lld-link: error: undefined symbol: __mingw_vsnprintf
>>> referenced by C:\hostedtoolcache\windows\zig\master\x64\lib\libc\include\any-windows-any\stdio.h:469
>>>               sokol.lib(sokol_debugtext.obj):(vsnprintf)
[...]
 lld-link: error: undefined symbol: __declspec(dllimport) freopen_s
>>> referenced by D:\a\sokol-d\sokol-d\src\sokol\c\sokol_app.h:7651
>>>               sokol.lib(sokol_app.obj):(_sapp_win32_init_console)
>>> referenced by D:\a\sokol-d\sokol-d\src\sokol\c\sokol_app.h:7653
>>>               sokol.lib(sokol_app.obj):(_sapp_win32_init_console)

https://github.com/kassane/sokol-d/actions/runs/7433191327/job/20225900501#step:6:15

debug flags: zig cc /NOLOGO /DEBUG /OPT:REF /OPT:NOICF /DEFAULTLIB:libcmt /DEFAULTLIB:libvcruntime /OUT:D:\a\sokol-d\sokol-d\zig-out\bin\debugtext_print.exe D:\a\sokol-d\sokol-d\zig-cache\o\8441520852fd3bf30fcee699975c9b06\debugtext_print.obj C:/hostedtoolcache/windows/dc/ldc2-530d41be/x64/ldc2-530d41be-windows-multilib/bin/../lib64\ldc_rt.builtins.lib /LIBPATH:D:\a\sokol-d\sokol-d\zig-out\lib sokol.lib kernel32.lib user32.lib gdi32.lib ole32.lib d3d11.lib dxgi.lib /LIBPATH:C:/hostedtoolcache/windows/dc/ldc2-530d41be/x64/ldc2-530d41be-windows-multilib/bin/../lib64 kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib oldnames.lib legacy_stdio_definitions.lib -target native-native-msvc
lld-link: warning: sokol.lib(sokol_log.obj): locally defined symbol imported: __acrt_iob_func (defined in libucrtd.lib(_file.obj)) [LNK4217]

zigcc wrapper had used -target native-native-msvc!!

Need zig downgrade? :roll_eyes:

kassane commented 10 months ago

Fixed: https://github.com/kassane/sokol-d/commit/07100713a22c0858093e1fe1438a557991b5b0e0