Skip to content

Add scons with_x86_64h option on macOS - #1642

Closed
Ivorforce wants to merge 1 commit into
godotengine:masterfrom
Ivorforce:x86_64h-slice-option
Closed

Add scons with_x86_64h option on macOS#1642
Ivorforce wants to merge 1 commit into
godotengine:masterfrom
Ivorforce:x86_64h-slice-option

Conversation

@Ivorforce

@Ivorforce Ivorforce commented Nov 17, 2024

Copy link
Copy Markdown
Member

This adds an x86_64h slice, which can lead to improved performance (at the cost of binary size).
It will be selected automatically on all post-2013 macs, if compiled. Pre 2013 macs will use the current x86_64 slice.

See godotengine/godot-proposals#11150 for details about this feature.

The x86_64h slice is compiled alongside the x86_64 slice and is fully and transparently compatible with x86_64 godot. Therefore, we don't need to wait for any progress on the godot front to add this feature.

❯ scons arch=x86_64 dev_build=yes with_x86_64h=yes
...

❯ lipo -info project/bin/libgdexample.macos.template_debug.framework/libgdexample.macos.template_debug
Architectures in the fat file: project/bin/libgdexample.macos.template_debug.framework/libgdexample.macos.template_debug are: x86_64 x86_64h

godot-cpp/test x86_64h-slice-option ≡
❯ GODOT=/Applications/Godot4.4-dev4.app/Contents/MacOS/Godot  ./run-tests.sh
Godot Engine v4.4.dev4.official.36e6207bb - https://godotengine.org


 ==== TESTS FINISHED ====

   PASSES: 124
   FAILURES: 0

 ******** PASSED ********

grep: repetition-operator operand invalid

Removing the slice to see if x86_64h can be selected:

godot-cpp/test x86_64h-slice-option ≡
❯ lipo -remove x86_64 project/bin/libgdexample.macos.template_debug.framework/libgdexample.macos.template_debug -output project/bin/libgdexample.macos.template_debug.framework/libgdexample.macos.template_debug

❯ lipo -info project/bin/libgdexample.macos.template_debug.framework/libgdexample.macos.template_debug
Architectures in the fat file: project/bin/libgdexample.macos.template_debug.framework/libgdexample.macos.template_debug are: x86_64h

godot-cpp/test x86_64h-slice-option ≡
❯ GODOT=/Applications/Godot4.4-dev4.app/Contents/MacOS/Godot  ./run-tests.sh
Godot Engine v4.4.dev4.official.36e6207bb - https://godotengine.org


 ==== TESTS FINISHED ====

   PASSES: 124
   FAILURES: 0

 ******** PASSED ********

grep: repetition-operator operand invalid

godot-cpp/test x86_64h-slice-option ≡

@Ivorforce
Ivorforce requested a review from a team as a code owner November 17, 2024 12:20
@Ivorforce

Copy link
Copy Markdown
Member Author

It may be nice to have an option to build only for x86_64h (instead of x86_64), to kill compatibility to older macs by choice. I opted not to add that because gdextensions should probably be fully compatible to everything godot is compatible with.

@dsnopek dsnopek left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

However, I'm not totally sure about including this in godot-cpp. How commonly would this be used?

If it won't be super common, I think extension authors who really want it could add this in their own SConstruct files, we don't need to support it upstream

Comment thread tools/macos.py
def options(opts):
opts.Add("macos_deployment_target", "macOS deployment target", "default")
opts.Add("macos_sdk_path", "macOS SDK path", "")
opts.Add(BoolVariable("with_x86_64h", "If arch=x86_64 or universal, include an x86_64h slice.", False))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"with_" as a prefix for this option doesn't really fit with the naming of our other options. Maybe "use_x86_64h"?

@Ivorforce

Ivorforce commented Apr 16, 2025

Copy link
Copy Markdown
Member Author

However, I'm not totally sure about including this in godot-cpp. How commonly would this be used?

Realistically, probably not a lot.
The reason I proposed it anyway is that, for Intel macOS targets, it's an "instantaneous performance upgrade" at no development cost, though it does make the binary twice as large. Exposing it through SCons would 'expose' developers to it, since it's not a very well known trick.
I guess with Apple phasing out Intel, it's not all that relevant.

@Ivorforce

Copy link
Copy Markdown
Member Author

Closing as the window of intel macs is running out, and it's not going to become more relevant anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

archived enhancement This is an enhancement on the current functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants