godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.68k stars 20.11k forks source link

How to build godot on windows arm64ec using MSVC #70470

Closed YangYang129 closed 5 months ago

YangYang129 commented 1 year ago

Godot version

master 56b828e

System information

Windows Server 2022 Datacenter

Issue description

We try MSVC to run scons tools=no target=release verbose=yes build on x64, it works. I found scons support arch: CPU architecture (auto|x86_32|x86_64|arm32|arm64|rv64|ppc32|ppc64|wasm32) does not ARM64EC. How to build godot on windows arm64ec using MSVC. Could you please help look at this issue? Thanks in advance.

Steps to reproduce

  1. Open VS2019 x64 tools command
  2. git clone https://github.com/godotengine/godot F:\godot
  3. cd F:\godot
  4. python.exe -m pip install scons 2>&1
  5. scons --help

Minimal reproduction project

scons: Reading SConscript files ... Automatically detected platform: windows Auto-detected 16 CPU cores available for build parallelism. Using 15 cores by default. You can override it with the -j argument. Found MSVC, arch x86_64 Building for platform "windows", architecture "x86_64", target "editor". Checking for C header file mntent.h... no scons: done reading SConscript files.

platform: Target platform (windows) default: actual: windows

p: Platform (alias for 'platform') default: actual:

target: Compilation target (editor|template_release|template_debug) default: editor actual: editor

arch: CPU architecture (auto|x86_32|x86_64|arm32|arm64|rv64|ppc32|ppc64|wasm32) default: auto actual: auto

dev_build: Developer build with dev-only debugging code (DEV_ENABLED) (yes|no) default: False actual: False

optimize: Optimization level (none|custom|debug|speed|speed_trace|size) default: speed_trace actual: speed_trace

debug_symbols: Build with debugging symbols (yes|no) default: True actual: True

separate_debug_symbols: Extract debugging symbols to a separate file (yes|no) default: False actual: False

lto: Link-time optimization (production builds) (none|auto|thin|full) default: none actual: none

production: Set defaults to build Godot for use in production (yes|no) default: False actual: False

deprecated: Enable compatibility code for deprecated and removed features (yes|no) default: True actual: True

precision: Set the floating-point precision level (single|double) default: single actual: single

minizip: Enable ZIP archive support using minizip (yes|no) default: True actual: True

xaudio2: Enable the XAudio2 audio driver (yes|no) default: False actual: False

vulkan: Enable the vulkan rendering driver (yes|no) default: True actual: True

opengl3: Enable the OpenGL/GLES3 rendering driver (yes|no) default: True actual: True

openxr: Enable the OpenXR driver (yes|no) default: True actual: True

use_volk: Use the volk library to load the Vulkan loader dynamically (yes|no) default: True actual: True

custom_modules: A list of comma-separated directory paths containing custom modules to build. default: actual:

custom_modules_recursive: Detect custom modules recursively for each specified path. (yes|no) default: True actual: True

dev_mode: Alias for dev options: verbose=yes warnings=extra werror=yes tests=yes (yes|no) default: False actual: False

tests: Build the unit tests (yes|no) default: False actual: False

fast_unsafe: Enable unsafe options for faster rebuilds (yes|no) default: False actual: False

compiledb: Generate compilation DB (compile_commands.json) for external tools (yes|no) default: False actual: False

verbose: Enable verbose output for the compilation (yes|no) default: False actual: False

progress: Show a progress indicator during compilation (yes|no) default: True actual: True

warnings: Level of compilation warnings (extra|all|moderate|no) default: all actual: all

werror: Treat compiler warnings as errors (yes|no) default: False actual: False

extra_suffix: Custom extra suffix added to the base filename of all generated binary files default: actual:

vsproj: Generate a Visual Studio solution (yes|no) default: False actual: False

disable_3d: Disable 3D nodes for a smaller executable (yes|no) default: False actual: False

disable_advanced_gui: Disable advanced GUI nodes and behaviors (yes|no) default: False actual: False

build_feature_profile: Path to a file containing a feature build profile default: actual:

