Skip to content

Commit 27b0f18

Browse files
Unify bits, arch, and android_arch into env["arch"]
Fully removes the `bits` option and adapts the code that relied on it. Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
1 parent 8916949 commit 27b0f18

28 files changed

+271
-218
lines changed

.github/workflows/android_builds.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,19 @@ jobs:
3838
- name: Setup python and scons
3939
uses: ./.github/actions/godot-deps
4040

41-
- name: Compilation (armv7)
41+
- name: Compilation (arm32)
4242
uses: ./.github/actions/godot-build
4343
with:
44-
sconsflags: ${{ env.SCONSFLAGS }} android_arch=armv7
44+
sconsflags: ${{ env.SCONSFLAGS }} arch=arm32
4545
platform: android
4646
target: release
4747
tools: false
4848
tests: false
4949

50-
- name: Compilation (arm64v8)
50+
- name: Compilation (arm64)
5151
uses: ./.github/actions/godot-build
5252
with:
53-
sconsflags: ${{ env.SCONSFLAGS }} android_arch=arm64v8
53+
sconsflags: ${{ env.SCONSFLAGS }} arch=arm64
5454
platform: android
5555
target: release
5656
tools: false

.github/workflows/ios_builds.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- name: Setup python and scons
2727
uses: ./.github/actions/godot-deps
2828

29-
- name: Compilation (arm64v8)
29+
- name: Compilation (arm64)
3030
uses: ./.github/actions/godot-build
3131
with:
3232
sconsflags: ${{ env.SCONSFLAGS }}

.github/workflows/linux_builds.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
tests: false # Disabled due freeze caused by mix Mono build and CI
2929
sconsflags: module_mono_enabled=yes
3030
doc-test: true
31-
bin: "./bin/godot.linuxbsd.opt.tools.64.mono"
31+
bin: "./bin/godot.linuxbsd.opt.tools.x86_64.mono"
3232
build-mono: true
3333
proj-conv: true
3434
artifact: true
@@ -43,7 +43,7 @@ jobs:
4343
# Can be turned off for PRs that intentionally break compat with godot-cpp,
4444
# until both the upstream PR and the matching godot-cpp changes are merged.
4545
godot-cpp-test: true
46-
bin: "./bin/godot.linuxbsd.double.tools.64.san"
46+
bin: "./bin/godot.linuxbsd.double.tools.x86_64.san"
4747
build-mono: false
4848
# Skip 2GiB artifact speeding up action.
4949
artifact: false
@@ -54,7 +54,7 @@ jobs:
5454
tools: true
5555
tests: true
5656
sconsflags: use_asan=yes use_ubsan=yes use_llvm=yes linker=lld
57-
bin: "./bin/godot.linuxbsd.tools.64.llvm.san"
57+
bin: "./bin/godot.linuxbsd.tools.x86_64.llvm.san"
5858
build-mono: false
5959
# Skip 2GiB artifact speeding up action.
6060
artifact: false

.github/workflows/macos_builds.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
target: release_debug
2525
tools: true
2626
tests: true
27-
bin: "./bin/godot.macos.opt.tools.64"
27+
bin: "./bin/godot.macos.opt.tools.x86_64"
2828

2929
- name: Template (target=release, tools=no)
3030
cache-name: macos-template

.github/workflows/windows_builds.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
tests: true
3030
# Skip debug symbols, they're way too big with MSVC.
3131
sconsflags: debug_symbols=no
32-
bin: "./bin/godot.windows.opt.tools.64.exe"
32+
bin: "./bin/godot.windows.opt.tools.x86_64.exe"
3333

3434
- name: Template (target=release, tools=no)
3535
cache-name: windows-template

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Godot runs on a large variety of platforms and operating systems and devices.
3737

3838
For bugs that are likely OS-specific and/or graphics-related, please also specify:
3939

40-
- Device (CPU model including architecture, e.g. x86, x86_64, ARM, etc.)
40+
- Device (CPU model including architecture, e.g. x86_64, arm64, etc.)
4141
- GPU model (and the driver version in use if you know it)
4242

4343
**Bug reports not including the required information may be closed at the

SConstruct

+10-11
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ _helper_module("modules.modules_builders", "modules/modules_builders.py")
5555
import methods
5656
import glsl_builders
5757
import gles3_builders
58+
from platform_methods import architectures, architecture_aliases
5859

5960
if methods.get_cmdline_bool("tools", True):
6061
_helper_module("editor.editor_builders", "editor/editor_builders.py")
@@ -161,12 +162,11 @@ if profile:
161162
opts = Variables(customs, ARGUMENTS)
162163

