-
-
Notifications
You must be signed in to change notification settings - Fork 21.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
Unify bits, arch, and android_arch into env["arch"] #55778
Conversation
2f98468
to
46d18ca
Compare
I think the drop of 32bit support on iOS should go into its own commit. |
Yes, and similarly I would put the actual build fixes in a dedicated PR too. This should only focus on buildsystem changes. |
5428d42
to
9735747
Compare
if (file.find("/data.mono.osx.64.release_debug/") != -1) { | ||
if (file.find("/data.mono.osx.x86_64.release_debug/") != -1) { | ||
if (!p_debug) { | ||
ret = unzGoToNextFile(src_pkg_zip); | ||
continue; // skip | ||
} | ||
file = file.replace("/data.mono.osx.64.release_debug/", "/GodotSharp/"); | ||
file = file.replace("/data.mono.osx.x86_64.release_debug/", "/GodotSharp/"); | ||
} | ||
if (file.find("/data.mono.osx.64.release/") != -1) { | ||
if (file.find("/data.mono.osx.x86_64.release/") != -1) { | ||
if (p_debug) { | ||
ret = unzGoToNextFile(src_pkg_zip); | ||
continue; // skip | ||
} | ||
file = file.replace("/data.mono.osx.64.release/", "/GodotSharp/"); | ||
file = file.replace("/data.mono.osx.x86_64.release/", "/GodotSharp/"); |
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.
This should stay 64
or skip architecture at all, usually this path point to the Universal (x86_64
+ arm64
) binaries.
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.
Since this is supposed to point to universal, I reverted this part for this PR, but I think it would make sense to remove the architecture in the future for universal things, or use the word "universal".
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.
Yeah I think it can be left out for this PR, but that's something that needs more work later.
We can indeed remove the bits/arch part which is currently irrelevant. But we have to think about whether we want to actually make it possibility to support different architectures with this like we do on other platforms, and thus have:
data.mono.osx.x86_64.release
data.mono.osx.arm64.release
data.mono.osx.universal.release
Official builds would use the latter, but users who want to ship separate x86_64 and arm64 builds for some reason would still have the option to do it with pre-defined names. Currently you'd have to use data.mono.osx.64.release
regardless of what the actual native binaries inside are compiled for.
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.
For the record the names were changed here: https://github.com/godotengine/godot/pull/63096/files#diff-72b5d6bdf8391a9477aca91fe06263335d88623f353c71cc56ffc8bda6102221
9735747
to
dd009bb
Compare
if env["arch"] == "x86_32": | ||
cmdbase = env["mingw_prefix_32"] | ||
else: | ||
cmdbase = env["mingw_prefix_64"] |
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.
I guess it should be simply a single mingw_prefix
that can be set alongside arch
.
"Failed to manually detect MSVC compiler architecture version... Defaulting to 32bit executable settings" | ||
" (forcing bits=32). Compilation attempt will continue, but SCons can not detect for what architecture this" | ||
"Failed to manually detect MSVC compiler architecture version... Defaulting to x86 32-bit executable settings" | ||
" (forcing arch=x86_32). Compilation attempt will continue, but SCons can not detect for what architecture this" | ||
" build is compiled for. You should check your settings/compilation setup, or avoid setting VCINSTALLDIR." | ||
) |
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.
This should just fail, there's no point to continue if compiler is not present.
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 print is no longer accurate then, since it says explicitly that it's falling back to x86 32-bit settings.
# TODO: This doesn't seem to be working, or maybe I just have | ||
# MinGW set up incorrectly. It always gives me x86_64 builds, | ||
# even though arch == "x86_32" and the file name has x86_32 in it. |
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.
Depending on setup, MinGW can have either prefixed binaries (e.g. x86_64-w64-mingw32-gcc
) or everything in the subfolder (gcc
) in this case which one used is determined by path
. I'm not sure how to detect arch in this case, we can do something like detect_visual_c_compiler_version
, but MinGW path is not standard (might work for MSYS2 - https://www.msys2.org/docs/environments/).
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.
Using -march=
seems to work fine with MinGW, but x86-64
for example only available if running from 64-bit MSYS2 environment.
So I guess the best way is to, try to set prefix based on arch
if it's not set (ignore it otherwise since it can be something line /mingw/bin/
without arch name). Always set -march
to make sure it's building for the correct one. Plus check MSYS2
env variables and warn if trying to use 64-bit arch in 32-bit env.
For MSVC, I think we can always force compilers path based on arch, even if it's started from wrong environment (maybe with a warning as well).
In any case, this should be good to merge as is (after rebase), and I'll add both checks / -march
for Windows cross compile when implementing ARM support for Windows.
a556b4e
to
1ae98cc
Compare
1ae98cc
to
b2b30da
Compare
I'm pretty happy with the state of this PR now, I'll do a final review and squash the commits so we can merge. My only remaining concern is the same as expressed by @m4gr3d, there's potential confusion between the values we use for |
b2b30da
to
10bcb1e
Compare
Fully removes the `bits` option and adapts the code that relied on it. Co-authored-by: Rémi Verschelde <[email protected]>
10bcb1e
to
27b0f18
Compare
I reviewed the changes again and amended a couple nitpicks. I tested an Android build with:
And it seems to work fine. I could use the resulting APK and source templates to do both APK and Custom Build/AAB exports to my arm64 Poco F1, which ran fine. I still have some concerns about the Android+Mono changes, and I think some renaming might be in order to make a clear separation between the |
Original concerns seem to have been addressed. Needs re-review/testing.
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.
Amazing work!
Thanks! |
Needed after godotengine/godot#55778. Not sure how alpha15 built properly without this :O
This PR addresses part of godotengine/godot-proposals#1416
In the master branch before this PR, we have several arguments for specifying the architecture:
bits
,arch
, andandroid_arch
. This is a bit of a mess, so this PR replaces all three of these with a single unifiedarch
. Note thatenv["bits"]
still exists internally for now (or it could be kept forever).The list of valid architectures is
["auto", "x86_32", "x86_64", "arm32", "arm64", "rv64", "ppc32", "ppc64", "wasm32"]
. The names were chosen to be explicit such that each architecture always includes the bitness in the name (except for "auto").If
"auto"
, then it will automatically determine the architecture. It will use arm64 for Android and iOS, wasm32 for JavaScript, and otherwise it will use the host architecture, so arm64 on modern ARM devices, x86_64 on a typical modern desktop, and x86_32 on an old 32-bit desktop.For macOS, iOS, JavaScript, and Android, it will throw an error if trying to build for an invalid architecture. The same should be done for Windows and Linux but I'm not sure how to get cross-compiling working in all cases where it should exist or how to show an error when the necessary libs etc are missing. There's also several places in both Windows and Linux that are hard-coded for x86. I left some TODOs in the Windows and Linux code for future PRs.
I've tested this PR compiling on an arm64 macOS host for x86_64 and arm64 macOS and for arm64 iOS, on an arm64 Ubuntu VM for arm64 Linux, on a rv64 Ubuntu VM for rv64 Linux, on an x86_64 Ubuntu host for x86_64 Linux, on an x86_32 Ubuntu VM for x86_32 Linux (fails linking, but happens on master too), on an x86_64 Windows host for x86_32 and x86_64 Windows using MSVC and x86_64 using MinGW, on both an x86_64 Windows and x86_64 Ubuntu host for x86_32, x86_64, arm32, and arm64 Android (x86 Android fails linking on Ubuntu but this happens on master too, and I only tested if the arm64 Android build runs), and on an x86_64 Windows host for wasm32 JavaScript. Still, it needs further testing. Most of the platforms I've tested on have revealed bugs (some of which exist on master too).
This PR also simplifies a lot of architecture checks (such as the ones in the denoise module).
@q66 Can you test if this works as expected on PowerPC?