modules_enabled_by_default: If no, disable all modules except ones explicitly enabled (yes|no) default: True actual: True

no_editor_splash: Don't use the custom splash screen for the editor (yes|no) default: True actual: True

system_certs_path: Use this path as SSL certificates default for editor (for package maintainers) default: actual:

use_precise_math_checks: Math checks use very precise epsilon (debug option) (yes|no) default: False actual: False

builtin_certs: Use the built-in SSL certificates bundles (yes|no) default: True actual: True

builtin_embree: Use the built-in Embree library (yes|no) default: True actual: True

builtin_enet: Use the built-in ENet library (yes|no) default: True actual: True

builtin_freetype: Use the built-in FreeType library (yes|no) default: True actual: True

builtin_msdfgen: Use the built-in MSDFgen library (yes|no) default: True actual: True

builtin_glslang: Use the built-in glslang library (yes|no) default: True actual: True

builtin_graphite: Use the built-in Graphite library (yes|no) default: True actual: True

builtin_harfbuzz: Use the built-in HarfBuzz library (yes|no) default: True actual: True

builtin_icu: Use the built-in ICU library (yes|no) default: True actual: True

builtin_libogg: Use the built-in libogg library (yes|no) default: True actual: True

builtin_libpng: Use the built-in libpng library (yes|no) default: True actual: True

builtin_libtheora: Use the built-in libtheora library (yes|no) default: True actual: True

builtin_libvorbis: Use the built-in libvorbis library (yes|no) default: True actual: True

builtin_libwebp: Use the built-in libwebp library (yes|no) default: True actual: True

builtin_wslay: Use the built-in wslay library (yes|no) default: True actual: True

builtin_mbedtls: Use the built-in mbedTLS library (yes|no) default: True actual: True

builtin_miniupnpc: Use the built-in miniupnpc library (yes|no) default: True actual: True

builtin_pcre2: Use the built-in PCRE2 library (yes|no) default: True actual: True

builtin_pcre2_with_jit: Use JIT compiler for the built-in PCRE2 library (yes|no) default: True actual: True

builtin_recast: Use the built-in Recast library (yes|no) default: True actual: True

builtin_rvo2: Use the built-in RVO2 library (yes|no) default: True actual: True

builtin_squish: Use the built-in squish library (yes|no) default: True actual: True

builtin_xatlas: Use the built-in xatlas library (yes|no) default: True actual: True

builtin_zlib: Use the built-in zlib library (yes|no) default: True actual: True

builtin_zstd: Use the built-in Zstd library (yes|no) default: True actual: True

CXX: C++ compiler default: None actual: cl

CC: C compiler default: None actual: cl

LINK: Linker default: None actual: link

CCFLAGS: Custom flags for both the C and C++ compilers default: None actual: /nologo

CFLAGS: Custom flags for the C compiler default: None actual:

CXXFLAGS: Custom flags for the C++ compiler default: None actual: /TP

LINKFLAGS: Custom flags for the linker default: None actual: /nologo

mingw_prefix: MinGW prefix default: actual:

target_win_version: Targeted Windows version, >= 0x0601 (Windows 7) default: 0x0601 actual: 0x0601

windows_subsystem: Windows subsystem (gui|console) default: gui actual: gui

msvc_version: MSVC version to use. Ignored if VCINSTALLDIR is set in shell env. default: None actual: None

use_mingw: Use the Mingw compiler, even if MSVC is installed. (yes|no) default: False actual: False

use_llvm: Use the LLVM compiler (yes|no) default: False actual: False

use_static_cpp: Link MinGW/MSVC C++ runtime libraries statically (yes|no) default: True actual: True

use_asan: Use address sanitizer (ASAN) (yes|no) default: False actual: False

debug_crt: Compile with MSVC's debug CRT (/MDd) (yes|no) default: False actual: False

module_basis_universal_enabled: Enable module 'basis_universal' (yes|no) default: True actual: True

module_bmp_enabled: Enable module 'bmp' (yes|no) default: True actual: True

module_camera_enabled: Enable module 'camera' (yes|no) default: True actual: True

