floooh / sokol-nim

nim bindings for https://github.com/floooh/sokol
MIT License
76 stars 14 forks source link

MacOS 14.5 M3 compilation error #30

Closed Nazariglez closed 6 days ago

Nazariglez commented 1 week ago

Hello! I am leaving this here as we talked in twitter.

I am having some issues running the examples:

sokol-nim git:(master) nimble clear
  Verifying dependencies for sokol@0.5.0
  Executing task clear in /Users/nazariglez/personal/sokol-nim/sokol.nimble
Hint: used config file '/opt/homebrew/Cellar/nim/2.0.6/nim/config/nim.cfg' [Conf]
Hint: used config file '/opt/homebrew/Cellar/nim/2.0.6/nim/config/config.nims' [Conf]
..........................................................................
CC: sokol_app
CC: sokol_gfx
In file included from /Users/nazariglez/.nimble/pkgs2/sokol-0.5.0-a18f55ac213f621e6431a7f2a5e029e45fa9b89e/sokol/c/sokol_app.c:6:
In file included from /Users/nazariglez/.nimble/pkgs2/sokol-0.5.0-a18f55ac213f621e6431a7f2a5e029e45fa9b89e/sokol/c/sokol_app.h:2056:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.h:9:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLTypes.h:8:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:9:
/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:615:74: error: unknown type name 'NSUInteger'
FOUNDATION_EXPORT const char *NSGetSizeAndAlignment(const char *typePtr, NSUInteger * _Nullable sizep, NSUInteger * _Nullable alignp);
                                                                         ^
In file included from /Users/nazariglez/.nimble/pkgs2/sokol-0.5.0-a18f55ac213f621e6431a7f2a5e029e45fa9b89e/sokol/c/sokol_gfx.c:5:
In file included from /Users/nazariglez/.nimble/pkgs2/sokol-0.5.0-a18f55ac213f621e6431a7f2a5e029e45fa9b89e/sokol/c/sokol_gfx.h:4473:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/System/Library/Frameworks/Metal.framework/Headers/Metal.h:9:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLTypes.h:8:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:9:
/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:615:74: error: unknown type name 'NSUInteger'
FOUNDATION_EXPORT const char *NSGetSizeAndAlignment(const char *typePtr, NSUInteger * _Nullable sizep, NSUInteger * _Nullable alignp);
                                                                         ^
/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:615:104: error: unknown type name 'NSUInteger'
FOUNDATION_EXPORT const char *NSGetSizeAndAlignment(const char *typePtr, NSUInteger * _Nullable sizep, NSUInteger * _Nullable alignp);
                                                                                                       ^
/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:615:104: error: unknown type name 'NSUInteger'
FOUNDATION_EXPORT const char *NSGetSizeAndAlignment(const char *typePtr, NSUInteger * _Nullable sizep, NSUInteger * _Nullable alignp);
                                                                                                       ^
/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:631:24: error: unknown type name 'NSInteger'
typedef NS_CLOSED_ENUM(NSInteger, NSComparisonResult) {
                       ^
/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:631:24: error: unknown type name 'NSInteger'
typedef NS_CLOSED_ENUM(NSInteger, NSComparisonResult) {
                       ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
fatal error: too many errors emitted, stopping now [-ferror-limit=]
4 errors generated.
Error: execution of an external compiler program 'clang -c  -w -ferror-limit=3 -pthread -DSOKOL_NIM_IMPL -x objective-c -DSOKOL_METAL   -I/opt/homebrew/Cellar/nim/2.0.6/nim/lib -I/Users/nazariglez/personal/sokol-nim/examples -o /Users/nazariglez/.cache/nim/clear_d/@m..@s..@s..@s.nimble@spkgs2@ssokol-0.5.0-a18f55ac213f621e6431a7f2a5e029e45fa9b89e@ssokol@sc@ssokol_gfx.c.o /Users/nazariglez/.nimble/pkgs2/sokol-0.5.0-a18f55ac213f621e6431a7f2a5e029e45fa9b89e/sokol/c/sokol_gfx.c' failed with exit code: 1

stack trace: (most recent call last)
/private/var/folders/zw/1nf4s1_92b1fkgcbgqr604t80000gn/T/nimblecache-1799278598/nimscriptapi_1188391125.nim(211, 16)
/Users/nazariglez/personal/sokol-nim/sokol.nimble(73, 3) clearTask
/Users/nazariglez/personal/sokol-nim/sokol.nimble(68, 8) run
/Users/nazariglez/personal/sokol-nim/sokol.nimble(65, 3) build
/opt/homebrew/Cellar/nim/2.0.6/nim/lib/system/nimscript.nim(265, 7) exec
/opt/homebrew/Cellar/nim/2.0.6/nim/lib/system/nimscript.nim(265, 7) Error: unhandled exception: FAILED: nim c --outdir:build   examples/clear [OSError]
       Tip: 1 messages have been suppressed, use --verbose to show them.
nimscriptwrapper.nim(161) execScript

    Error:  Exception raised during nimble script execution

I am using a Mac M3, OSX 14.5, XCode 15.4 and commit commit b5baede27f2d6b9242b09d270d60c0935889bb64 (HEAD -> master, origin/master, origin/HEAD).

Let me know how can I help! thanks

EDIT: It works on an old intel mac.

floooh commented 6 days ago

Hmm ok, here's my config:

Here's what I do before building the actual samples:

git clone https://github.com/floooh/sokol-nim
cd sokol-nim
nimble uninstall sokol -Y
nimble install

...then build some of the samples, for instance

nimble cube

...this outputs the following and then starts the cube sample:

sokol-nim ➤ nimble cube                                                                                              git:master
  Verifying dependencies for sokol@0.5.0
  Executing task cube in /Users/floh/scratch/sokol-nim/sokol.nimble
Hint: used config file '/opt/homebrew/Cellar/nim/2.0.6/nim/config/nim.cfg' [Conf]
Hint: used config file '/opt/homebrew/Cellar/nim/2.0.6/nim/config/config.nims' [Conf]
..................................................................................
CC: sokol_log
CC: sokol_gfx
CC: sokol_app
CC: sokol_glue
CC: ../../../../../opt/homebrew/Cellar/nim/2.0.6/nim/lib/system/exceptions.nim
CC: ../../../../../opt/homebrew/Cellar/nim/2.0.6/nim/lib/std/private/since.nim
CC: ../../../../../opt/homebrew/Cellar/nim/2.0.6/nim/lib/system/ctypes.nim
CC: ../../../../../opt/homebrew/Cellar/nim/2.0.6/nim/lib/std/sysatomics.nim
CC: ../../../../../opt/homebrew/Cellar/nim/2.0.6/nim/lib/system/ansi_c.nim
CC: ../../../../../opt/homebrew/Cellar/nim/2.0.6/nim/lib/system/memory.nim
CC: ../../../../../opt/homebrew/Cellar/nim/2.0.6/nim/lib/std/private/syslocks.nim
CC: ../../../../../opt/homebrew/Cellar/nim/2.0.6/nim/lib/std/private/threadtypes.nim
CC: ../../../../../opt/homebrew/Cellar/nim/2.0.6/nim/lib/std/private/digitsutils.nim
CC: ../../../../../opt/homebrew/Cellar/nim/2.0.6/nim/lib/std/private/miscdollars.nim
CC: ../../../../../opt/homebrew/Cellar/nim/2.0.6/nim/lib/std/assertions.nim
CC: ../../../../../opt/homebrew/Cellar/nim/2.0.6/nim/lib/system/iterators.nim
CC: ../../../../../opt/homebrew/Cellar/nim/2.0.6/nim/lib/system/coro_detection.nim
CC: ../../../../../opt/homebrew/Cellar/nim/2.0.6/nim/lib/std/private/dragonbox.nim
CC: ../../../../../opt/homebrew/Cellar/nim/2.0.6/nim/lib/std/private/schubfach.nim
CC: ../../../../../opt/homebrew/Cellar/nim/2.0.6/nim/lib/std/formatfloat.nim
CC: ../../../../../opt/homebrew/Cellar/nim/2.0.6/nim/lib/std/objectdollar.nim
CC: ../../../../../opt/homebrew/Cellar/nim/2.0.6/nim/lib/system/dollars.nim
CC: ../../../../../opt/homebrew/Cellar/nim/2.0.6/nim/lib/std/typedthreads.nim
CC: ../../../../../opt/homebrew/Cellar/nim/2.0.6/nim/lib/system/stacktraces.nim
CC: ../../../../../opt/homebrew/Cellar/nim/2.0.6/nim/lib/std/private/bitops_utils.nim
CC: ../../../../../opt/homebrew/Cellar/nim/2.0.6/nim/lib/system/countbits_impl.nim
CC: ../../../../../opt/homebrew/Cellar/nim/2.0.6/nim/lib/system/repr_v2.nim
CC: ../../../../../opt/homebrew/Cellar/nim/2.0.6/nim/lib/std/widestrs.nim
CC: ../../../../../opt/homebrew/Cellar/nim/2.0.6/nim/lib/std/syncio.nim
CC: ../../../../../opt/homebrew/Cellar/nim/2.0.6/nim/lib/system.nim
CC: ../../../.nimble/pkgs2/sokol-0.5.0-a18f55ac213f621e6431a7f2a5e029e45fa9b89e/sokol/log.nim
CC: ../../../.nimble/pkgs2/sokol-0.5.0-a18f55ac213f621e6431a7f2a5e029e45fa9b89e/sokol/gfx.nim
CC: ../../../.nimble/pkgs2/sokol-0.5.0-a18f55ac213f621e6431a7f2a5e029e45fa9b89e/sokol/app.nim
CC: ../../../.nimble/pkgs2/sokol-0.5.0-a18f55ac213f621e6431a7f2a5e029e45fa9b89e/sokol/glue.nim
CC: ../../../../../opt/homebrew/Cellar/nim/2.0.6/nim/lib/core/macros.nim
CC: ../../../../../opt/homebrew/Cellar/nim/2.0.6/nim/lib/pure/bitops.nim
CC: ../../../../../opt/homebrew/Cellar/nim/2.0.6/nim/lib/pure/fenv.nim
CC: ../../../../../opt/homebrew/Cellar/nim/2.0.6/nim/lib/pure/math.nim
CC: math/vec3.nim
CC: math/mat4.nim
CC: shaders/cube.nim
CC: cube.nim
Hint:  [Link]
ld: warning: ignoring duplicate libraries: '-lm'
Hint: mm: orc; threads: on; opt: none (DEBUG BUILD, `-d:release` generates faster code)
35458 lines; 2.629s; 46.492MiB peakmem; proj: examples/cube; out: /Users/floh/scratch/sokol-nim/build/cube [SuccessX]

...can you run the following and paste the output here?

xcrun --sdk macosx --show-sdk-path

...on my setup this prints:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk

...from looking at your console output, it looks like the C build is using an SDK under /Library/Developer/CommandLineTools/ which doesn't look right, the SDK should be in /Applications/Xcode.app.

...also, please check that there are no CFLAGS and CXXFLAGS set on your config, for some reason this seems to be pretty common on macOS, e.g. these should not print anything:

echo $CFLAGS
echo $CXXFLAGS

...that's all I can think of for now.

Nazariglez commented 6 days ago

I had the same output for xcrun and the flags were empty too.

Then I downgrade Xcode to 15.3, nothing... removed commadlinetools directory and reinstalled, nothing... Then I remember that I had once a similar issue similar llvm, I uninstalled it and it works!

I am not sure why... but this works for me. Thank you so much for the help!