163164
# Target build options
164-
opts.Add("p", "Platform (alias for 'platform')", "")
165165
opts.Add("platform", "Target platform (%s)" % ("|".join(platform_list),), "")
166+
opts.Add("p", "Platform (alias for 'platform')", "")
166167
opts.Add(BoolVariable("tools", "Build the tools (a.k.a. the Godot editor)", True))
167168
opts.Add(EnumVariable("target", "Compilation target", "debug", ("debug", "release_debug", "release")))
168-
opts.Add("arch", "Platform-dependent architecture (arm/arm64/x86/x64/mips/...)", "")
169-
opts.Add(EnumVariable("bits", "Target platform bits", "default", ("default", "32", "64")))
169+
opts.Add(EnumVariable("arch", "CPU architecture", "auto", ["auto"] + architectures, architecture_aliases))
170170
opts.Add(EnumVariable("float", "Floating-point precision", "default", ("default", "32", "64")))
171171
opts.Add(EnumVariable("optimize", "Optimization type", "speed", ("speed", "size", "none")))
172172
opts.Add(BoolVariable("production", "Set defaults to build Godot for use in production", False))
@@ -502,12 +502,17 @@ if selected_platform in platform_list:
502502
# Platform specific flags
503503
flag_list = platform_flags[selected_platform]
504504
for f in flag_list:
505-
if not (f[0] in ARGUMENTS): # allow command line to override platform flags
505+
if not (f[0] in ARGUMENTS) or ARGUMENTS[f[0]] == "auto": # Allow command line to override platform flags
506506
env[f[0]] = f[1]
507507

508508
# Must happen after the flags' definition, so that they can be used by platform detect
509509
detect.configure(env)
510510

511+
print(
512+
'Building for platform "%s", architecture "%s", %s, target "%s".'
513+
% (selected_platform, env["arch"], "editor" if env["tools"] else "template", env["target"])
514+
)
515+
511516
# Set our C and C++ standard requirements.
512517
# C++17 is required as we need guaranteed copy elision as per GH-36436.
513518
# Prepending to make it possible to override.
@@ -693,13 +698,7 @@ if selected_platform in platform_list:
693698
)
694699
suffix += ".debug"
695700

696-
if env["arch"] != "":
697-
suffix += "." + env["arch"]
698-
elif env["bits"] == "32":
699-
suffix += ".32"
700-
elif env["bits"] == "64":
701-
suffix += ".64"
702-
701+
suffix += "." + env["arch"]
703702
suffix += env.extra_suffix
704703

705704
sys.path.remove(tmppath)

drivers/png/SCsub

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ if env["builtin_libpng"]:
3737
import os
3838

3939
# Enable ARM NEON instructions on 32-bit Android to compile more optimized code.
40-
use_neon = "android_arch" in env and env["android_arch"] == "armv7" and os.name != "nt"
40+
use_neon = env["platform"] == "android" and env["arch"] == "arm32" and os.name != "nt"
4141
if use_neon:
4242
env_png.Append(CPPDEFINES=[("PNG_ARM_NEON_OPT", 2)])
4343
else:

methods.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ def detect_visual_c_compiler_version(tools_env):
540540
# and not scons setup environment (env)... so make sure you call the right environment on it or it will fail to detect
541541
# the proper vc version that will be called
542542

543-
# There is no flag to give to visual c compilers to set the architecture, i.e. scons bits argument (32,64,ARM etc)
543+
# There is no flag to give to visual c compilers to set the architecture, i.e. scons arch argument (x86_32, x86_64, arm64, etc.).
544544
# There are many different cl.exe files that are run, and each one compiles & links to a different architecture
545545
# As far as I know, the only way to figure out what compiler will be run when Scons calls cl.exe via Program()
546546
# is to check the PATH variable and figure out which one will be called first. Code below does that and returns:

modules/denoise/config.py

+1-8
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,7 @@ def can_build(env, platform):
55
# as doing lightmap generation and denoising on Android or HTML5
66
# would be a bit far-fetched.
77
desktop_platforms = ["linuxbsd", "macos", "windows"]
8-
supported_arch = env["bits"] == "64"
9-
if env["arch"] == "arm64":
10-
supported_arch = False
11-
if env["arch"].startswith("ppc"):
12-
supported_arch = False
13-
if env["arch"].startswith("rv"):
14-
supported_arch = False
15-
return env["tools"] and platform in desktop_platforms and supported_arch
8+
return env["tools"] and platform in desktop_platforms and env["arch"] == "x86_64"
169

1710

1811
def configure(env):

modules/mono/build_scripts/mono_configure.py

+10-14
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def configure(env, env_mono):
1818
# is_android = env["platform"] == "android"
1919
# is_javascript = env["platform"] == "javascript"
2020
# is_ios = env["platform"] == "ios"
21-
# is_ios_sim = is_ios and env["arch"] in ["x86", "x86_64"]
21+
# is_ios_sim = is_ios and env["arch"] in ["x86_32", "x86_64"]
2222

