-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
add support for compiling Objective-C++ code #10096
Conversation
Wow, cool! Out of curiosity, does ObjC++ link fine with zld? |
* MacOS support functional * C shims for dawn_native functionality, e.g. required utilities for binding to a GLFW window. * Fully building with Zig, but depends on ziglang/zig#10096 for Obj-C++ support. Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
* MacOS support functional * C shims for dawn_native functionality, e.g. required utilities for binding to a GLFW window. * Fully building with Zig, but depends on ziglang/zig#10096 for Obj-C++ support. Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look great. I just have one tiny request: would you be able to add some basic standalone tests that are enabled on macOS with SDK present only (we have a flag for that -Denable-macos-sdk
)? The test would then link against some frameworks or what not, unless you think this is unnecessary.
I'd be very happy to do that! I dug around a bit and it seems like I would basically need to add a directory like this one ("standalone test") with something like a hello-world ObjC++ file called from Zig, plus maybe linking a framework in? Does that sound about right? |
Yep, sounds right. And then in |
* MacOS support functional * C shims for dawn_native functionality, e.g. required utilities for binding to a GLFW window. * Fully building with Zig, but depends on ziglang/zig#10096 for Obj-C++ support. Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
@kubkon PTAL - I rebased against |
* MacOS support functional * C shims for dawn_native functionality, e.g. required utilities for binding to a GLFW window. * Fully building with Zig, but depends on ziglang/zig#10096 for Obj-C++ support. Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
@slimsag if you rebase against master, macOS CI should be green again :-) |
Prior to this change, calling `step.addCSourceFiles` with Obj-C++ file extensions (`.mm`) would result in an error due to Zig not being aware of that extension. Clang supports an `-ObjC++` compilation mode flag, but it was only possible to use if you violated standards and renamed your `.mm` Obj-C++ files to `.m` (Obj-C) to workaround Zig being unaware of the extension. This change makes Zig aware of `.mm` files so they can be compiled, enabling compilation of projects such as [Google's Dawn WebGPU](https://dawn.googlesource.com/dawn/) using a `build.zig` file only. Helps hexops/mach#21 Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
Based on the existing objc example, just tweaked for ObjC++. Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
Done! 🤞 |
Prior to this change, calling
step.addCSourceFiles
with Obj-C++ file extensions (.mm
) would result in an error due to Zig not being aware of that extension. Clang supports an-ObjC++
compilation mode flag, but it was only possible to use if you violated standards and renamed your.mm
Obj-C++ files to.m
(Obj-C) to workaround Zig being unaware of the extension.This change makes Zig aware of
.mm
files so they can be compiled, enabling compilation of projects such as Google's Dawn WebGPU implementation using only abuild.zig
file.Helps hexops/mach#21
Signed-off-by: Stephen Gutekanst stephen@hexops.com