module_csg_enabled: Enable module 'csg' (yes|no) default: True actual: True

module_cvtt_enabled: Enable module 'cvtt' (yes|no) default: True actual: True

module_dds_enabled: Enable module 'dds' (yes|no) default: True actual: True

module_denoise_enabled: Enable module 'denoise' (yes|no) default: True actual: True

module_enet_enabled: Enable module 'enet' (yes|no) default: True actual: True

module_etcpak_enabled: Enable module 'etcpak' (yes|no) default: True actual: True

brotli: Enable Brotli decompressor for WOFF2 fonts support (yes|no) default: True actual: True

module_freetype_enabled: Enable module 'freetype' (yes|no) default: True actual: True

module_gdscript_enabled: Enable module 'gdscript' (yes|no) default: True actual: True

module_glslang_enabled: Enable module 'glslang' (yes|no) default: True actual: True

module_gltf_enabled: Enable module 'gltf' (yes|no) default: True actual: True

module_gridmap_enabled: Enable module 'gridmap' (yes|no) default: True actual: True

module_hdr_enabled: Enable module 'hdr' (yes|no) default: True actual: True

module_jpg_enabled: Enable module 'jpg' (yes|no) default: True actual: True

module_jsonrpc_enabled: Enable module 'jsonrpc' (yes|no) default: True actual: True

module_lightmapper_rd_enabled: Enable module 'lightmapper_rd' (yes|no) default: True actual: True

module_mbedtls_enabled: Enable module 'mbedtls' (yes|no) default: True actual: True

module_meshoptimizer_enabled: Enable module 'meshoptimizer' (yes|no) default: True actual: True

module_minimp3_enabled: Enable module 'minimp3' (yes|no) default: True actual: True

module_mobile_vr_enabled: Enable module 'mobile_vr' (yes|no) default: True actual: True

module_mono_enabled: Enable module 'mono' (yes|no) default: False actual: False

module_msdfgen_enabled: Enable module 'msdfgen' (yes|no) default: True actual: True

module_multiplayer_enabled: Enable module 'multiplayer' (yes|no) default: True actual: True

module_navigation_enabled: Enable module 'navigation' (yes|no) default: True actual: True

module_noise_enabled: Enable module 'noise' (yes|no) default: True actual: True

module_ogg_enabled: Enable module 'ogg' (yes|no) default: True actual: True

module_openxr_enabled: Enable module 'openxr' (yes|no) default: True actual: True

module_raycast_enabled: Enable module 'raycast' (yes|no) default: True actual: True

module_regex_enabled: Enable module 'regex' (yes|no) default: True actual: True

module_squish_enabled: Enable module 'squish' (yes|no) default: True actual: True

module_svg_enabled: Enable module 'svg' (yes|no) default: True actual: True

graphite: Enable SIL Graphite smart fonts support (yes|no) default: True actual: True

module_text_server_adv_enabled: Enable module 'text_server_adv' (yes|no) default: True actual: True

module_text_server_fb_enabled: Enable module 'text_server_fb' (yes|no) default: False actual: False

module_tga_enabled: Enable module 'tga' (yes|no) default: True actual: True

module_theora_enabled: Enable module 'theora' (yes|no) default: True actual: True

module_tinyexr_enabled: Enable module 'tinyexr' (yes|no) default: True actual: True

module_upnp_enabled: Enable module 'upnp' (yes|no) default: True actual: True

module_vhacd_enabled: Enable module 'vhacd' (yes|no) default: True actual: True

module_vorbis_enabled: Enable module 'vorbis' (yes|no) default: True actual: True

module_webp_enabled: Enable module 'webp' (yes|no) default: True actual: True

module_webrtc_enabled: Enable module 'webrtc' (yes|no) default: True actual: True

module_websocket_enabled: Enable module 'websocket' (yes|no) default: True actual: True

module_webxr_enabled: Enable module 'webxr' (yes|no) default: True actual: True

module_xatlas_unwrap_enabled: Enable module 'xatlas_unwrap' (yes|no) default: True actual: True

module_zip_enabled: Enable module 'zip' (yes|no) default: True actual: True