2323
tools_enabled = env["tools"]
2424

@@ -128,26 +128,22 @@ def get_runtime_path():
128128

129129

130130
def determine_runtime_identifier(env):
131+
# The keys are Godot's names, the values are the Microsoft's names.
132+
# List: https://docs.microsoft.com/en-us/dotnet/core/rid-catalog
131133
names_map = {
132134
"windows": "win",
133135
"macos": "osx",
134136
"linuxbsd": "linux",
135137
}
136-
137-
# .NET RID architectures: x86, x64, arm, or arm64
138-
138+
arch_map = {
139+
"x86_64": "x64",
140+
"x86_32": "x86",
141+
"arm64": "arm64",
142+
"arm32": "arm",
143+
}
139144
platform = env["platform"]
140-
141145
if is_desktop(platform):
142-
if env["arch"] in ["arm", "arm32"]:
143-
rid = "arm"
144-
elif env["arch"] == "arm64":
145-
rid = "arm64"
146-
else:
147-
bits = env["bits"]
148-
bit_arch_map = {"64": "x64", "32": "x86"}
149-
rid = bit_arch_map[bits]
150-
return "%s-%s" % (names_map[platform], rid)
146+
return "%s-%s" % (names_map[platform], arch_map[env["arch"]])
151147
else:
152148
raise NotImplementedError()
153149

modules/mono/editor/GodotTools/GodotTools/Export/AotBuilder.cs

+24-20
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,17 @@ public static void CompileAssemblies(ExportPlugin exporter, AotOptions aotOpts,
7575
}
7676
else
7777
{
78-
string bits = features.Contains("64") ? "64" : features.Contains("32") ? "32" : null;
79-
CompileAssembliesForDesktop(exporter, platform, isDebug, bits, aotOpts, aotTempDir, outputDataDir, assembliesPrepared, bclDir);
78+
string arch = "";
79+
if (features.Contains("x86_64")) {
80+
arch = "x86_64";
81+
} else if (features.Contains("x86_32")) {
82+
arch = "x86_32";
83+
} else if (features.Contains("arm64")) {
84+
arch = "arm64";
85+
} else if (features.Contains("arm32")) {
86+
arch = "arm32";
87+
}
88+
CompileAssembliesForDesktop(exporter, platform, isDebug, arch, aotOpts, aotTempDir, outputDataDir, assembliesPrepared, bclDir);
8089
}
8190
}
8291

@@ -112,7 +121,7 @@ public static void CompileAssembliesForAndroid(ExportPlugin exporter, bool isDeb
112121
}
113122
}
114123

