Skip to content

Get third party project "zig-gamedev" working successfully with self-hosted #12552

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

Closed
michal-z opened this issue Aug 21, 2022 · 3 comments
Closed
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness. miscompilation The compiler reports success but produces semantically incorrect code.

Comments

@michal-z
Copy link
Contributor

michal-z commented Aug 21, 2022

Zig Version

0.10.0-dev.3659+e5e6eb983

Steps to Reproduce

The problem occurs only on macOS AArch64 with stage2 and stage3 (works correctly on Windows, Linux and macOS x86_64 with stage1/stage2/stage3).

  1. git clone https://github.com/michal-z/zig-gamedev
  2. cd zig-gamedev
  3. zig build audio_experiments_wgpu-run
  4. Crash in the sample application (looks like miscompilation)

Expected Behavior

Sample application works correctly.

Actual Behavior

[zgpu] High-performance device has been selected:
[zgpu]   Name: Apple M1 Max
[zgpu]   Driver: Metal driver on macOS Version 12.5 (Build 21G72)
[zgpu]   Adapter type: discrete_gpu
[zgpu]   Backend type: metal
Segmentation fault at address 0xbb1b259f81cd0091
???:?:?: 0x1028743d0 in _ma_waveform_config_init (???)
/Users/jonas/src/zig/zig-gamedev/samples/audio_experiments_wgpu/src/audio_experiments_wgpu.zig:358:35: 0x1023c9523 in create (audio_experiments_wgpu)
        audio.engine.getSampleRate(),
                                  ^
/Users/jonas/src/zig/zig-gamedev/samples/audio_experiments_wgpu/src/audio_experiments_wgpu.zig:1001:28: 0x1023d1d77 in main (audio_experiments_wgpu)
    const demo = try create(allocator, window);
                           ^
/Users/jonas/src/zig/zig/build/stage3/lib/zig/std/start.zig:574:37: 0x1023d62eb in main (audio_experiments_wgpu)
        },
                                    ^
???:?:?: 0x10364508b in ??? (???)
???:?:?: 0x1e1f7fffffffffff in ??? (???)
@michal-z michal-z added the bug Observed behavior contradicts documented or intended behavior label Aug 21, 2022
@michal-z
Copy link
Contributor Author

Project is also affected by:
#12483
#12325

We currently employ workarounds for above issues.

@Vexu Vexu added miscompilation The compiler reports success but produces semantically incorrect code. frontend Tokenization, parsing, AstGen, Sema, and Liveness. labels Aug 21, 2022
@Vexu Vexu added this to the 0.10.0 milestone Aug 21, 2022
@kamidev
Copy link

kamidev commented Aug 21, 2022

As part of current workarounds, we had to avoid using cImport on MacOS AArch64. It does work for other platforms, though. This issue might be relevant:
#12185

@michal-z
Copy link
Contributor Author

michal-z commented Aug 21, 2022

We have confirmed that the original issue is an AAarch C ABI problem. Returning a structure by value that is 32 bytes in size causes a crash. We now have a workaround for this.

In summary, all cross-platform sample applications work correctly now. Project is affected by 3 above issues but we have workarounds.

@andrewrk @Vexu Should we leave this issue open?

@Vexu Vexu closed this as completed Aug 22, 2022
@Vexu Vexu removed this from the 0.10.0 milestone Aug 22, 2022
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 frontend Tokenization, parsing, AstGen, Sema, and Liveness. miscompilation The compiler reports success but produces semantically incorrect code.
Projects
None yet
Development

No branches or pull requests

3 participants