floooh / sokol-zig

Zig bindings for the sokol headers (https://github.com/floooh/sokol)
zlib License
355 stars 49 forks source link

Compilation fails on macOS #5

Closed frarees closed 3 years ago

frarees commented 3 years ago

zig 0.8.0-dev.1039+bea791b63 macOS 11.1 (Big Sur) Xcode 12.3

frarees@MBP18 sokol-zig % zig build run-triangle
error(compilation): clang failed with stderr: In file included from /Users/frarees/Documents/sokol-zig/src/sokol/c/sokol_audio.c:5:
In file included from /Users/frarees/Documents/sokol-zig/src/sokol/c/sokol_audio.h:511:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioToolbox.h:19:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AUGraph.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioUnit.h:21:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioUnitProperties.h:55:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup.h:30:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_object.h:48:19: error: a parameter list without types is only allowed in a function definition
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_object.h:93:24: error: unknown type name 'os_workgroup_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_object.h:116:1: error: unknown type name 'os_workgroup_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_object.h:116:16: error: nullability specifier '_Nullable' cannot be applied to non-pointer type 'int'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_object.h:137:1: error: unknown type name 'os_workgroup_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_object.h:138:65: error: unknown type name 'os_workgroup_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_object.h:137:16: error: nullability specifier '_Nullable' cannot be applied to non-pointer type 'int'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_object.h:177:19: error: unknown type name 'os_workgroup_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_object.h:202:20: error: unknown type name 'os_workgroup_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_object.h:241:32: error: unknown type name 'os_workgroup_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_object.h:271:32: error: unknown type name 'os_workgroup_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_object.h:299:21: error: unknown type name 'os_workgroup_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_object.h:311:25: error: unknown type name 'os_workgroup_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_object.h:350:35: error: unknown type name 'os_workgroup_t'
In file included from /Users/frarees/Documents/sokol-zig/src/sokol/c/sokol_audio.c:5:
In file included from /Users/frarees/Documents/sokol-zig/src/sokol/c/sokol_audio.h:511:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioToolbox.h:19:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AUGraph.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioUnit.h:21:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioUnitProperties.h:55:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup.h:31:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_interval.h:41:28: error: redefinition of parameter 'os_workgroup_interval'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_interval.h:41:28: error: a parameter list without types is only allowed in a function definition
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_interval.h:94:29: error: unknown type name 'os_workgroup_interval_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_interval.h:123:30: error: unknown type name 'os_workgroup_interval_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_interval.h:148:30: error: unknown type name 'os_workgroup_interval_t'
fatal error: too many errors emitted, stopping now [-ferror-limit=]

/Users/frarees/Documents/sokol-zig/src/sokol/c/sokol_audio.c:1:1: error: unable to build C object: clang exited with code 1
sokol...The following command exited with error code 1:
/Users/frarees/Documents/zig/build/bin/zig build-lib -lc -cflags -ObjC -DIMPL -- /Users/frarees/Documents/sokol-zig/src/sokol/c/sokol_app_gfx.c -cflags -ObjC -DIMPL -- /Users/frarees/Documents/sokol-zig/src/sokol/c/sokol_time.c -cflags -ObjC -DIMPL -- /Users/frarees/Documents/sokol-zig/src/sokol/c/sokol_audio.c -cflags -ObjC -DIMPL -- /Users/frarees/Documents/sokol-zig/src/sokol/c/sokol_gl.c -cflags -ObjC -DIMPL -- /Users/frarees/Documents/sokol-zig/src/sokol/c/sokol_debugtext.c -cflags -ObjC -DIMPL -- /Users/frarees/Documents/sokol-zig/src/sokol/c/sokol_shape.c --cache-dir /Users/frarees/Documents/sokol-zig/zig-cache --global-cache-dir /Users/frarees/.cache/zig --name sokol -I /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -F /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks -framework Cocoa -framework AudioToolbox -framework QuartzCore -framework MetalKit -framework Metal --enable-cache 
error: the following build command failed with exit code 1:
/Users/frarees/Documents/sokol-zig/zig-cache/o/adc71d1a5b6b66a2383e69b42697249b/build /Users/frarees/Documents/zig/build/bin/zig /Users/frarees/Documents/sokol-zig /Users/frarees/Documents/sokol-zig/zig-cache /Users/frarees/.cache/zig run-triangle
frarees@MBP18 sokol-zig % /Users/frarees/Documents/zig/build/bin/zig build-lib -lc -cflags -ObjC -DIMPL -- /Users/frarees/Documents/sokol-zig/src/sokol/c/sokol_app_gfx.c -cflags -ObjC -DIMPL -- /Users/frarees/Documents/sokol-zig/src/sokol/c/sokol_time.c -cflags -ObjC -DIMPL -- /Users/frarees/Documents/sokol-zig/src/sokol/c/sokol_audio.c -cflags -ObjC -DIMPL -- /Users/frarees/Documents/sokol-zig/src/sokol/c/sokol_gl.c -cflags -ObjC -DIMPL -- /Users/frarees/Documents/sokol-zig/src/sokol/c/sokol_debugtext.c -cflags -ObjC -DIMPL -- /Users/frarees/Documents/sokol-zig/src/sokol/c/sokol_shape.c --cache-dir /Users/frarees/Documents/sokol-zig/zig-cache --global-cache-dir /Users/frarees/.cache/zig --name sokol -I /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -F /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks -framework Cocoa -framework AudioToolbox -framework QuartzCore -framework MetalKit -framework Metal --enable-cache

error(compilation): clang failed with stderr: In file included from /Users/frarees/Documents/sokol-zig/src/sokol/c/sokol_audio.c:5:
In file included from /Users/frarees/Documents/sokol-zig/src/sokol/c/sokol_audio.h:511:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioToolbox.h:19:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AUGraph.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioUnit.h:21:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioUnitProperties.h:55:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup.h:30:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_object.h:48:19: error: a parameter list without types is only allowed in a function definition
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_object.h:93:24: error: unknown type name 'os_workgroup_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_object.h:116:1: error: unknown type name 'os_workgroup_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_object.h:116:16: error: nullability specifier '_Nullable' cannot be applied to non-pointer type 'int'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_object.h:137:1: error: unknown type name 'os_workgroup_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_object.h:138:65: error: unknown type name 'os_workgroup_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_object.h:137:16: error: nullability specifier '_Nullable' cannot be applied to non-pointer type 'int'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_object.h:177:19: error: unknown type name 'os_workgroup_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_object.h:202:20: error: unknown type name 'os_workgroup_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_object.h:241:32: error: unknown type name 'os_workgroup_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_object.h:271:32: error: unknown type name 'os_workgroup_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_object.h:299:21: error: unknown type name 'os_workgroup_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_object.h:311:25: error: unknown type name 'os_workgroup_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_object.h:350:35: error: unknown type name 'os_workgroup_t'
In file included from /Users/frarees/Documents/sokol-zig/src/sokol/c/sokol_audio.c:5:
In file included from /Users/frarees/Documents/sokol-zig/src/sokol/c/sokol_audio.h:511:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioToolbox.h:19:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AUGraph.h:30:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioUnit.h:21:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/AudioToolbox.framework/Headers/AudioUnitProperties.h:55:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup.h:31:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_interval.h:41:28: error: redefinition of parameter 'os_workgroup_interval'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_interval.h:41:28: error: a parameter list without types is only allowed in a function definition
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_interval.h:94:29: error: unknown type name 'os_workgroup_interval_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_interval.h:123:30: error: unknown type name 'os_workgroup_interval_t'
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/os/workgroup_interval.h:148:30: error: unknown type name 'os_workgroup_interval_t'
fatal error: too many errors emitted, stopping now [-ferror-limit=]

/Users/frarees/Documents/sokol-zig/src/sokol/c/sokol_audio.c:1:1: error: unable to build C object: clang exited with code 1
floooh commented 3 years ago

Yeah I can reproduce. It works with zig 7.1, but is broken in 8.0.

See this issue: https://github.com/ziglang/zig/issues/7697

I was hoping that it's enough to remove the current header-search-path hacks in build.zig, but this didn't fix the issue, so currently I'm not entirely sure if the bug is actually fixed (I haven't spend much time with it yet though, for now I reverted to 7.1).

floooh commented 3 years ago

This should be fixed now in the branch zig-0.8.0 (the master branch works with 0.7.1, and once 0.8.0 becomes the new official stable version, I'll update the master branch).

Technically there's still an issue regarding macOS system- vs C-runtime-headers (see: https://github.com/ziglang/zig/issues/8360) but I added a workaround to sokol_audio.h (I don't include the CoreAudio system headers now, but instead embed the required declarations directly in the sokol_audio.h header).