115-
public static void CompileAssembliesForDesktop(ExportPlugin exporter, string platform, bool isDebug, string bits, AotOptions aotOpts, string aotTempDir, string outputDataDir, IDictionary<string, string> assemblies, string bclDir)
124+
public static void CompileAssembliesForDesktop(ExportPlugin exporter, string platform, bool isDebug, string arch, AotOptions aotOpts, string aotTempDir, string outputDataDir, IDictionary<string, string> assemblies, string bclDir)
116125
{
117126
foreach (var assembly in assemblies)
118127
{
@@ -126,9 +135,9 @@ public static void CompileAssembliesForDesktop(ExportPlugin exporter, string pla
126135
string outputFileName = assemblyName + ".dll" + outputFileExtension;
127136
string tempOutputFilePath = Path.Combine(aotTempDir, outputFileName);
128137

129-
var compilerArgs = GetAotCompilerArgs(platform, isDebug, bits, aotOpts, assemblyPath, tempOutputFilePath);
138+
var compilerArgs = GetAotCompilerArgs(platform, isDebug, arch, aotOpts, assemblyPath, tempOutputFilePath);
130139

131-
string compilerDirPath = GetMonoCrossDesktopDirName(platform, bits);
140+
string compilerDirPath = GetMonoCrossDesktopDirName(platform, arch);
132141

133142
ExecuteCompiler(FindCrossCompiler(compilerDirPath), compilerArgs, bclDir);
134143

@@ -432,9 +441,9 @@ private static IEnumerable<string> GetAotCompilerArgs(string platform, bool isDe
432441

433442
var androidToolPrefixes = new Dictionary<string, string>
434443
{
435-
["armeabi-v7a"] = "arm-linux-androideabi-",
436-
["arm64-v8a"] = "aarch64-linux-android-",
437-
["x86"] = "i686-linux-android-",
444+
["arm32"] = "arm-linux-androideabi-",
445+
["arm64"] = "aarch64-linux-android-",
446+
["x86_32"] = "i686-linux-android-",
438447
["x86_64"] = "x86_64-linux-android-"
439448
};
440449

@@ -547,9 +556,9 @@ private static IEnumerable<string> GetEnabledAndroidAbis(string[] features)
547556
{
548557
var androidAbis = new[]
549558
{
550-
"armeabi-v7a",
551-
"arm64-v8a",
552-
"x86",
559+
"arm32",
560+
"arm64",
561+
"x86_32",
553562
"x86_64"
554563
};
555564
@@ -560,9 +569,9 @@ private static string GetAndroidTriple(string abi)
560569
{
561570
var abiArchs = new Dictionary<string, string>
562571
{
563-
["armeabi-v7a"] = "armv7",
564-
["arm64-v8a"] = "aarch64-v8a",
565-
["x86"] = "i686",
572+
["arm32"] = "armv7",
573+
["arm64"] = "aarch64-v8a",
574+
["x86_32"] = "i686",
566575
["x86_64"] = "x86_64"
567576
};
568577
@@ -571,30 +580,25 @@ private static string GetAndroidTriple(string abi)
571580
return $"{arch}-linux-android";
572581
}
573582
574-
private static string GetMonoCrossDesktopDirName(string platform, string bits)
583+
private static string GetMonoCrossDesktopDirName(string platform, string arch)
575584
{
576585
switch (platform)
577586
{
578587
case OS.Platforms.Windows:
579588
case OS.Platforms.UWP:
580589
{
581-
string arch = bits == "64" ? "x86_64" : "i686";
582590
return $"windows-{arch}";
583591
}
584592
case OS.Platforms.MacOS:
585593
{
586-
Debug.Assert(bits == null || bits == "64");
587-
string arch = "x86_64";
588594
return $"{platform}-{arch}";
589595
}
590596
case OS.Platforms.LinuxBSD:
591597
{
592-
string arch = bits == "64" ? "x86_64" : "i686";
593598
return $"linux-{arch}";
594599
}
595600
case OS.Platforms.Haiku:
596601
{
597-
string arch = bits == "64" ? "x86_64" : "i686";
598602
return $"{platform}-{arch}";
599603
}
600604
default:

modules/raycast/SCsub

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ if env["builtin_embree"]:
6666
env_raycast.Append(CPPDEFINES=["EMBREE_TARGET_SSE2", "EMBREE_LOWEST_ISA", "TASKING_INTERNAL", "NDEBUG"])
6767

6868
if not env.msvc:
69-
if env["arch"] in ["x86", "x86_64"]:
69+
if env["arch"] == "x86_64":
7070
env_raycast.Append(CPPFLAGS=["-msse2", "-mxsave"])
7171

7272
if env["platform"] == "windows":
@@ -83,7 +83,7 @@ if env["builtin_embree"]:
8383
env_thirdparty.disable_warnings()
8484
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_sources)
8585

86-
if not env["arch"] in ["x86", "x86_64"] or env.msvc:
86+
if env["arch"] == "arm64" or env.msvc:
8787
# Embree needs those, it will automatically use SSE2NEON in ARM
8888
env_thirdparty.Append(CPPDEFINES=["__SSE2__", "__SSE__"])
8989

modules/raycast/config.py

+2-14
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
11
def can_build(env, platform):
2-
# Depends on Embree library, which only supports x86_64 and aarch64.
3-
if env["arch"].startswith("rv") or env["arch"].startswith("ppc"):
4-
return False
5-
6-
if platform == "android":
7-
return env["android_arch"] in ["arm64v8", "x86_64"]
8-
9-
if platform == "javascript":
10-
return False # No SIMD support yet
11-
12-
if env["bits"] == "32":
13-
return False
14-
15-
return True
2+
# Depends on Embree library, which only supports x86_64 and arm64.
3+
return env["arch"] in ["x86_64", "arm64"]
164

175

186
def configure(env):

platform/android/SCsub

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ lib = env_android.add_shared_library("#bin/libgodot", [android_objects], SHLIBSU
4141
env.Depends(lib, thirdparty_obj)
4242

4343
lib_arch_dir = ""
44-
if env["android_arch"] == "armv7":
44+
if env["arch"] == "arm32":
4545
lib_arch_dir = "armeabi-v7a"
46-
elif env["android_arch"] == "arm64v8":
46+
elif env["arch"] == "arm64":
4747
lib_arch_dir = "arm64-v8a"
48-
elif env["android_arch"] == "x86":
48+
elif env["arch"] == "x86_32":
4949
lib_arch_dir = "x86"
50-
elif env["android_arch"] == "x86_64":
50+
elif env["arch"] == "x86_64":
5151
lib_arch_dir = "x86_64"
5252
else:
5353
print("WARN: Architecture not suitable for embedding into APK; keeping .so at \\bin")

0 commit comments

Comments
 (0)