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

macOS/MoltenVK issue on SDL 2.0.12 #1028

Closed
aclysma opened this issue Sep 16, 2020 · 2 comments · Fixed by #1030
Closed

macOS/MoltenVK issue on SDL 2.0.12 #1028

aclysma opened this issue Sep 16, 2020 · 2 comments · Fixed by #1030

Comments

@aclysma
Copy link
Contributor

aclysma commented Sep 16, 2020

My application runs with sdl2-sys 0.34.2 but not 0.34.3, when using bundled/static-link. The error message:

thread 'main' panicked at 'Failed to create window: SdlError("Vulkan support is either not configured in SDL or not available in current SDL video driver (cocoa) or platform")', engine/src/init.rs:51:18

It may be related to this:
KhronosGroup/MoltenVK#846

It sounds like VK_MVK_macos_surface was replaced with VK_EXT_metal_surface. I'll investigate this more later, but wanted to mention it.

@aclysma
Copy link
Contributor Author

aclysma commented Sep 17, 2020

I was able to build SDL2 manually and static link it. It was not an easy process so a few things I had to do in build.rs for rust-sdl2:

  • Add the Metal framework: println!("cargo:rustc-link-lib=framework=Metal");
  • I did not have SDL2main and didn't figure out how to generate it so I REMOVED println!("cargo:rustc-link-lib=static=SDL2main");
  • Add clang_rt.osx
    • LIB: println!("cargo:rustc-link-lib=clang_rt.osx");
    • Search path: println!("cargo:rustc-link-search={}", "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.3/lib/darwin"); to solve this error:
error: linking with `cc` failed: exit code: 1
...
  = note: Undefined symbols for architecture x86_64:
            "___isPlatformVersionAtLeast", referenced from:
                _METAL_CreateRenderer in libsdl2_sys-4e45691694f9156d.rlib(SDL_render_metal.o)
          ld: symbol(s) not found for architecture x86_64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

After static linking, my vulkan app works fine. I only reproduce the above behavior if I manually set SDL_VIDEO_VULKAN to 0. I think the next step is figuring out why bundled 2.0.12 SDL2 is producing different results than static linking my own SDL2 I built manually.

@aclysma
Copy link
Contributor Author

aclysma commented Sep 18, 2020

The issue is that the HAVE_FRAMEWORK_METAL check is failing

