godotengine / godotengine/godot-cpp

macOS and iOS arch build behavior does not match Godot upstream

Open
#1,633 10 comments 0 reactions 0 assignees View on GitHub
enhancement topic:buildsystem
Dominant language
C++
Stars
2.7k
Forks
809
Avg merge
1d 3h
Merged PRs (30d)
8

Description

We recently found in [a discussion](https://github.com/godotengine/godot-cpp/pull/1613) that godot-cpp arch build behavior does not match Godot upstream.

In particular, godot-cpp [defaults to building universal binaries](https://github.com/godotengine/godot-cpp/blob/master/tools/godotcpp.py#L410) ([which passes the appropriate flags to the compiler](https://github.com/godotengine/godot-cpp/blob/master/tools/macos.py#L51) to build both). The gdextension usually loads the same binary for both `arm64` and `x86_64` (as per [godot-cpp-template](https://github.com/godotengine/godot-cpp-template/blob/main/demo/bin/example.gdextension#L8-L11)).

Godot, on the other hand, builds `arm64` and `x86_64` separately and [joins them afterwards with `lipo`](https://github.com/godotengine/godot/blob/a3080477ac0421aef24ca0916c40559abbf4846b/.github/workflows/macos_builds.yml#L79). It [does not support a 'universal' arch target](https://github.com/godotengine/godot/blob/master/platform/macos/detect.py#L71).

One problem with the `universal` approach used by godot-cpp is that for universal builds, no architecture-specific build flags can be passed to the compilers (such as `-mavx`), because then the other architecture won't build (e.g. `-mavx` is not arm64 compatible). Notably, godot-cpp [already supports](https://github.com/godotengine/godot-cpp/blob/master/tools/macos.py#L23) compiling for the arches separately.

Changing the default behavior would affect all current macOS compatible godot-cpp extensions, because they will (likely) build with the default `universal` target right now (as per [godot-cpp-template](https://github.com/godotengine/godot-cpp-template/blob/main/.github/workflows/builds.yml#L36)). We will have to figure out whether a change to separate the binaries will affect exports, especially for universal macOS apps.

We discussed this briefly at the last GDExtension meeting, and would like to have input on this before proceeding (especially from @Faless).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.