Use scons -H for help about command-line options.

akien-mga commented 1 year ago

Did you try scons p=windows arch=arm64?

arm64 is to be understood as a generic, 64-bit ARM target. It might not be compatible with all variants of 64-bit ARM but unless proven otherwise, it's likely to work just fine for ARM64EC.

For the record, tools=no target=release is obsolete, that's the options for Godot 3.x but it changed in Godot 4.0. You should now use target=template_release if you want a release template (other options are target=template_debug and target=editor).

bruvzg commented 1 year ago

ARM64EC is not a separate architecture, it's a modified ABI to make x86 app porting easier. What's the purpose of building Godot with it instead of normal ARM64?

You can try setting up additional environment variables when building with arch=arm64 (not tested).

CXXFLAGS = "/arm64EC"
CFLAGS = "/arm64EC"
LINKFLAGS = "/MACHINE:ARM64EC"
ARFLAGS = "/MACHINE:ARM64EC"
bruvzg commented 1 year ago

You can try setting up additional environment variables when building with arch=arm64 (not tested).

Done some testing, most of the third party libraries with SIMD do not support it and won't build (including zstd which is required for building core), so it won't work.

Normal ARM64 build works with disabled raycast module (module_raycast_enabled=no).

lucidium4 commented 1 year ago

ARM64EC is not a separate architecture, it's a modified ABI to make x86 app porting easier. What's the purpose of building Godot with it instead of normal ARM64?

I guess to use a native ARM64 build with x86 GDExtension Libraries.

mhilbrunner commented 5 months ago

Hey! The engine Github issue tracker is not really suited to discussions like these, other community channels like the forum or developer Rocketchat may be better to ask questions like this. :)

Zhaojun-Liu commented 1 month ago

Did you try scons p=windows arch=arm64?

Hi @akien-mga and @bruvzg, I tried to build Godot on Windows with VS2022, cross-build, host is amd64, target architecture is arm64, but it failed due to ERROR: Arch argument (arm64) is not matching Native/Cross Compile Tools Prompt/Developer Console (or Visual Studio settings) that is being used to run SCons (x86_64), my build steps are as follows, can you take a look? Thanks so much.

  1. Open VS2022 x64 Native Tools command.
  2. git clone https://github.com/godotengine/godot C:\gitP\godotengine\godot
  3. python.exe -m pip install scons
  4. set VSCMD_SKIP_SENDTELEMETRY=1 & "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" -host_arch=amd64 -arch=arm64
  5. cd /d C:\gitP\godotengine\godot
  6. scons platform=windows arch=arm64

Actual result:

##[command] Command #2 (Output in "Build.log"):  scons platform=windows arch=arm64 2>&1
scons: Reading SConscript files ...
Auto-detected 8 CPU cores available for build parallelism. Using 7 cores by default. You can override it with the -j argument.
ERROR: Arch argument (arm64) is not matching Native/Cross Compile Tools Prompt/Developer Console (or Visual Studio settings) that is being used to run SCons (x86_64).
Run SCons again without arch argument (example: scons p=windows) and SCons will attempt to detect what MSVC compiler will be executed and inform you. 
##[debug] Command #2 exited with code [255].
##[error] Detected error code [255].
bruvzg commented 1 month ago

Open VS2022 x64 Native Tools command.

Use either VS ARM64 Tools environment, or generic terminal session (it should detect VS installation and setup environment automatically).

Zhaojun-Liu commented 1 month ago

Open VS2022 x64 Native Tools command.

Use either VS ARM64 Tools environment, or generic terminal session (it should detect VS installation and setup environment automatically).

Step 4 is to set the environment to arm64, no other generic terminal session.

Zhaojun-Liu commented 1 month ago

Open VS2022 x64 Native Tools command.

Use either VS ARM64 Tools environment, or generic terminal session (it should detect VS installation and setup environment automatically).

Maybe I didn't make it clear, we are doing cross-compilation, building for target ARM64 on an amd64 machine. So, is this build not supported or is there some step I'm missing? Looking forward your reply. Thanks so much. @bruvzg