Performing C SOURCE FILE Test HAVE_FRAMEWORK_METAL failed with the following output:
Change Dir: /Users/pmd/dev/rust/sdl2-test/target/debug/build/sdl2-sys-c89bed5a4182e1ce/out/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_5ace8/fast && /Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_5ace8.dir/build.make CMakeFiles/cmTC_5ace8.dir/build
Building C object CMakeFiles/cmTC_5ace8.dir/src.c.o
/usr/bin/cc   -ffunction-sections -fdata-sections -fPIC -m64 -arch x86_64 -idirafter /Users/pmd/dev/rust/sdl2-test/target/debug/build/sdl2-sys-c89bed5a4182e1ce/out/SDL2-2.0.12/src/video/khronos -DHAVE_FRAMEWORK_METAL  -x objective-c -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk   -o CMakeFiles/cmTC_5ace8.dir/src.c.o   -c /Users/pmd/dev/rust/sdl2-test/target/debug/build/sdl2-sys-c89bed5a4182e1ce/out/build/CMakeFiles/CMakeTmp/src.c
Linking C executable cmTC_5ace8
/usr/local/Cellar/cmake/3.16.4/bin/cmake -E cmake_link_script CMakeFiles/cmTC_5ace8.dir/link.txt --verbose=1
/usr/bin/cc  -ffunction-sections -fdata-sections -fPIC -m64 -arch x86_64 -idirafter /Users/pmd/dev/rust/sdl2-test/target/debug/build/sdl2-sys-c89bed5a4182e1ce/out/SDL2-2.0.12/src/video/khronos -DHAVE_FRAMEWORK_METAL  -x objective-c -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names   CMakeFiles/cmTC_5ace8.dir/src.c.o  -o cmTC_5ace8 
CMakeFiles/cmTC_5ace8.dir/src.c.o:1:1: error: source file is not valid UTF-8
<CF><FA><ED><FE><U+0007><U+0000><U+0000><U+0001><U+0003><U+0000><U+0000><U+0000><U+0001><U+0000><U+0000><U+0000><U+0004><U+0000><U+0000><U+0000><U+0008><U+0002><U+0000><U+0000><U+0000> <U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0019><U+0000><U+0000><U+0000><88><U+0001><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>x<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>(<U+0002><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>x<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0007><U+0000><U+0000><U+0000><U+0007><U+0000><U+0000><U+0000><U+0004><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>__text<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>__TEXT<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+000F><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>(<U+0002><U+0000><U+0000><U+0004><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0004><U+0000><80><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>__objc_imageinfo__DATA<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+000F><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0008><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>7<U+0002><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0010><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>__compact_unwind__LD<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0018><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000> <U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>@<U+0002><U+0000><U+0000><U+0003><U+0000><U+0000><U+0000><A0><U+0002><U+0000><U+0000><U+0001><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0002><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>__eh_frame<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>__TEXT<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>8<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>@<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>`<U+0002><U+0000><U+0000><U+0003><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+000B><U+0000><U+0000>h<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>2<U+0000><U+0000><U+0000><U+0018><U+0000><U+0000><U+0000><U+0001><U+0000><U+0000><U+0000><U+0000><U+000F>
^
CMakeFiles/cmTC_5ace8.dir/src.c.o:1:2: error: source file is not valid UTF-8
<CF><FA><ED><FE><U+0007><U+0000><U+0000><U+0001><U+0003><U+0000><U+0000><U+0000><U+0001><U+0000><U+0000><U+0000><U+0004><U+0000><U+0000><U+0000><U+0008><U+0002><U+0000><U+0000><U+0000> <U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0019><U+0000><U+0000><U+0000><88><U+0001><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>x<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>(<U+0002><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>x<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0007><U+0000><U+0000><U+0000><U+0007><U+0000><U+0000><U+0000><U+0004><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>__text<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>__TEXT<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+000F><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>(<U+0002><U+0000><U+0000><U+0004><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0004><U+0000><80><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>__objc_imageinfo__DATA<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+000F><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0008><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>7<U+0002><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0010><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>__compact_unwind__LD<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0018><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000> <U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>@<U+0002><U+0000><U+0000><U+0003><U+0000><U+0000><U+0000><A0><U+0002><U+0000><U+0000><U+0001><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0002><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>__eh_frame<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>__TEXT<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>8<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>@<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>`<U+0002><U+0000><U+0000><U+0003><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+000B><U+0000><U+0000>h<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>2<U+0000><U+0000><U+0000><U+0018><U+0000><U+0000><U+0000><U+0001><U+0000><U+0000><U+0000><U+0000><U+000F>
    ^
CMakeFiles/cmTC_5ace8.dir/src.c.o:1:3: error: source file is not valid UTF-8
<CF><FA><ED><FE><U+0007><U+0000><U+0000><U+0001><U+0003><U+0000><U+0000><U+0000><U+0001><U+0000><U+0000><U+0000><U+0004><U+0000><U+0000><U+0000><U+0008><U+0002><U+0000><U+0000><U+0000> <U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0019><U+0000><U+0000><U+0000><88><U+0001><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>x<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>(<U+0002><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>x<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0007><U+0000><U+0000><U+0000><U+0007><U+0000><U+0000><U+0000><U+0004><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>__text<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>__TEXT<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+000F><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>(<U+0002><U+0000><U+0000><U+0004><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0004><U+0000><80><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>__objc_imageinfo__DATA<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+000F><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0008><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>7<U+0002><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0010><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>__compact_unwind__LD<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0018><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000> <U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>@<U+0002><U+0000><U+0000><U+0003><U+0000><U+0000><U+0000><A0><U+0002><U+0000><U+0000><U+0001><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0002><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>__eh_frame<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>__TEXT<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>8<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>@<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>`<U+0002><U+0000><U+0000><U+0003><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+000B><U+0000><U+0000>h<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>2<U+0000><U+0000><U+0000><U+0018><U+0000><U+0000><U+0000><U+0001><U+0000><U+0000><U+0000><U+0000><U+000F>
        ^
CMakeFiles/cmTC_5ace8.dir/src.c.o:1:4: error: source file is not valid UTF-8
<CF><FA><ED><FE><U+0007><U+0000><U+0000><U+0001><U+0003><U+0000><U+0000><U+0000><U+0001><U+0000><U+0000><U+0000><U+0004><U+0000><U+0000><U+0000><U+0008><U+0002><U+0000><U+0000><U+0000> <U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0019><U+0000><U+0000><U+0000><88><U+0001><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>x<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>(<U+0002><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>x<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0007><U+0000><U+0000><U+0000><U+0007><U+0000><U+0000><U+0000><U+0004><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>__text<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>__TEXT<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+000F><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>(<U+0002><U+0000><U+0000><U+0004><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0004><U+0000><80><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>__objc_imageinfo__DATA<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+000F><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0008><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>7<U+0002><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0010><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>__compact_unwind__LD<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0018><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000> <U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>@<U+0002><U+0000><U+0000><U+0003><U+0000><U+0000><U+0000><A0><U+0002><U+0000><U+0000><U+0001><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0002><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>__eh_frame<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>__TEXT<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>8<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>@<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>`<U+0002><U+0000><U+0000><U+0003><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+000B><U+0000><U+0000>h<U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000><U+0000>2<U+0000><U+0000><U+0000><U+0018><U+0000><U+0000><U+0000><U+0001><U+0000><U+0000><U+0000><U+0000><U+000F>
            ^

Looks like this was reported here:
https://discourse.libsdl.org/t/macos-build-issues-not-detecting-metal/27557

This error can be found in the CMakeError.log in the target directory and does not occur with sdl2-sys 0.34.2 which is based on SDL 2.0.10. I can reproduce this when manually building SDL2 from source when using cmake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant