From 7fb14ffa4f2f730181997d7da5abdd4d6037acee Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 26 Jun 2026 03:13:19 +0200 Subject: [PATCH 01/76] cmake,VirtualMachine: append the architecture name to loader binaries, implement box64 fallback, detect armhf multiarch support --- CMakeLists.txt | 14 +- src/engine/framework/VirtualMachine.cpp | 493 +++++++++++++----- .../nacl_multiarch.cpp} | 20 +- 3 files changed, 371 insertions(+), 156 deletions(-) rename tools/{nacl_helper_bootstrap-armhf/nacl_helper_bootstrap-armhf.cpp => nacl_multiarch/nacl_multiarch.cpp} (84%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6af566d9bf..d5e4b209dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -974,7 +974,7 @@ if (DEPS_DIR AND HAS_NACL AND (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER add_custom_command(TARGET runtime_deps PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DEPS_DIR}/nacl_loader${CMAKE_EXECUTABLE_SUFFIX} - ${FULL_OUTPUT_DIR}/nacl_loader${CMAKE_EXECUTABLE_SUFFIX} + ${FULL_OUTPUT_DIR}/nacl_loader-${DAEMON_NACL_ARCH_NAME}${CMAKE_EXECUTABLE_SUFFIX} ) add_custom_command(TARGET runtime_deps PRE_BUILD @@ -986,13 +986,11 @@ if (DEPS_DIR AND HAS_NACL AND (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER # Linux uses a bootstrap program to reserve address space if (YOKAI_TARGET_SYSTEM_LINUX_COMPATIBILITY) if (YOKAI_TARGET_ARCH_ARM64) - add_executable(nacl_helper_bootstrap-armhf tools/nacl_helper_bootstrap-armhf/nacl_helper_bootstrap-armhf.cpp) - add_dependencies(runtime_deps nacl_helper_bootstrap-armhf) - - add_custom_command(TARGET runtime_deps PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E make_directory - ${FULL_OUTPUT_DIR}/lib-armhf + add_executable(nacl_multiarch-${DAEMON_NACL_ARCH_NAME} + tools/nacl_multiarch/nacl_multiarch.cpp + ${BUILDINFOLIST} ) + add_dependencies(runtime_deps nacl_multiarch-${DAEMON_NACL_ARCH_NAME}) add_custom_command(TARGET runtime_deps PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory @@ -1004,7 +1002,7 @@ if (DEPS_DIR AND HAS_NACL AND (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER add_custom_command(TARGET runtime_deps PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DEPS_DIR}/nacl_helper_bootstrap - ${FULL_OUTPUT_DIR}/nacl_helper_bootstrap + ${FULL_OUTPUT_DIR}/nacl_helper_bootstrap-${DAEMON_NACL_ARCH_NAME} ) endif() diff --git a/src/engine/framework/VirtualMachine.cpp b/src/engine/framework/VirtualMachine.cpp index df2739b9f3..859bb9b168 100644 --- a/src/engine/framework/VirtualMachine.cpp +++ b/src/engine/framework/VirtualMachine.cpp @@ -75,6 +75,15 @@ static Cvar::Cvar workaround_naclSystem_freebsd_disableQualification( "Disable platform qualification when running Linux NaCl loader on FreeBSD through Linuxulator", Cvar::NONE, true); +#if defined(DAEMON_NACL_RUNTIME_ENABLED) +// Many BSDs have a Linuxulator, for now we only tested one. +#if defined(__linux__) || defined(__FreeBSD__) +#define DAEMON_NACL_RUNTIME_LINUX +#define DAEMON_NACL_BOOSTRAP_ENABLED +#endif // defined(__linux__) || defined(DAEMON_LINUXULATOR) +#endif // defined(DAEMON_NACL_RUNTIME_ENABLED) + +#if defined(DAEMON_NACL_RUNTIME_ENABLED) #if defined(DAEMON_NACL_BOX64_EMULATION) static Cvar::Cvar workaround_box64_disableQualification( "workaround.box64.disableQualification", @@ -88,14 +97,41 @@ static Cvar::Cvar workaround_box64_disableBootstrap( static Cvar::Cvar vm_box64_path( "vm.box64.path", - "Path to the box64 binary for NaCl emulation (empty = search PATH)", + "Path to the box64 binary for NaCl emulation (empty = use provided one or search PATH if missing)", Cvar::NONE, ""); -// Resolve box64 binary path by searching PATH if not explicitly set. -static std::string ResolveBox64Path() { - std::string path = vm_box64_path.Get(); - if (!path.empty()) { - return path; +// Resolve box64 binary path by looking for a provided one or searching PATH if not explicitly set. +static std::string ResolveBox64Path(std::string naclPath) { + std::string requestedPath = vm_box64_path.Get(); + + if (requestedPath.empty()) { + std::string providedPath = FS::Path::Build(naclPath, "box64"); + + if (FS::RawPath::FileExists(providedPath)) { + const std::string libs_linux_amd64 = "libs-linux-amd64"; + const std::string libgcc_linux_amd64 = "libgcc_s.so.1"; + + std::string libsDirPath = FS::Path::Build(naclPath, libs_linux_amd64); + std::string libGccPath = FS::Path::Build(libsDirPath, libgcc_linux_amd64); + + if (FS::RawPath::FileExists(libGccPath)) { + Sys::SetEnv("BOX64_LD_LIBRARY_PATH", libsDirPath.c_str()); + } + else { + Log::Warn("Using provided Box64 executable but the libraries are missing."); + } + + return providedPath; + } + + Log::Warn("Box64 emulation is enabled but the executable is not provided with the engine: %s", providedPath); + } + + if (!FS::RawPath::FileExists(requestedPath)) { + Sys::Error("Box64 emulation is enabled but the requested executable is missing: %s", requestedPath); + } + else { + return requestedPath; } const char* envPath = getenv("PATH"); @@ -121,34 +157,47 @@ static std::string ResolveBox64Path() { "Install Box64 or set vm.box64.path to the full path of the box64 binary."); return ""; // unreachable } -#endif +#endif // DAEMON_NACL_BOX64_EMULATION +#endif // DAEMON_NACL_RUNTIME_ENABLED + +#if defined(DAEMON_NACL_RUNTIME_ENABLED) +static constexpr bool vmAvailable = true; +#else // !defined(DAEMON_NACL_RUNTIME_ENABLED) +static constexpr bool vmAvailable = false; +#endif // !defined(DAEMON_NACL_RUNTIME_ENABLED) + +static Cvar::Cvar vm_nacl_available( + "vm.nacl.available", + "Whether NaCl runtime is available on this platform", + Cvar::ROM, vmAvailable); + +#if defined(DAEMON_NACL_RUNTIME_ENABLED) +static Cvar::Cvar vm_timeout( + "vm.timeout", + "Receive timeout in seconds", + Cvar::NONE, 2); static Cvar::Cvar vm_nacl_qualification( "vm.nacl.qualification", "Enable NaCl loader platform qualification", Cvar::INIT, true); +#endif // defined(DAEMON_NACL_RUNTIME_ENABLED) + +#if defined(DAEMON_NACL_RUNTIME_ENABLED) +#if defined(DAEMON_NACL_RUNTIME_LINUX) && defined(YOKAI_ARCH_ARM64) +static Cvar::Cvar vm_nacl_multiarch( + "vm.nacl.multiarch", + "Use multiarch to run the NaCl loader when needed and available", + Cvar::INIT, true); +#endif // defined(DAEMON_NACL_RUNTIME_LINUX) && defined(YOKAI_ARCH_ARM64) +#endif // defined(DAEMON_NACL_RUNTIME_ENABLED) +#if defined(DAEMON_NACL_BOOSTRAP_ENABLED) static Cvar::Cvar vm_nacl_bootstrap( "vm.nacl.bootstrap", "Use NaCl bootstrap helper", Cvar::INIT, true); - -static Cvar::Cvar vm_timeout( - "vm.timeout", - "Receive timeout in seconds", - Cvar::NONE, 2); - -#if defined(DAEMON_NACL_RUNTIME_ENABLED) -static Cvar::Cvar vm_nacl_available( - "vm.nacl.available", - "Whether NaCl runtime is available on this platform", - Cvar::ROM, true); -#else -static Cvar::Cvar vm_nacl_available( - "vm.nacl.available", - "Whether NaCl runtime is available on this platform", - Cvar::ROM, false); -#endif +#endif // defined(DAEMON_NACL_BOOSTRAP_ENABLED) namespace VM { @@ -300,57 +349,225 @@ static std::pair InternalLoadModule(std::pair(probe.data()), + nullptr, + }; + + execve(probe.data(), argv, environ); + + switch (errno) + { + case ENOEXEC: + // The kernel cannot execute the probe. + _exit(100); + + case ENOENT: + case EACCES: + // Missing or inaccessible probe. + _exit(101); + + default: + _exit(102); + } + } + + int status; + if (waitpid(pid, &status, 0) < 0) { + return ExeSupport::Unknown; + } + + if (!WIFEXITED(status)) { + return ExeSupport::Unknown; + } + + switch (WEXITSTATUS(status)) + { + case 100: + return ExeSupport::Unsupported; + + case 101: + case 102: + return ExeSupport::Unknown; + + default: + // The probe has been executed properly. + return ExeSupport::Supported; + } +} +#endif // defined(DAEMON_NACL_RUNTIME_LINUX) && defined(NACL_ARCH_ARM64) + +#if defined(DAEMON_NACL_RUNTIME_ENABLED) static std::pair CreateNaClVM(std::pair pair, Str::StringRef name, bool debug, bool extract, int debugLoader) { CheckMinAddressSysctlTooLarge(); const std::string& libPath = FS::GetLibPath(); -#ifdef DAEMON_NACL_RUNTIME_PATH - const char* naclPath = DAEMON_NACL_RUNTIME_PATH_STRING; -#else - const std::string& naclPath = libPath; -#endif std::vector args; char rootSocketRedir[32]; - std::string module, nacl_loader, irt, bootstrap, modulePath, verbosity; FS::File stderrRedirect; -#if defined(DAEMON_NACL_BOX64_EMULATION) - std::string box64Path; - bool usingBox64 = false; -#endif + bool inheritEnvironment = false; + +#if defined(DAEMON_NACL_RUNTIME_PATH) + const char* naclPath = DAEMON_NACL_RUNTIME_PATH_STRING; +#else // !defined(DAEMON_NACL_RUNTIME_PATH) + const std::string& naclPath = libPath; +#endif // !defined(DAEMON_NACL_RUNTIME_PATH) + #if !defined(_WIN32) || defined(_WIN64) - constexpr bool win32Force64Bit = false; -#else + constexpr bool i686ForceAmd64 = false; +#else // !( !defined(_WIN32) || defined(_WIN64) ) // On Windows, even if we are running a 32-bit engine, we must use the // 64-bit nacl_loader if the host operating system is 64-bit. SYSTEM_INFO systemInfo; GetNativeSystemInfo(&systemInfo); - const bool win32Force64Bit = systemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64; + bool i686ForceAmd64 = systemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64; +#endif // !( !defined(_WIN32) || defined(_WIN64) ) + + std::string multiarchPath; + +#if defined(DAEMON_NACL_RUNTIME_LINUX) && defined(YOKAI_ARCH_ARM64) + bool hasMultiarch = vm_nacl_multiarch.Get(); +#else + constexpr bool hasMultiarch = false; + Q_UNUSED(multiarchPath); #endif + std::string bootstrapPath; + +#if defined(DAEMON_NACL_BOOSTRAP_ENABLED) + bool hasBootstrap = vm_nacl_bootstrap.Get(); +#else // !defined(DAEMON_NACL_BOOSTRAP_ENABLED) + constexpr bool hasBootstrap = false; + Q_UNUSED(bootstrapPath); +#endif // !defined(DAEMON_NACL_BOOSTRAP_ENABLED) + + std::string box64Path; + +#if defined(DAEMON_NACL_BOX64_EMULATION) + constexpr bool hasBox64 = true; +#else // !defined(DAEMON_NACL_BOX64_EMULATION) + constexpr bool hasBox64 = false; + Q_UNUSED(box64Path); +#endif // !defined(DAEMON_NACL_BOX64_EMULATION) + +#if defined(DAEMON_NACL_RUNTIME_LINUX) +#if defined(YOKAI_ARCH_ARM64) + /* We later turn this boolean off when we detect armhf support is not + provided on arm64. */ + bool hasArmhf = true; +#elif defined(YOKAI_ARCH_ARMHF) + constexpr bool hasArmhf = false; +#endif // !defined(YOKAI_ARCH_ARMHF) +#endif // !defined(DAEMON_NACL_RUNTIME_LINUX) + + bool useMultiarch = hasMultiarch; + bool useBox64 = hasBox64; + +#if defined(DAEMON_NACL_RUNTIME_LINUX) && defined(YOKAI_ARCH_ARM64) + const std::string libs_linux_armhf = "lib-armhf"; + const std::string libld_linux_armhf = "ld-linux-armhf"; + + std::string libsDirPath = FS::Path::Build(libPath, libs_linux_armhf); + std::string libLoaderPath = FS::Path::Build(libsDirPath, libld_linux_armhf); + + switch (CheckExeSupport(libLoaderPath)) + { + case ExeSupport::Supported: + Log::Notice("Working multiarch support."); + break; + + case ExeSupport::Unsupported: + Log::Notice("Unsupported multiarch."); + hasArmhf = false; + break; + + case ExeSupport::Unknown: + Log::Warn("Cannot determine multiarch support."); + hasArmhf = false; + break; + } + + if (!hasArmhf) { + useMultiarch = false; + } +#endif // defined(DAEMON_NACL_RUNTIME_LINUX) && defined(YOKAI_ARCH_ARM64) + + if (useMultiarch && useBox64) { + Log::Notice("Preferring multiarch over Box64 emulation."); + useBox64 = false; + } + + bool useBootstrap = hasBootstrap; + +#if defined(DAEMON_NACL_BOX64_EMULATION) + if (useBootstrap) { + /* Use Box64 to run the x86_64 NaCl loader on non-x86 architectures. + The bootstrap helper uses a double-exec pattern that Box64 cannot handle, + so we skip it and prepend "box64" to the nacl_loader command instead. */ + if (useBox64 + && workaround_box64_disableBootstrap.Get()) { + useBootstrap = false; + } + } +#endif // defined(DAEMON_NACL_BOX64_EMULATION) + + std::string arch = (useBox64 || i686ForceAmd64) ? "amd64" : DAEMON_NACL_ARCH_STRING; + + std::string moduleName = Str::Format("%s-%s.nexe", name, arch); + std::string irt = FS::Path::Build(naclPath, Str::Format("irt_core-%s.nexe", arch)); + std::string nacl_loader = FS::Path::Build(naclPath, Str::Format("nacl_loader-%s%s", arch, EXE_EXT)); + + std::string modulePath; + // Extract the nexe from the pak so that nacl_loader can load it - module = win32Force64Bit - ? name + "-amd64.nexe" - : Str::Format("%s-%s.nexe", name, DAEMON_NACL_ARCH_STRING); if (extract) { try { - FS::File out = FS::HomePath::OpenWrite(module); - if (const FS::LoadedPakInfo* pak = FS::PakPath::LocateFile(module)) - Log::Notice("Extracting VM module %s from %s...", module.c_str(), pak->path.c_str()); - FS::PakPath::CopyFile(module, out); + FS::File out = FS::HomePath::OpenWrite(moduleName); + if (const FS::LoadedPakInfo* pak = FS::PakPath::LocateFile(moduleName)) + Log::Notice("Extracting VM module %s from %s...", moduleName.c_str(), pak->path.c_str()); + FS::PakPath::CopyFile(moduleName, out); out.Close(); } catch (std::system_error& err) { - Sys::Drop("VM: Failed to extract VM module %s: %s", module, err.what()); + Sys::Drop("VM: Failed to extract VM module %s: %s", moduleName, err.what()); } - modulePath = FS::Path::Build(FS::GetHomePath(), module); + modulePath = FS::Path::Build(FS::GetHomePath(), moduleName); } else { - modulePath = FS::Path::Build(libPath, module); + modulePath = FS::Path::Build(libPath, moduleName); } // Generate command line Q_snprintf(rootSocketRedir, sizeof(rootSocketRedir), "%d:%d", ROOT_SOCKET_FD, (int)(intptr_t)pair.second.GetHandle()); - irt = FS::Path::Build(naclPath, win32Force64Bit - ? "irt_core-amd64.nexe" - : Str::Format("irt_core-%s.nexe", DAEMON_NACL_ARCH_STRING)); - nacl_loader = FS::Path::Build(naclPath, win32Force64Bit ? "nacl_loader-amd64" EXE_EXT : "nacl_loader" EXE_EXT); if (!FS::RawPath::FileExists(modulePath)) { Sys::Error("VM module file not found: %s", modulePath); @@ -364,99 +581,108 @@ static std::pair CreateNaClVM(std::pair Error while loading "sgame-armhf.nexe": CPU model is not supported + > Error while loading "sgame-armhf.nexe": CPU model is not supported - From nacl_loader --help we can read: + From nacl_loader --help we can read: - > -Q disable platform qualification (dangerous!) + > -Q disable platform qualification (dangerous!) - When this option is enabled, nacl_loader will print: + When this option is enabled, nacl_loader will print: - > PLATFORM QUALIFICATION DISABLED BY -Q - Native Client's sandbox will be unreliable! + > PLATFORM QUALIFICATION DISABLED BY -Q - Native Client's sandbox will be unreliable! - But the nexe will load and run. */ + But the nexe will load and run. */ - if (onArm64) { - Log::Warn("Disabling NaCL platform qualification on arm64 kernel architecture."); - enableQualification = false; - } + if (onArm64) { + Log::Warn("Disabling NaCl platform qualification on arm64 kernel architecture."); + enableQualification = false; } -#endif + } +#endif // defined(__linux__) && (defined(YOKAI_ARCH_ARM64) || defined(YOKAI_ARCH_ARMHF)) + +#if defined(DAEMON_NACL_BOX64_EMULATION) + if (enableQualification + && useBox64 + && workaround_box64_disableQualification.Get()) { + /* When running the amd64 NaCl loader under Box64, the loader's + platform qualification will fail because the CPU is not actually x86_64. + Disabling qualification allows the emulated loader to proceed. */ + + Log::Warn("Disabling NaCl platform qualification for Box64 emulation."); + enableQualification = false; + } +#endif // defined(DAEMON_NACL_BOX64_EMULATION) #if defined(__FreeBSD__) + if (enableQualification + && workaround_naclSystem_freebsd_disableQualification.Get()) { /* While it is possible to build a native FreeBSD engine, the only available NaCl loader is the Linux one, which can run on Linuxulator (the FreeBSD Linux compatibility layer). @@ -466,26 +692,10 @@ static std::pair CreateNaClVM(std::pair CreateNaClVM(std::pair CreateNaClVM(std::pair CreateNaClVM(std::pair CreateNativeVM(std::pair pair, Str::StringRef name, bool debug) { const std::string& libPath = FS::GetLibPath(); @@ -622,7 +831,9 @@ void VMBase::Create() } #endif if (type == TYPE_NACL || type == TYPE_NACL_LIBPATH) { +#if defined(DAEMON_NACL_RUNTIME_ENABLED) std::tie(processHandle, rootSocket) = CreateNaClVM(std::move(pair), name, params.debug.Get(), type == TYPE_NACL, params.debugLoader.Get()); +#endif // defined(DAEMON_NACL_RUNTIME_ENABLED) } else if (type == TYPE_NATIVE_EXE) { std::tie(processHandle, rootSocket) = CreateNativeVM(std::move(pair), name, params.debug.Get()); } else { diff --git a/tools/nacl_helper_bootstrap-armhf/nacl_helper_bootstrap-armhf.cpp b/tools/nacl_multiarch/nacl_multiarch.cpp similarity index 84% rename from tools/nacl_helper_bootstrap-armhf/nacl_helper_bootstrap-armhf.cpp rename to tools/nacl_multiarch/nacl_multiarch.cpp index ec16447482..84c4b28bfe 100644 --- a/tools/nacl_helper_bootstrap-armhf/nacl_helper_bootstrap-armhf.cpp +++ b/tools/nacl_multiarch/nacl_multiarch.cpp @@ -35,7 +35,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include "YokaiBuildInfo/DaemonEngine.h" + int main(int argc, char *argv[]) { + if (argc < 2) { + printf("nacl_multiarch-%s: missing command line\n", DAEMON_NACL_ARCH_STRING); + return 1; + } + char *directory = dirname(strdup(argv[0])); int err = chdir(directory); @@ -44,19 +51,18 @@ int main(int argc, char *argv[]) { return err; } - err = putenv(strdup("LD_LIBRARY_PATH=lib-armhf")); + char env[100]; + sprintf(env, "LD_LIBRARY_PATH=lib-%s", DAEMON_NACL_ARCH_STRING); + + err = putenv(strdup(env)); if (err != 0) { return err; } - char *helper = strdup("./nacl_helper_bootstrap"); - argv[0] = helper; - - execv(helper, argv); + execv(argv[1], &argv[1]); // The execv() function returns only if an error has occurred. - printf("nacl_helper_bootstrap-armhf: %s\n", strerror(errno)); - + printf("nacl_multiarch-%s: %s\n", DAEMON_NACL_ARCH_STRING, strerror(errno)); return 1; } From 0836a86a4a42bfcf9e2624c406ddf182ca07e5eb Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 3 Jul 2026 12:40:34 +0200 Subject: [PATCH 02/76] cmake: rework the code enabling nexe build when there is an nacl sdk, taking saigo in account --- CMakeLists.txt | 69 +++++++++-------- cmake/DaemonGame.cmake | 61 +++++++++------ ...ost.cmake => DaemonNaclArchitecture.cmake} | 75 ++++++++++++------- 3 files changed, 124 insertions(+), 81 deletions(-) rename cmake/{DaemonNaclHost.cmake => DaemonNaclArchitecture.cmake} (62%) diff --git a/CMakeLists.txt b/CMakeLists.txt index d5e4b209dc..ea8eb1da16 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,7 +76,13 @@ if (Daemon_OUT) endif() include(Yokai/All) -include(DaemonNaclHost) + +include(DaemonNaclArchitecture) + +daemon_detect_nacl_arch("${YOKAI_TARGET_ARCH_NAME}") + +# Add printable strings to the executable. +yokai_add_buildinfo("char*" "DAEMON_NACL_ARCH_STRING" "\"${DAEMON_NACL_ARCH_NAME}\"") ################################################################################ # Configuration options @@ -970,22 +976,33 @@ if (DEPS_DIR AND HAS_NACL AND (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER add_custom_target(runtime_deps) set_target_properties(runtime_deps PROPERTIES FOLDER "CMakePlumbing") - # The NaCl loader and IRT are required to load .nexe files - add_custom_command(TARGET runtime_deps PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${DEPS_DIR}/nacl_loader${CMAKE_EXECUTABLE_SUFFIX} - ${FULL_OUTPUT_DIR}/nacl_loader-${DAEMON_NACL_ARCH_NAME}${CMAKE_EXECUTABLE_SUFFIX} - ) + foreach(arch_name IN LISTS DAEMON_NACL_ARCH_NAME_LIST) + # The NaCl loader and IRT are required to load .nexe files + if (YOKAI_TARGET_SYSTEM_WINDOWS AND YOKAI_TARGET_ARCH_I686 AND "${arch_name}" STREQUAL "amd64") + # Backport compatibility until the external_deps script properly suffixes names in the archives. + add_custom_command(TARGET runtime_deps PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${DEPS_DIR}/nacl_loader-${arch_name}${CMAKE_EXECUTABLE_SUFFIX} + ${FULL_OUTPUT_DIR}/nacl_loader-${arch_name}${CMAKE_EXECUTABLE_SUFFIX} + ) + else() + add_custom_command(TARGET runtime_deps PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${DEPS_DIR}/nacl_loader${CMAKE_EXECUTABLE_SUFFIX} + ${FULL_OUTPUT_DIR}/nacl_loader-${arch_name}${CMAKE_EXECUTABLE_SUFFIX} + ) + endif() - add_custom_command(TARGET runtime_deps PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${DEPS_DIR}/irt_core-${DAEMON_NACL_ARCH_NAME}.nexe - ${FULL_OUTPUT_DIR}/irt_core-${DAEMON_NACL_ARCH_NAME}.nexe - ) + add_custom_command(TARGET runtime_deps PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${DEPS_DIR}/irt_core-${arch_name}.nexe + ${FULL_OUTPUT_DIR}/irt_core-${arch_name}.nexe + ) + endforeach() # Linux uses a bootstrap program to reserve address space if (YOKAI_TARGET_SYSTEM_LINUX_COMPATIBILITY) - if (YOKAI_TARGET_ARCH_ARM64) + if (DAEMON_NACL_MULTIARCH) add_executable(nacl_multiarch-${DAEMON_NACL_ARCH_NAME} tools/nacl_multiarch/nacl_multiarch.cpp ${BUILDINFOLIST} @@ -999,25 +1016,13 @@ if (DEPS_DIR AND HAS_NACL AND (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER ) endif() - add_custom_command(TARGET runtime_deps PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${DEPS_DIR}/nacl_helper_bootstrap - ${FULL_OUTPUT_DIR}/nacl_helper_bootstrap-${DAEMON_NACL_ARCH_NAME} - ) - endif() - - # Win32 requires nacl_loader_amd64.exe in order to run on Win64 - if (YOKAI_TARGET_SYSTEM_WINDOWS AND YOKAI_TARGET_ARCH_I686) - add_custom_command(TARGET runtime_deps PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${DEPS_DIR}/nacl_loader-amd64${CMAKE_EXECUTABLE_SUFFIX} - ${FULL_OUTPUT_DIR}/nacl_loader-amd64${CMAKE_EXECUTABLE_SUFFIX} - ) - add_custom_command(TARGET runtime_deps PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${DEPS_DIR}/irt_core-amd64.nexe - ${FULL_OUTPUT_DIR}/irt_core-amd64.nexe - ) + foreach(arch_name IN LISTS DAEMON_NACL_ARCH_NAME_LIST) + add_custom_command(TARGET runtime_deps PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${DEPS_DIR}/nacl_helper_bootstrap + ${FULL_OUTPUT_DIR}/nacl_helper_bootstrap-${arch_name} + ) + endforeach() endif() # Mac requires some libraries from external_deps diff --git a/cmake/DaemonGame.cmake b/cmake/DaemonGame.cmake index f6adde3c7c..053f44a567 100644 --- a/cmake/DaemonGame.cmake +++ b/cmake/DaemonGame.cmake @@ -68,39 +68,56 @@ set(SHAREDLIST_sgame # Function to setup all the Sgame/Cgame libraries include(CMakeParseArguments) -# The NaCl SDK only runs on amd64 or i686. if (NOT FORK EQUAL 2) - if (CMAKE_SYSTEM_NAME STREQUAL CMAKE_HOST_SYSTEM_NAME + if (USE_NACL_SAIGO) + set(HAS_NACL_SDK ON) + elseif (CMAKE_SYSTEM_NAME STREQUAL CMAKE_HOST_SYSTEM_NAME AND (YOKAI_TARGET_ARCH_AMD64 OR YOKAI_TARGET_ARCH_I686)) + # The PNaCl SDK only runs on amd64 or i686. + set(HAS_NACL_SDK ON) + endif() + + if (HAS_NACL_SDK) + include(DaemonNaclArchitecture) + # can be loaded by daemon with vm.[sc]game.type 0 or 1 option(BUILD_GAME_NACL "Build the NaCl \"pexe\" and \"nexe\" gamelogic modules for enabled architecture targets, required to host mods." OFF) set(NACL_ALL_TARGETS "amd64;i686;armhf") - set(BUILD_GAME_NACL_TARGETS "all" CACHE STRING "Enabled NaCl \"nexe\" architecture targets, values: ${NACL_ALL_TARGETS}, all, native, none.") + set(BUILD_GAME_NACL_TARGETS "all" CACHE STRING "Enabled NaCl \"nexe\" architecture targets, values: ${NACL_ALL_TARGETS};all;native;none") mark_as_advanced(BUILD_GAME_NACL_TARGETS) - if (BUILD_GAME_NACL_TARGETS STREQUAL "all") - set(NACL_TARGETS "${NACL_ALL_TARGETS}") - elseif (BUILD_GAME_NACL_TARGETS STREQUAL "native") - set(NACL_TARGETS "${YOKAI_TARGET_ARCH_NAME}") - elseif (BUILD_GAME_NACL_TARGETS STREQUAL "none") - set(NACL_TARGETS "") - else() - set(NACL_TARGETS "${BUILD_GAME_NACL_TARGETS}") - endif() + if (BUILD_GAME_NACL) + foreach(nacl_target ${BUILD_GAME_NACL_TARGETS}) + if (BUILD_GAME_NACL_TARGETS STREQUAL "all") + list(APPEND nacl_target_list ${NACL_ALL_TARGETS}) + elseif (BUILD_GAME_NACL_TARGETS STREQUAL "native") + list(APPEND nacl_target_list "${YOKAI_TARGET_ARCH_NAME}") + elseif (BUILD_GAME_NACL_TARGETS STREQUAL "none") + set(nacl_target_list "") + else() + list(APPEND nacl_target_list "${nacl_target}") + endif() + endforeach() - foreach(NACL_TARGET ${NACL_TARGETS}) - set(IS_NACL_VALID_TARGET OFF) - foreach(NACL_VALID_TARGET ${NACL_ALL_TARGETS}) - if(NACL_TARGET STREQUAL NACL_VALID_TARGET) - set(IS_NACL_VALID_TARGET ON) + foreach(nacl_target IN LISTS nacl_target_list) + daemon_detect_nacl_arch("${nacl_target}") + + foreach(detected_target IN LISTS DAEMON_NACL_ARCH_NAME_LIST) + if (NOT "${detected_target}" IN_LIST NACL_TARGETS) + list(APPEND NACL_TARGETS ${detected_target}) + endif() + endforeach() + endforeach() + + foreach(nacl_target IN LISTS NACL_TARGETS) + if (NOT nacl_target IN_LIST NACL_ALL_TARGETS) + message(FATAL_ERROR "Invalid NaCl target ${nacl_target}, must be one of ${NACL_ALL_TARGETS}") endif() endforeach() - if (NOT IS_NACL_VALID_TARGET) - message(FATAL_ERROR "Invalid NaCl target ${NACL_TARGET}, must be one of ${NACL_ALL_TARGETS}") - endif() - endforeach() + message(STATUS "Building NaCl targets: ${NACL_TARGETS}") + endif() else() set(BUILD_GAME_NACL OFF) set(NACL_TARGETS "") @@ -207,7 +224,7 @@ function(GAMEMODULE) add_custom_target(nacl-vms ALL) unset(NACL_VMS_PROJECTS) - foreach(NACL_TARGET ${NACL_TARGETS}) + foreach(NACL_TARGET IN LISTS NACL_TARGETS) if (NACL_TARGET STREQUAL "i686") set(SAIGO_ARCH "i686") elseif (NACL_TARGET STREQUAL "amd64") diff --git a/cmake/DaemonNaclHost.cmake b/cmake/DaemonNaclArchitecture.cmake similarity index 62% rename from cmake/DaemonNaclHost.cmake rename to cmake/DaemonNaclArchitecture.cmake index 7172e71d55..ed267918c8 100644 --- a/cmake/DaemonNaclHost.cmake +++ b/cmake/DaemonNaclArchitecture.cmake @@ -24,60 +24,81 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -function(daemon_detect_nacl_arch) - set(target_arch "${YOKAI_TARGET_ARCH_NAME}") - set(nacl_arch "${target_arch}") +function(daemon_detect_nacl_arch target_arch) + macro(add_nacl_arch arch_name) + list(APPEND nacl_arch_list "${arch_name}") + endmacro() + + macro(add_nacl_multilib_arch arch_name) + add_nacl_arch("${arch_name}") + list(APPEND nacl_multilib_arch_list "${arch_name}") + endmacro() + + # NaCl runtime is only available on architectures that have a NaCl loader. + set(nacl_runtime_arch "amd64" "i686" "armhf") + + if (YOKAI_TARGET_SYSTEM_WINDOWS) + if("${target_arch}" STREQUAL "amd64") + add_nacl_arch("${target_arch}") + elseif("${target_arch}" STREQUAL "i686") + # Win32 requires nacl_loader-amd64.exe in order to run on Win64 + add_nacl_arch("${target_arch}") + add_nacl_arch("amd64") + endif() + elseif (YOKAI_TARGET_SYSTEM_LINUX_COMPATIBILITY OR YOKAI_TARGET_SYSTEM_XDG_COMPATIBILITY) + if ("${target_arch}" IN_LIST nacl_runtime_arch) + add_nacl_arch("${target_arch}") + endif() - if (YOKAI_TARGET_SYSTEM_LINUX_COMPATIBILITY OR YOKAI_TARGET_SYSTEM_XDG_COMPATIBILITY) set(armhf_usage "arm64" "armel") - set(box64_usage "ppc64el" "riscv64") + set(box64_usage "ppc64el" "riscv64" "loong64") if ("${target_arch}" IN_LIST armhf_usage) + set(DAEMON_NACL_MULTIARCH ON) + # Load 32-bit armhf nexe on 64-bit arm64 engine on Linux with multiarch. # The nexe is system agnostic so there should be no difference with armel. - set(nacl_arch "armhf") - elseif ("${target_arch}" IN_LIST box64_usage) + add_nacl_multilib_arch("armhf") + endif() + + if ("${target_arch}" IN_LIST box64_usage) option(DAEMON_NACL_BOX64_EMULATION "Use Box64 to emulate x86_64 NaCl loader on unsupported platforms" ON) + if (DAEMON_NACL_BOX64_EMULATION) # Use Box64 to run x86_64 NaCl loader and amd64 nexe. # Box64 must be installed and available in PATH at runtime. - set(nacl_arch "amd64") + add_nacl_multilib_arch("amd64") add_definitions(-DDAEMON_NACL_BOX64_EMULATION) endif() endif() elseif (YOKAI_TARGET_SYSTEM_MACOS) - if ("${target_arch}" STREQUAL "arm64") + if ("${target_arch}" STREQUAL "amd64") + add_nacl_arch("${target_arch}") + elseif ("${target_arch}" STREQUAL "arm64") # You can get emulated NaCl going like this: # cp external_deps/macos-amd64-default_10/{nacl_loader,irt_core-amd64.nexe} build/ - set(nacl_arch "amd64") + add_nacl_arch("amd64") endif() endif() - string(TOUPPER "${nacl_arch}" nacl_arch_upper) + if (nacl_arch_list) + message(STATUS "Available NaCl architectures: ${nacl_arch_list}") - # NaCl runtime is only available on architectures that have a NaCl loader. - set(nacl_runtime_arch "amd64" "i686" "armhf") - if ("${nacl_arch}" IN_LIST nacl_runtime_arch) - message(STATUS "Detected NaCl architecture: ${nacl_arch}") + list(GET nacl_arch_list 0 nacl_arch) + + message(STATUS "Primary NaCl architecture: ${nacl_arch}") add_definitions(-DDAEMON_NACL_RUNTIME_ENABLED) else() set(nacl_arch "unknown") - message(STATUS "No NaCl architecture detected") + message(STATUS "No known NaCl architecture") endif() # The DAEMON_NACL_ARCH_NAME variable contributes to the nexe file name. set(DAEMON_NACL_ARCH_NAME "${nacl_arch}" PARENT_SCOPE) - - set(DAEMON_NACL_ARCH_NAME_UPPER "${nacl_arch_upper}" PARENT_SCOPE) + # Those names are used to copy the loader and the IRT binaries. + set(DAEMON_NACL_ARCH_NAME_LIST "${nacl_arch_list}" PARENT_SCOPE) + # Those names are used to copy the libraries for the loader. + set(DAEMON_NACL_MULTILIB_ARCH_NAME_LIST "${nacl_multilib_arch_list}" PARENT_SCOPE) endfunction() - -daemon_detect_nacl_arch() - -# Makes possible to do that in CMake code: -# > if (DAEMON_NACL_ARCH_ARMHF) -set("DAEMON_NACL_ARCH_${DAEMON_NACL_ARCH_NAME_UPPER}" ON) - -# Add printable strings to the executable. -yokai_add_buildinfo("char*" "DAEMON_NACL_ARCH_STRING" "\"${DAEMON_NACL_ARCH_NAME}\"") From 770f58c38a912cb7e971dbfed91bb790e3262a84 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 4 Jul 2026 10:57:36 +0200 Subject: [PATCH 03/76] cmake: deeply rewrite the NaCl toolchains --- CMakeLists.txt | 28 ++--- cmake/DaemonGame.cmake | 87 +++++++------ cmake/DaemonNacl.cmake | 81 ------------ cmake/DaemonNaclFlags.cmake | 75 +++++++++++ cmake/DaemonPNaClFinalize.cmake | 79 ++++++++++++ cmake/DaemonSaigoFinalize.cmake | 56 +++++++++ cmake/cross-toolchain-pnacl.cmake | 106 ++++++++++++++++ cmake/cross-toolchain-saigo-amd64.cmake | 28 +++++ cmake/cross-toolchain-saigo-armhf.cmake | 28 +++++ cmake/cross-toolchain-saigo-common.cmake | 79 ++++++++++++ cmake/cross-toolchain-saigo-i686.cmake | 39 ++++++ cmake/toolchain-pnacl.cmake | 151 ----------------------- cmake/toolchain-saigo.cmake | 75 ----------- 13 files changed, 554 insertions(+), 358 deletions(-) delete mode 100644 cmake/DaemonNacl.cmake create mode 100644 cmake/DaemonNaclFlags.cmake create mode 100644 cmake/DaemonPNaClFinalize.cmake create mode 100644 cmake/DaemonSaigoFinalize.cmake create mode 100644 cmake/cross-toolchain-pnacl.cmake create mode 100644 cmake/cross-toolchain-saigo-amd64.cmake create mode 100644 cmake/cross-toolchain-saigo-armhf.cmake create mode 100644 cmake/cross-toolchain-saigo-common.cmake create mode 100644 cmake/cross-toolchain-saigo-i686.cmake delete mode 100644 cmake/toolchain-pnacl.cmake delete mode 100644 cmake/toolchain-saigo.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index ea8eb1da16..ecd565af4e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,12 +77,14 @@ endif() include(Yokai/All) -include(DaemonNaclArchitecture) +if (NOT YOKAI_TARGET_SYSTEM_NACL) + include(DaemonNaclArchitecture) -daemon_detect_nacl_arch("${YOKAI_TARGET_ARCH_NAME}") + daemon_detect_nacl_arch("${YOKAI_TARGET_ARCH_NAME}") -# Add printable strings to the executable. -yokai_add_buildinfo("char*" "DAEMON_NACL_ARCH_STRING" "\"${DAEMON_NACL_ARCH_NAME}\"") + # Add printable strings to the executable. + yokai_add_buildinfo("char*" "DAEMON_NACL_ARCH_STRING" "\"${DAEMON_NACL_ARCH_NAME}\"") +endif() ################################################################################ # Configuration options @@ -272,6 +274,12 @@ endif() option(USE_EXTERNAL_DEPS_LIBS "Build and link against libraries from the EXTERNAL_DEPS_DIR" ${DEFAULT_USE_EXTERNAL_DEPS_LIBS}) +set(PNACLSDK_PREFIX "${DEPS_DIR}/pnacl" CACHE PATH "PNaCl SDK path") +mark_as_advanced(PNACLSDK_PREFIX) + +set(SAIGOSDK_PREFIX "${DEPS_DIR}/saigo_newlib" CACHE PATH "Saigo NaCl SDK path") +mark_as_advanced(SAIGOSDK_PREFIX) + if (USE_EXTERNAL_DEPS AND NOT YOKAI_TARGET_SYSTEM_NACL) if (DEPS_DIR) message(STATUS "Using external deps dir: ${DEPS_DIR}") @@ -298,6 +306,7 @@ endif() # meaning we have to detect useless engine compiler to set # useless engine flags when only building vms. include(DaemonFlags) +include(DaemonNaclFlags) # FIXME: Once engine flags would be only set when building the engine # this would be likely unused by vms as they are built by DaemonGame. @@ -469,7 +478,6 @@ endif() # LIBS_BASE, LIBS_ENGINE_BASE LIBS_ENGINE, LIBS_BASECLIENT, LIBS_CLIENT # Native client -include(DaemonNacl) if (YOKAI_TARGET_SYSTEM_NACL) add_library(srclibs-nacl-module EXCLUDE_FROM_ALL ${NACLLIST_MODULE}) set(LIBS_BASE ${LIBS_BASE} srclibs-nacl-module) @@ -490,16 +498,6 @@ elseif (YOKAI_TARGET_SYSTEM_NACL) find_library(NACL_EXCEPTION nacl_exception) find_library(NACL_MINIDUMP minidump_generator) - # HACK: To be removed when Saigo is repackaged properly. - if (NOT NACL_MINIDUMP - # NACL_TARGET is specific to Saigo, PNaCl target is le32 and doesn't set NACL_TARGET. - AND "${NACL_TARGET}" STREQUAL "i686" - # x86_64-nacl/lib32 is specific to Google build, other builds may provide i686-nacl/lib instead. - AND EXISTS "${DEPS_DIR}/saigo_newlib/x86_64-nacl/lib32") - set(NACL_EXCEPTION "${DEPS_DIR}/saigo_newlib/x86_64-nacl/lib32/libnacl_exception.a") - set(NACL_MINIDUMP "${DEPS_DIR}/saigo_newlib/x86_64-nacl/lib32/libminidump_generator.a") - endif() - set(LIBS_BASE ${LIBS_BASE} ${NACL_MINIDUMP} ${NACL_EXCEPTION}) else() find_library(LIBM m) diff --git a/cmake/DaemonGame.cmake b/cmake/DaemonGame.cmake index 053f44a567..8a4cc2e4ff 100644 --- a/cmake/DaemonGame.cmake +++ b/cmake/DaemonGame.cmake @@ -44,9 +44,9 @@ include(Yokai/All) # Do not report unused native compiler if native vms are not built. # If only NACL vms are built, this will be reported in chainloaded build. -if (BUILD_GAME_NATIVE_DLL OR BUILD_GAME_NATIVE_EXE OR NACL) - include(DaemonNacl) +if (BUILD_GAME_NATIVE_DLL OR BUILD_GAME_NATIVE_EXE OR GAME_BUILD_SUBINVOCATION) include(DaemonFlags) + include(DaemonNaclFlags) endif() # Source lists for src/shared @@ -68,7 +68,11 @@ set(SHAREDLIST_sgame # Function to setup all the Sgame/Cgame libraries include(CMakeParseArguments) -if (NOT FORK EQUAL 2) +list(APPEND NACL_ALL_TARGETS "amd64" "i686" "armhf") + +if (NOT GAME_BUILD_SUBINVOCATION) + option(USE_NACL_SAIGO "Use the Saigo toolchain to build NaCl executables" OFF) + if (USE_NACL_SAIGO) set(HAS_NACL_SDK ON) elseif (CMAKE_SYSTEM_NAME STREQUAL CMAKE_HOST_SYSTEM_NAME @@ -77,23 +81,24 @@ if (NOT FORK EQUAL 2) set(HAS_NACL_SDK ON) endif() + list(APPEND NACL_ALL_TARGETS "amd64" "i686" "armhf") + if (HAS_NACL_SDK) include(DaemonNaclArchitecture) # can be loaded by daemon with vm.[sc]game.type 0 or 1 option(BUILD_GAME_NACL "Build the NaCl \"pexe\" and \"nexe\" gamelogic modules for enabled architecture targets, required to host mods." OFF) - set(NACL_ALL_TARGETS "amd64;i686;armhf") set(BUILD_GAME_NACL_TARGETS "all" CACHE STRING "Enabled NaCl \"nexe\" architecture targets, values: ${NACL_ALL_TARGETS};all;native;none") mark_as_advanced(BUILD_GAME_NACL_TARGETS) if (BUILD_GAME_NACL) foreach(nacl_target ${BUILD_GAME_NACL_TARGETS}) - if (BUILD_GAME_NACL_TARGETS STREQUAL "all") + if ("${nacl_target}" STREQUAL "all") list(APPEND nacl_target_list ${NACL_ALL_TARGETS}) - elseif (BUILD_GAME_NACL_TARGETS STREQUAL "native") + elseif ("${nacl_target}" STREQUAL "native") list(APPEND nacl_target_list "${YOKAI_TARGET_ARCH_NAME}") - elseif (BUILD_GAME_NACL_TARGETS STREQUAL "none") + elseif ("${nacl_target}" STREQUAL "none") set(nacl_target_list "") else() list(APPEND nacl_target_list "${nacl_target}") @@ -105,7 +110,7 @@ if (NOT FORK EQUAL 2) foreach(detected_target IN LISTS DAEMON_NACL_ARCH_NAME_LIST) if (NOT "${detected_target}" IN_LIST NACL_TARGETS) - list(APPEND NACL_TARGETS ${detected_target}) + list(APPEND NACL_TARGETS "${detected_target}") endif() endforeach() endforeach() @@ -151,7 +156,7 @@ function(buildGameModule module_slug) if (module_slug STREQUAL "nacl") set_target_properties(${module_target} PROPERTIES OUTPUT_NAME "${GAMEMODULE_NAME}" - SUFFIX "${PLATFORM_EXE_SUFFIX}") + SUFFIX "${NACL_EXECUTABLE_SUFFIX}") target_link_libraries(${module_target} ${GAMEMODULE_LIBS} ${LIBS_BASE}) else() @@ -167,13 +172,13 @@ function(gameSubProject) BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NACL_VMS_PROJECT} CMAKE_GENERATOR ${VM_GENERATOR} CMAKE_ARGS - -DFORK=2 - -DDAEMON_DIR=${Daemon_SOURCE_DIR} - -DDEPS_DIR=${DEPS_DIR} + "-DDAEMON_DIR=${Daemon_SOURCE_DIR}" + "-DDEPS_DIR=${DEPS_DIR}" -DBUILD_CLIENT=OFF -DBUILD_TTY_CLIENT=OFF -DBUILD_SERVER=OFF - -DBUILD_DUMMY_GAMELOGIC=${BUILD_DUMMY_GAMELOGIC} + "-DBUILD_DUMMY_GAMELOGIC=${BUILD_DUMMY_GAMELOGIC}" + -DGAME_BUILD_SUBINVOCATION=ON ${ARGV} ${INHERITED_OPTION_ARGS} INSTALL_COMMAND "" @@ -203,8 +208,9 @@ function(GAMEMODULE) buildGameModule("native-exe") endif() - if (NOT FORK) # create the nacl-vms target only the first time that GAMEMODULE is called - set(FORK 1 PARENT_SCOPE) + if (NOT NACL_VMS_TARGET_CREATED AND NOT GAME_BUILD_SUBINVOCATION) + # Create the nacl-vms target only the first time that GAMEMODULE is called. + set(NACL_VMS_TARGET_CREATED ON PARENT_SCOPE) if (CMAKE_GENERATOR MATCHES "Visual Studio") set(VM_GENERATOR "NMake Makefiles") @@ -219,34 +225,29 @@ function(GAMEMODULE) "-D${inherited_option}=${${inherited_option}}") endforeach(inherited_option) - if (BUILD_GAME_NACL) + if (BUILD_GAME_NACL AND NOT YOKAI_TARGET_SYSTEM_NACL) if (USE_NACL_SAIGO) add_custom_target(nacl-vms ALL) unset(NACL_VMS_PROJECTS) - foreach(NACL_TARGET IN LISTS NACL_TARGETS) - if (NACL_TARGET STREQUAL "i686") - set(SAIGO_ARCH "i686") - elseif (NACL_TARGET STREQUAL "amd64") - set(SAIGO_ARCH "x86_64") - elseif (NACL_TARGET STREQUAL "armhf") - set(SAIGO_ARCH "arm") - else() + foreach(nacl_target IN LISTS NACL_TARGETS) + if (NOT nacl_target IN_LIST NACL_ALL_TARGETS) message(FATAL_ERROR "Unknown NaCl architecture ${NACL_TARGET}") endif() - set(NACL_VMS_PROJECT nacl-vms-${NACL_TARGET}) + set(NACL_VMS_PROJECT nacl-vms-${nacl_target}) list(APPEND NACL_VMS_PROJECTS ${NACL_VMS_PROJECT}) add_dependencies(nacl-vms ${NACL_VMS_PROJECT}) + # TODO: Remove USE_NACL_SAIGO once the game uses YOKAI_TARGET_SYSTEM_NACL. gameSubProject( - -DCMAKE_TOOLCHAIN_FILE=${Daemon_SOURCE_DIR}/cmake/toolchain-saigo.cmake + "-DCMAKE_TOOLCHAIN_FILE=${Daemon_SOURCE_DIR}/cmake/cross-toolchain-saigo-${nacl_target}.cmake" + "-DSAIGOSDK_PREFIX=${SAIGOSDK_PREFIX}" + -DUSE_NACL_SAIGO=ON -DBUILD_GAME_NACL=ON -DBUILD_GAME_NATIVE_DLL=OFF -DBUILD_GAME_NATIVE_EXE=OFF -DUSE_NACL_SAIGO=ON - -DSAIGO_ARCH=${SAIGO_ARCH} - -DNACL_TARGET=${NACL_TARGET} ) endforeach() else() @@ -257,19 +258,21 @@ function(GAMEMODULE) string(REPLACE ";" "," NACL_TARGETS_STRING "${NACL_TARGETS}") gameSubProject( - -DCMAKE_TOOLCHAIN_FILE=${Daemon_SOURCE_DIR}/cmake/toolchain-pnacl.cmake + "-DCMAKE_TOOLCHAIN_FILE=${Daemon_SOURCE_DIR}/cmake/cross-toolchain-pnacl.cmake" + "-DPNACLSDK_PREFIX=${PNACLSDK_PREFIX}" + -DUSE_NACL_SAIGO=OFF -DBUILD_GAME_NACL=ON -DBUILD_GAME_NATIVE_DLL=OFF -DBUILD_GAME_NATIVE_EXE=OFF - -DNACL_TARGETS_STRING=${NACL_TARGETS_STRING} + "-DNACL_TARGETS_STRING=${NACL_TARGETS_STRING}" ) endif() endif() set(NACL_VMS_PROJECTS ${NACL_VMS_PROJECTS} PARENT_SCOPE) - elseif (FORK EQUAL 2) # we are in the CMake sub-invocation for NaCl + elseif (GAME_BUILD_SUBINVOCATION) if (BUILD_GAME_NACL) - if (USE_NACL_SAIGO) + if (YOKAI_CXX_COMPILER_SAIGO) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) else() # Put the .nexe and .pexe files in the same directory as the engine. @@ -278,16 +281,28 @@ function(GAMEMODULE) buildGameModule("nacl") - if (USE_NACL_SAIGO) + if (YOKAI_CXX_COMPILER_SAIGO) + include(DaemonSaigoFinalize) + # Finalize NaCl executables for supported architectures. - saigo_finalize(${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/.. ${GAMEMODULE_NAME} ${NACL_TARGET}) + saigo_finalize( + "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" + "${GAMEMODULE_NAME}" + "${YOKAI_TARGET_ARCH_NAME}" + ) else() + include(DaemonPNaClFinalize) + # Revert a workaround for a bug where CMake ExternalProject lists-as-args are cut on first “;” string(REPLACE "," ";" NACL_TARGETS "${NACL_TARGETS_STRING}") # Generate NaCl executables for supported architectures. - foreach(NACL_TARGET ${NACL_TARGETS}) - pnacl_finalize(${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${GAMEMODULE_NAME} ${NACL_TARGET}) + foreach(nacl_target ${NACL_TARGETS}) + pnacl_finalize( + "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" + "${GAMEMODULE_NAME}" + "${nacl_target}" + ) endforeach() endif() endif() diff --git a/cmake/DaemonNacl.cmake b/cmake/DaemonNacl.cmake deleted file mode 100644 index e37bf06844..0000000000 --- a/cmake/DaemonNacl.cmake +++ /dev/null @@ -1,81 +0,0 @@ -# Daemon BSD Source Code -# Copyright (c) 2013-2016, Daemon Developers -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the Daemon developers nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL DAEMON DEVELOPERS BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -# Native client - -option(USE_NACL_SAIGO "Use Saigo toolchain to build NaCl executables" OFF) - -if (YOKAI_TARGET_SYSTEM_NACL) - # Build nexe binary. - if(USE_NACL_SAIGO) - if (NACL_TARGET STREQUAL "amd64") - add_definitions(-DNACL_BUILD_ARCH=x86) - add_definitions(-DNACL_BUILD_SUBARCH=64) - elseif (NACL_TARGET STREQUAL "i686") - add_definitions(-DNACL_BUILD_ARCH=x86) - add_definitions(-DNACL_BUILD_SUBARCH=32) - elseif (NACL_TARGET STREQUAL "armhf") - add_definitions(-DNACL_BUILD_ARCH=arm) - else() - message(FATAL_ERROR "Unsupported architecture ${NACL_TARGET}") - endif() - else() - # Those defines looks to be meaningless to produce arch-independent pexe - # with PNaCl but they must be set to anything supported by native builds. - # This requirement looks to be a PNaCl bug. - add_definitions( -DNACL_BUILD_ARCH=x86 ) - add_definitions( -DNACL_BUILD_SUBARCH=64 ) - endif() -else() - # Build native dll or native exe. - if (YOKAI_TARGET_SYSTEM_MACOS) - add_definitions( -DNACL_WINDOWS=0 -DNACL_LINUX=0 -DNACL_ANDROID=0 -DNACL_FREEBSD=0 -DNACL_OSX=1 ) - elseif (YOKAI_TARGET_SYSTEM_LINUX) - add_definitions( -DNACL_WINDOWS=0 -DNACL_LINUX=1 -DNACL_ANDROID=0 -DNACL_FREEBSD=0 -DNACL_OSX=0 ) - elseif (YOKAI_TARGET_SYSTEM_FREEBSD) - add_definitions( -DNACL_WINDOWS=0 -DNACL_LINUX=0 -DNACL_ANDROID=0 -DNACL_FREEBSD=1 -DNACL_OSX=0 ) - elseif (YOKAI_TARGET_SYSTEM_WINDOWS) - add_definitions( -DNACL_WINDOWS=1 -DNACL_LINUX=0 -DNACL_ANDROID=0 -DNACL_FREEBSD=0 -DNACL_OSX=0 ) - endif() - - if (YOKAI_TARGET_ARCH_AMD64) - add_definitions( -DNACL_BUILD_ARCH=x86 ) - add_definitions( -DNACL_BUILD_SUBARCH=64 ) - elseif (YOKAI_TARGET_ARCH_I686) - add_definitions( -DNACL_BUILD_ARCH=x86 ) - add_definitions( -DNACL_BUILD_SUBARCH=32 ) - elseif (YOKAI_TARGET_ARCH_ARMHF) - add_definitions( -DNACL_BUILD_ARCH=arm ) - else() - # NaCl does not support this architecture natively, but these defines must - # be set because nacl_config.h is included unconditionally. Use dummy x86 - # values as PNaCl does for architecture-independent builds. - add_definitions( -DNACL_BUILD_ARCH=x86 ) - add_definitions( -DNACL_BUILD_SUBARCH=64 ) - endif() -endif() - -include_directories( ${LIB_DIR}/nacl ) diff --git a/cmake/DaemonNaclFlags.cmake b/cmake/DaemonNaclFlags.cmake new file mode 100644 index 0000000000..cbdc4b5a3f --- /dev/null +++ b/cmake/DaemonNaclFlags.cmake @@ -0,0 +1,75 @@ +# Daemon BSD Source Code +# Copyright (c) 2013-2026, Daemon Developers +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the Daemon developers nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL DAEMON DEVELOPERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# Native Client build configuration. + +if (YOKAI_TARGET_SYSTEM_NACL) + # Build nexe binary. + + if (YOKAI_CXX_COMPILER_SAIGO) + if (YOKAI_TARGET_ARCH_AMD64) + add_definitions(-DNACL_BUILD_ARCH=x86 -DNACL_BUILD_SUBARCH=64) + elseif (YOKAI_TARGET_ARCH_I686) + add_definitions(-DNACL_BUILD_ARCH=x86 -DNACL_BUILD_SUBARCH=32) + elseif (YOKAI_TARGET_ARCH_ARMHF) + add_definitions(-DNACL_BUILD_ARCH=arm) + else() + message(FATAL_ERROR "Unsupported architecture ${NACL_TARGET}") + endif() + else() + # Those defines looks to be meaningless to produce arch-independent pexe + # with PNaCl but they must be set to anything supported by native builds. + # This requirement looks to be a PNaCl bug. + add_definitions(-DNACL_BUILD_ARCH=x86 -DNACL_BUILD_SUBARCH=64) + endif() +else() + # Build native dll or native exe. + + if (YOKAI_TARGET_SYSTEM_MACOS) + add_definitions(-DNACL_WINDOWS=0 -DNACL_LINUX=0 -DNACL_ANDROID=0 -DNACL_FREEBSD=0 -DNACL_OSX=1) + elseif (YOKAI_TARGET_SYSTEM_LINUX) + add_definitions(-DNACL_WINDOWS=0 -DNACL_LINUX=1 -DNACL_ANDROID=0 -DNACL_FREEBSD=0 -DNACL_OSX=0) + elseif (YOKAI_TARGET_SYSTEM_FREEBSD) + add_definitions(-DNACL_WINDOWS=0 -DNACL_LINUX=0 -DNACL_ANDROID=0 -DNACL_FREEBSD=1 -DNACL_OSX=0) + elseif (YOKAI_TARGET_SYSTEM_WINDOWS) + add_definitions(-DNACL_WINDOWS=1 -DNACL_LINUX=0 -DNACL_ANDROID=0 -DNACL_FREEBSD=0 -DNACL_OSX=0) + endif() + + if (YOKAI_TARGET_ARCH_AMD64) + add_definitions(-DNACL_BUILD_ARCH=x86 -DNACL_BUILD_SUBARCH=64) + elseif (YOKAI_TARGET_ARCH_I686) + add_definitions(-DNACL_BUILD_ARCH=x86 -DNACL_BUILD_SUBARCH=32) + elseif (YOKAI_TARGET_ARCH_ARMHF) + add_definitions(-DNACL_BUILD_ARCH=arm) + else() + # NaCl does not support this architecture natively, but these defines must + # be set because nacl_config.h is included unconditionally. Use dummy x86 + # values as PNaCl does for architecture-independent builds. + add_definitions(-DNACL_BUILD_ARCH=x86 -DNACL_BUILD_SUBARCH=64) + endif() +endif() + +include_directories(${LIB_DIR}/nacl) diff --git a/cmake/DaemonPNaClFinalize.cmake b/cmake/DaemonPNaClFinalize.cmake new file mode 100644 index 0000000000..2130490030 --- /dev/null +++ b/cmake/DaemonPNaClFinalize.cmake @@ -0,0 +1,79 @@ +# Daemon BSD Source Code +# Copyright (c) 2013-2026, Daemon Developers +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the Daemon developers nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL DAEMON DEVELOPERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +function(pnacl_finalize dir module arch) + include(DaemonBuildTypeGeneratorExpression) + + set(PNACL_TRANSLATE_OPTIONS + --allow-llvm-bitcode-input # FIXME: finalize as part of the build process + --pnacl-allow-exceptions + $<${RELEASE_GENEXP_COND}:-O3> + $<${DEBUG_GENEXP_COND}:-O0> + $<${RELWITHDEBINFO_GENEXP_COND}:-O2> + $<${MINSIZEREL_GENEXP_COND}:-O2> + ) + set(PEXE "${dir}/${module}${NACL_EXECUTABLE_SUFFIX}") + set(NEXE "${dir}/${module}-${arch}${NACL_TRANSLATED_EXECUTABLE_SUFFIX}") + set(STRIPPED_NEXE "${dir}/${module}-${arch}-stripped${NACL_TRANSLATED_EXECUTABLE_SUFFIX}") + + if (arch STREQUAL "i686") + set(PNACL_ARCH "i686") + elseif (arch STREQUAL "amd64") + set(PNACL_ARCH "x86-64") + elseif (arch STREQUAL "armhf") + set(PNACL_ARCH "arm") + else() + message(FATAL_ERROR "Unknown NaCl architecture ${arch}") + endif() + + add_custom_command( + OUTPUT ${NEXE} + COMMENT "Translating ${module} (${arch})" + DEPENDS ${PEXE} + COMMAND + ${PNACLPYTHON_PREFIX2} + "${PNACL_TRANSLATE}" + ${PNACL_TRANSLATE_OPTIONS} + -arch "${PNACL_ARCH}" + "${PEXE}" + -o "${NEXE}" + ) + + add_custom_command( + OUTPUT "${STRIPPED_NEXE}" + COMMENT "Stripping ${module} (${arch})" + DEPENDS "${NEXE}" + COMMAND + ${PNACLPYTHON_PREFIX2} + "${CMAKE_STRIP}" + -s + "${NEXE}" + -o "${STRIPPED_NEXE}" + ) + + add_custom_target("${module}-${arch}" ALL DEPENDS "${STRIPPED_NEXE}") + add_dependencies("${module}-${arch}" "${module}-nacl") +endfunction() diff --git a/cmake/DaemonSaigoFinalize.cmake b/cmake/DaemonSaigoFinalize.cmake new file mode 100644 index 0000000000..01f1cf1da5 --- /dev/null +++ b/cmake/DaemonSaigoFinalize.cmake @@ -0,0 +1,56 @@ +# Daemon BSD Source Code +# Copyright (c) 2023-2026, Daemon Developers +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the Daemon developers nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL DAEMON DEVELOPERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +function(saigo_finalize dir module arch) + set(SUBPROJECT_NEXE "${dir}/${module}${NACL_EXECUTABLE_SUFFIX}") + set(NEXE "${dir}/../${module}-${arch}${NACL_EXECUTABLE_SUFFIX}") + set(STRIPPED_NEXE "${dir}/../${module}-${arch}-stripped${NACL_EXECUTABLE_SUFFIX}") + + add_custom_command( + OUTPUT "${NEXE}" + COMMENT "Copying ${module} (${arch})" + DEPENDS "${SUBPROJECT_NEXE}" + COMMAND + ${CMAKE_COMMAND} + -E copy + "${SUBPROJECT_NEXE}" + "${NEXE}" + ) + + add_custom_command( + OUTPUT "${STRIPPED_NEXE}" + COMMENT "Stripping ${module} (${arch})" + DEPENDS "${NEXE}" + COMMAND + "${CMAKE_STRIP}" + -s + "${NEXE}" + -o "${STRIPPED_NEXE}" + ) + + add_custom_target("${module}-${arch}" ALL DEPENDS "${STRIPPED_NEXE}") + add_dependencies("${module}-${arch}" "${module}-nacl") +endfunction() diff --git a/cmake/cross-toolchain-pnacl.cmake b/cmake/cross-toolchain-pnacl.cmake new file mode 100644 index 0000000000..eb71dbc5cc --- /dev/null +++ b/cmake/cross-toolchain-pnacl.cmake @@ -0,0 +1,106 @@ +# Daemon BSD Source Code +# Copyright (c) 2013-2026, Daemon Developers +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the Daemon developers nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL DAEMON DEVELOPERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# We can't use CMAKE_EXECUTABLE_SUFFIX because the Generic Platform will reset it +# and creating a Platform module for setting CMAKE_EXECUTABLE_SUFFIX is overkill. +set(NACL_EXECUTABLE_SUFFIX ".pexe") +set(NACL_TRANSLATED_EXECUTABLE_SUFFIX ".nexe") + +if (CMAKE_HOST_WIN32) + set(PNACL_EXECUTABLE_SUFFIX ".bat") +else() + set(PNACL_EXECUTABLE_SUFFIX "") +endif() + +set(PNACL_TRIPLET "pnacl") + +if ("${PNACLSDK_PREFIX}" STREQUAL "") + find_program(PATH_PNACL_CLANG NAMES "${PNACL_TRIPLET}-clang${PNACL_EXECUTABLE_SUFFIX}") + get_filename_component(PNACLSDK_PREFIX ${PATH_PNACL_CLANG} DIRECTORY) +endif() + +list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES PNACLSDK_PREFIX) + +set(CMAKE_SYSTEM_NAME "Generic") + +set(CMAKE_C_COMPILER "${PNACLSDK_PREFIX}/bin/${PNACL_TRIPLET}-clang${PNACL_EXECUTABLE_SUFFIX}") +set(CMAKE_CXX_COMPILER "${PNACLSDK_PREFIX}/bin/${PNACL_TRIPLET}-clang++${PNACL_EXECUTABLE_SUFFIX}") +set(CMAKE_AR "${PNACLSDK_PREFIX}/bin/${PNACL_TRIPLET}-ar${PNACL_EXECUTABLE_SUFFIX}" CACHE FILEPATH "Archiver" FORCE) +set(CMAKE_RANLIB "${PNACLSDK_PREFIX}/bin/${PNACL_TRIPLET}-ranlib${PNACL_EXECUTABLE_SUFFIX}") +set(PNACL_TRANSLATE "${PNACLSDK_PREFIX}/bin/${PNACL_TRIPLET}-translate${PNACL_EXECUTABLE_SUFFIX}") +set(CMAKE_STRIP "${PNACLSDK_PREFIX}/bin/${PNACL_TRIPLET}-strip${PNACL_EXECUTABLE_SUFFIX}") +set(CMAKE_FIND_ROOT_PATH "${PNACLSDK_PREFIX}/le32-nacl") + +set(CMAKE_C_USE_RESPONSE_FILE_FOR_LIBRARIES 1) +set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_LIBRARIES 1) +set(CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS 1) +set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS 1) +set(CMAKE_C_USE_RESPONSE_FILE_FOR_INCLUDES 1) +set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES 1) +set(CMAKE_C_RESPONSE_FILE_LINK_FLAG "@") +set(CMAKE_CXX_RESPONSE_FILE_LINK_FLAG "@") + +set(CMAKE_C_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG") +set(CMAKE_C_FLAGS_RELEASE_INIT "-O3 -DNDEBUG") +set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-O2 -g -DNDEBUG") +set(CMAKE_C_FLAGS_DEBUG_INIT "-g") + +set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "${CMAKE_C_FLAGS_MINSIZEREL_INIT}") +set(CMAKE_CXX_FLAGS_RELEASE_INIT "${CMAKE_C_FLAGS_RELEASE_INIT}") +set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "${CMAKE_C_FLAGS_RELWITHDEBINFO_INIT}") +set(CMAKE_CXX_FLAGS_DEBUG_INIT "${CMAKE_C_FLAGS_DEBUG_INIT}") + +if (NOT CMAKE_HOST_WIN32) + find_package(Python) + + if (Python_Interpreter_FOUND) + set(PNACLPYTHON_PREFIX "env PNACLPYTHON=${Python_EXECUTABLE} ") + set(PNACLPYTHON_PREFIX2 env "PNACLPYTHON=${Python_EXECUTABLE} ") + message(STATUS "Using PNACL Python executable: ${Python_EXECUTABLE}") + else() + message(FATAL_ERROR "Please install python (and run in a python virtualenv if that's not enough).") + endif() +endif() + +# These commands can fail on windows if there is a space at the beginning +set(CMAKE_C_CREATE_STATIC_LIBRARY "${PNACLPYTHON_PREFIX} rc ") +set(CMAKE_CXX_CREATE_STATIC_LIBRARY "${PNACLPYTHON_PREFIX} rc ") + +set(CMAKE_C_COMPILE_OBJECT "${PNACLPYTHON_PREFIX} -o -c ") +set(CMAKE_CXX_COMPILE_OBJECT "${PNACLPYTHON_PREFIX} -o -c ") + +set(CMAKE_C_LINK_EXECUTABLE "${PNACLPYTHON_PREFIX} -o ") +set(CMAKE_CXX_LINK_EXECUTABLE "${PNACLPYTHON_PREFIX} -o ") + +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) + +set(NACL ON) + +set(CMAKE_C_FLAGS "") +set(CMAKE_CXX_FLAGS "") diff --git a/cmake/cross-toolchain-saigo-amd64.cmake b/cmake/cross-toolchain-saigo-amd64.cmake new file mode 100644 index 0000000000..c755d9b2b1 --- /dev/null +++ b/cmake/cross-toolchain-saigo-amd64.cmake @@ -0,0 +1,28 @@ +# Daemon BSD Source Code +# Copyright (c) 2026, Daemon Developers +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the Daemon developers nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL DAEMON DEVELOPERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +set(SAIGO_ARCH "x86_64") +include("${CMAKE_CURRENT_LIST_DIR}/cross-toolchain-saigo-common.cmake") diff --git a/cmake/cross-toolchain-saigo-armhf.cmake b/cmake/cross-toolchain-saigo-armhf.cmake new file mode 100644 index 0000000000..7197c47049 --- /dev/null +++ b/cmake/cross-toolchain-saigo-armhf.cmake @@ -0,0 +1,28 @@ +# Daemon BSD Source Code +# Copyright (c) 2026, Daemon Developers +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the Daemon developers nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL DAEMON DEVELOPERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +set(SAIGO_ARCH "arm") +include("${CMAKE_CURRENT_LIST_DIR}/cross-toolchain-saigo-common.cmake") diff --git a/cmake/cross-toolchain-saigo-common.cmake b/cmake/cross-toolchain-saigo-common.cmake new file mode 100644 index 0000000000..0c7a928e40 --- /dev/null +++ b/cmake/cross-toolchain-saigo-common.cmake @@ -0,0 +1,79 @@ +# Daemon BSD Source Code +# Copyright (c) 2023-2026, Daemon Developers +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the Daemon developers nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL DAEMON DEVELOPERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# We can't use CMAKE_EXECUTABLE_SUFFIX because the Generic Platform will reset it +# and creating a Platform module for setting CMAKE_EXECUTABLE_SUFFIX is overkill. +set(NACL_EXECUTABLE_SUFFIX ".nexe") + +set(SAIGO_TRIPLET "${SAIGO_ARCH}-nacl") + +if ("${SAIGOSDK_PREFIX}" STREQUAL "") + find_program(PATH_SAIGO_CLANG NAMES "${SAIGO_TRIPLET}-clang") + get_filename_component(SAIGOSDK_PREFIX ${PATH_SAIGO_CLANG} DIRECTORY) +endif() + +list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES SAIGOSDK_PREFIX) + +set(CMAKE_SYSTEM_NAME "Generic") + +set(CMAKE_C_COMPILER "${SAIGOSDK_PREFIX}/bin/${SAIGO_TRIPLET}-clang") +set(CMAKE_CXX_COMPILER "${SAIGOSDK_PREFIX}/bin/${SAIGO_TRIPLET}-clang++") +set(CMAKE_AR "${SAIGOSDK_PREFIX}/bin/${SAIGO_TRIPLET}-ar" CACHE FILEPATH "Archiver" FORCE) +set(CMAKE_RANLIB "${SAIGOSDK_PREFIX}/bin/${SAIGO_TRIPLET}-ranlib") +set(CMAKE_STRIP "${SAIGOSDK_PREFIX}/bin/${SAIGO_TRIPLET}-strip") +set(CMAKE_FIND_ROOT_PATH "${SAIGOSDK_PREFIX}/${SAIGO_TRIPLET}") + +# Copy-pasted from the PNaCl toolchain, it's not sure we need it. +set(CMAKE_C_USE_RESPONSE_FILE_FOR_LIBRARIES 1) +set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_LIBRARIES 1) +set(CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS 1) +set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS 1) +set(CMAKE_C_USE_RESPONSE_FILE_FOR_INCLUDES 1) +set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES 1) +set(CMAKE_C_RESPONSE_FILE_LINK_FLAG "@") +set(CMAKE_CXX_RESPONSE_FILE_LINK_FLAG "@") + +# Copy-pasted from the PNaCl toolchain, it's not sure we need it. +# These commands can fail on windows if there is a space at the beginning +set(CMAKE_C_CREATE_STATIC_LIBRARY " rc ") +set(CMAKE_CXX_CREATE_STATIC_LIBRARY " rc ") + +set(CMAKE_C_COMPILE_OBJECT " -o -c ") +set(CMAKE_CXX_COMPILE_OBJECT " -o -c ") + +set(CMAKE_C_LINK_EXECUTABLE " -o ") +set(CMAKE_CXX_LINK_EXECUTABLE " -o ") + +# Copy-pasted from the PNaCl toolchain, it's not sure we need it. +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) + +set(NACL ON) + +set(CMAKE_C_FLAGS "") +set(CMAKE_CXX_FLAGS "") diff --git a/cmake/cross-toolchain-saigo-i686.cmake b/cmake/cross-toolchain-saigo-i686.cmake new file mode 100644 index 0000000000..1bd9b1f0c5 --- /dev/null +++ b/cmake/cross-toolchain-saigo-i686.cmake @@ -0,0 +1,39 @@ +# Daemon BSD Source Code +# Copyright (c) 2026, Daemon Developers +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the Daemon developers nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL DAEMON DEVELOPERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +set(SAIGO_ARCH "i686") +include("${CMAKE_CURRENT_LIST_DIR}/cross-toolchain-saigo-common.cmake") + +if (EXISTS "${SAIGOSDK_PREFIX}/x86_64-nacl/lib32") + # This will search libraries in paths in this order: + # - i686-nacl/lib + # - x86_64-nacl/lib32 + # - x86_64-nacl/lib + # The last path is wrong but is not used when the lib is found before, + # so it is meant to work on well-formed SDK installations. + list(APPEND CMAKE_FIND_ROOT_PATH "${SAIGOSDK_PREFIX}/x86_64-nacl") + set(CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX "32") +endif() diff --git a/cmake/toolchain-pnacl.cmake b/cmake/toolchain-pnacl.cmake deleted file mode 100644 index b19f61e8ec..0000000000 --- a/cmake/toolchain-pnacl.cmake +++ /dev/null @@ -1,151 +0,0 @@ -# Daemon BSD Source Code -# Copyright (c) 2013-2016, Daemon Developers -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the Daemon developers nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL DAEMON DEVELOPERS BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -set(PLATFORM_PREFIX ${DEPS_DIR}/pnacl/bin) -set(PLATFORM_TRIPLET "pnacl") - -if (WIN32) - set(PNACL_BIN_EXT ".bat") -else() - set(PNACL_BIN_EXT "") -endif() - -set(PLATFORM_EXE_SUFFIX ".pexe") - -set(CMAKE_SYSTEM_NAME "Generic") - -set(CMAKE_C_COMPILER "${PLATFORM_PREFIX}/${PLATFORM_TRIPLET}-clang${PNACL_BIN_EXT}") -set(CMAKE_CXX_COMPILER "${PLATFORM_PREFIX}/${PLATFORM_TRIPLET}-clang++${PNACL_BIN_EXT}") -set(CMAKE_AR "${PLATFORM_PREFIX}/${PLATFORM_TRIPLET}-ar${PNACL_BIN_EXT}" CACHE FILEPATH "Archiver" FORCE) -set(CMAKE_RANLIB "${PLATFORM_PREFIX}/${PLATFORM_TRIPLET}-ranlib${PNACL_BIN_EXT}") -set(PNACL_TRANSLATE "${PLATFORM_PREFIX}/${PLATFORM_TRIPLET}-translate${PNACL_BIN_EXT}") -set(PNACL_STRIP "${PLATFORM_PREFIX}/${PLATFORM_TRIPLET}-strip${PNACL_BIN_EXT}") -set(CMAKE_FIND_ROOT_PATH "${PLATFORM_PREFIX}/../le32-nacl") - -set(CMAKE_C_USE_RESPONSE_FILE_FOR_LIBRARIES 1) -set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_LIBRARIES 1) -set(CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS 1) -set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS 1) -set(CMAKE_C_USE_RESPONSE_FILE_FOR_INCLUDES 1) -set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES 1) -set(CMAKE_C_RESPONSE_FILE_LINK_FLAG "@") -set(CMAKE_CXX_RESPONSE_FILE_LINK_FLAG "@") - -set(CMAKE_C_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG") -set(CMAKE_C_FLAGS_RELEASE_INIT "-O3 -DNDEBUG") -set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-O2 -g -DNDEBUG") -set(CMAKE_C_FLAGS_DEBUG_INIT "-g") - -set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "${CMAKE_C_FLAGS_MINSIZEREL_INIT}") -set(CMAKE_CXX_FLAGS_RELEASE_INIT "${CMAKE_C_FLAGS_RELEASE_INIT}") -set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "${CMAKE_C_FLAGS_RELWITHDEBINFO_INIT}") -set(CMAKE_CXX_FLAGS_DEBUG_INIT "${CMAKE_C_FLAGS_DEBUG_INIT}") - -if (NOT CMAKE_HOST_WIN32) - find_package(Python) - - if (Python_Interpreter_FOUND) - set(PNACLPYTHON_PREFIX "env PNACLPYTHON=${Python_EXECUTABLE} ") - set(PNACLPYTHON_PREFIX2 env "PNACLPYTHON=${Python_EXECUTABLE} ") - message(STATUS "Using PNACL Python executable: ${Python_EXECUTABLE}") - else() - message(FATAL_ERROR "Please install python (and run in a python virtualenv if that's not enough).") - endif() -endif() - -# These commands can fail on windows if there is a space at the beginning -set(CMAKE_C_CREATE_STATIC_LIBRARY "${PNACLPYTHON_PREFIX} rc ") -set(CMAKE_CXX_CREATE_STATIC_LIBRARY "${PNACLPYTHON_PREFIX} rc ") - -set(CMAKE_C_COMPILE_OBJECT "${PNACLPYTHON_PREFIX} -o -c ") -set(CMAKE_CXX_COMPILE_OBJECT "${PNACLPYTHON_PREFIX} -o -c ") - -set(CMAKE_C_LINK_EXECUTABLE "${PNACLPYTHON_PREFIX} -o ") -set(CMAKE_CXX_LINK_EXECUTABLE "${PNACLPYTHON_PREFIX} -o ") - -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) - -set(NACL ON) - -set(CMAKE_C_FLAGS "") -set(CMAKE_CXX_FLAGS "") - -function(pnacl_finalize dir module arch) - include(DaemonBuildTypeGeneratorExpression) - - set(PNACL_TRANSLATE_OPTIONS - --allow-llvm-bitcode-input # FIXME: finalize as part of the build process - --pnacl-allow-exceptions - $<${RELEASE_GENEXP_COND}:-O3> - $<${DEBUG_GENEXP_COND}:-O0> - $<${RELWITHDEBINFO_GENEXP_COND}:-O2> - $<${MINSIZEREL_GENEXP_COND}:-O2> - ) - set(PEXE ${dir}/${module}.pexe) - set(NEXE ${dir}/${module}-${arch}.nexe) - set(STRIPPED_NEXE ${dir}/${module}-${arch}-stripped.nexe) - - if (arch STREQUAL "i686") - set(PNACL_ARCH "i686") - elseif (arch STREQUAL "amd64") - set(PNACL_ARCH "x86-64") - elseif (arch STREQUAL "armhf") - set(PNACL_ARCH "arm") - else() - message(FATAL_ERROR "Unknown NaCl architecture ${arch}") - endif() - - add_custom_command( - OUTPUT ${NEXE} - COMMENT "Translating ${module} (${arch})" - DEPENDS ${PEXE} - COMMAND - ${PNACLPYTHON_PREFIX2} - "${PNACL_TRANSLATE}" - ${PNACL_TRANSLATE_OPTIONS} - -arch ${PNACL_ARCH} - ${PEXE} - -o ${NEXE} - ) - - add_custom_command( - OUTPUT ${STRIPPED_NEXE} - COMMENT "Stripping ${module} (${arch})" - DEPENDS ${NEXE} - COMMAND - ${PNACLPYTHON_PREFIX2} - "${PNACL_STRIP}" - -s - ${NEXE} - -o ${STRIPPED_NEXE} - ) - - add_custom_target(${module}-${arch} ALL DEPENDS ${STRIPPED_NEXE}) - add_dependencies(${module}-${arch} ${module}-nacl) -endfunction() diff --git a/cmake/toolchain-saigo.cmake b/cmake/toolchain-saigo.cmake deleted file mode 100644 index 75374527b3..0000000000 --- a/cmake/toolchain-saigo.cmake +++ /dev/null @@ -1,75 +0,0 @@ -set(PLATFORM_PREFIX "${DEPS_DIR}/saigo_newlib/bin") -set(PLATFORM_TRIPLET "${SAIGO_ARCH}-nacl") -set(PLATFORM_EXE_SUFFIX ".nexe") - -set(CMAKE_SYSTEM_NAME "Generic") - -set(CMAKE_C_COMPILER "${PLATFORM_PREFIX}/${PLATFORM_TRIPLET}-clang") -set(CMAKE_CXX_COMPILER "${PLATFORM_PREFIX}/${PLATFORM_TRIPLET}-clang++") -set(CMAKE_AR "${PLATFORM_PREFIX}/${PLATFORM_TRIPLET}-ar" CACHE FILEPATH "Archiver" FORCE) -set(CMAKE_RANLIB "${PLATFORM_PREFIX}/${PLATFORM_TRIPLET}-ranlib") -set(SAIGO_STRIP "${PLATFORM_PREFIX}/${PLATFORM_TRIPLET}-strip") -set(CMAKE_FIND_ROOT_PATH "${PLATFORM_PREFIX}/../${PLATFORM_TRIPLET}") - -# Copy-pasted from the PNaCl toolchain, it's not sure we need it. -set(CMAKE_C_USE_RESPONSE_FILE_FOR_LIBRARIES 1) -set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_LIBRARIES 1) -set(CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS 1) -set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS 1) -set(CMAKE_C_USE_RESPONSE_FILE_FOR_INCLUDES 1) -set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES 1) -set(CMAKE_C_RESPONSE_FILE_LINK_FLAG "@") -set(CMAKE_CXX_RESPONSE_FILE_LINK_FLAG "@") - -# Copy-pasted from the PNaCl toolchain, it's not sure we need it. -# These commands can fail on windows if there is a space at the beginning -set(CMAKE_C_CREATE_STATIC_LIBRARY " rc ") -set(CMAKE_CXX_CREATE_STATIC_LIBRARY " rc ") - -set(CMAKE_C_COMPILE_OBJECT " -o -c ") -set(CMAKE_CXX_COMPILE_OBJECT " -o -c ") - -set(CMAKE_C_LINK_EXECUTABLE " -o ") -set(CMAKE_CXX_LINK_EXECUTABLE " -o ") - -# Copy-pasted from the PNaCl toolchain, it's not sure we need it. -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) - -set(NACL ON) - -set(CMAKE_C_FLAGS "") -set(CMAKE_CXX_FLAGS "") - -function(saigo_finalize dir module arch) - set(SUBPROJECT_NEXE ${dir}/nacl-vms-${arch}/${module}.nexe) - set(NEXE ${dir}/${module}-${arch}.nexe) - set(STRIPPED_NEXE ${dir}/${module}-${arch}-stripped.nexe) - - add_custom_command( - OUTPUT ${NEXE} - COMMENT "Copying ${module} (${arch})" - DEPENDS ${SUBPROJECT_NEXE} - COMMAND - ${CMAKE_COMMAND} - -E copy - ${SUBPROJECT_NEXE} - ${NEXE} - ) - - add_custom_command( - OUTPUT ${STRIPPED_NEXE} - COMMENT "Stripping ${module} (${arch})" - DEPENDS ${NEXE} - COMMAND - "${SAIGO_STRIP}" - -s - ${NEXE} - -o ${STRIPPED_NEXE} - ) - - add_custom_target(${module}-${arch} ALL DEPENDS ${STRIPPED_NEXE}) - add_dependencies(${module}-${arch} ${module}-nacl) -endfunction() From 0ce6ea35fcfa80b05fa69d123973e92ff12887b7 Mon Sep 17 00:00:00 2001 From: slipher Date: Thu, 30 Jul 2026 10:16:01 -0500 Subject: [PATCH 04/76] Refactor: function for Linux arm64 check for VM Co-authored-by: Thomas Debesse --- src/engine/framework/VirtualMachine.cpp | 29 +++++++++++++++---------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/engine/framework/VirtualMachine.cpp b/src/engine/framework/VirtualMachine.cpp index 859bb9b168..f54e31bd27 100644 --- a/src/engine/framework/VirtualMachine.cpp +++ b/src/engine/framework/VirtualMachine.cpp @@ -226,6 +226,22 @@ static void CheckMinAddressSysctlTooLarge() #endif // __linux__ } +#if defined(DAEMON_NACL_RUNTIME_LINUX) && (defined(YOKAI_ARCH_ARM64) || defined(YOKAI_ARCH_ARMHF)) +static bool OnArm64() +{ +#if defined(YOKAI_ARCH_ARM64) + return true; +#elif defined(YOKAI_ARCH_ARMHF) + struct utsname buf; + if (!uname(&buf)) { + return !strcmp(buf.machine, "aarch64"); + } + + return false; +#endif // defined(YOKAI_ARCH_ARMHF) +} +#endif + // Platform-specific code to load a module static std::pair InternalLoadModule(std::pair pair, const char* const* args, bool reserve_mem, FS::File stderrRedirect = FS::File(), bool inheritEnvironment = false) { @@ -634,17 +650,6 @@ static std::pair CreateNaClVM(std::pair CreateNaClVM(std::pair Date: Thu, 30 Jul 2026 11:28:20 -0500 Subject: [PATCH 05/76] Get rid of nacl_multiarch executable Set up the chdir and environment variable in posix_spawn. Fixes #1336. Co-authored-by: Thomas Debesse --- CMakeLists.txt | 9 +--- cmake/DaemonNaclArchitecture.cmake | 2 - src/engine/framework/VirtualMachine.cpp | 35 ++++--------- tools/nacl_multiarch/nacl_multiarch.cpp | 68 ------------------------- 4 files changed, 13 insertions(+), 101 deletions(-) delete mode 100644 tools/nacl_multiarch/nacl_multiarch.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index ecd565af4e..68430d9fc9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1000,13 +1000,8 @@ if (DEPS_DIR AND HAS_NACL AND (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER # Linux uses a bootstrap program to reserve address space if (YOKAI_TARGET_SYSTEM_LINUX_COMPATIBILITY) - if (DAEMON_NACL_MULTIARCH) - add_executable(nacl_multiarch-${DAEMON_NACL_ARCH_NAME} - tools/nacl_multiarch/nacl_multiarch.cpp - ${BUILDINFOLIST} - ) - add_dependencies(runtime_deps nacl_multiarch-${DAEMON_NACL_ARCH_NAME}) - + # Backport compatibility until the external_deps script properly suffixes names in the archives. + if (YOKAI_TARGET_ARCH_ARM64) add_custom_command(TARGET runtime_deps PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${DEPS_DIR}/lib-armhf diff --git a/cmake/DaemonNaclArchitecture.cmake b/cmake/DaemonNaclArchitecture.cmake index ed267918c8..1c6726d9ba 100644 --- a/cmake/DaemonNaclArchitecture.cmake +++ b/cmake/DaemonNaclArchitecture.cmake @@ -54,8 +54,6 @@ function(daemon_detect_nacl_arch target_arch) set(box64_usage "ppc64el" "riscv64" "loong64") if ("${target_arch}" IN_LIST armhf_usage) - set(DAEMON_NACL_MULTIARCH ON) - # Load 32-bit armhf nexe on 64-bit arm64 engine on Linux with multiarch. # The nexe is system agnostic so there should be no difference with armel. add_nacl_multilib_arch("armhf") diff --git a/src/engine/framework/VirtualMachine.cpp b/src/engine/framework/VirtualMachine.cpp index f54e31bd27..d2ad026328 100644 --- a/src/engine/framework/VirtualMachine.cpp +++ b/src/engine/framework/VirtualMachine.cpp @@ -183,15 +183,6 @@ static Cvar::Cvar vm_nacl_qualification( Cvar::INIT, true); #endif // defined(DAEMON_NACL_RUNTIME_ENABLED) -#if defined(DAEMON_NACL_RUNTIME_ENABLED) -#if defined(DAEMON_NACL_RUNTIME_LINUX) && defined(YOKAI_ARCH_ARM64) -static Cvar::Cvar vm_nacl_multiarch( - "vm.nacl.multiarch", - "Use multiarch to run the NaCl loader when needed and available", - Cvar::INIT, true); -#endif // defined(DAEMON_NACL_RUNTIME_LINUX) && defined(YOKAI_ARCH_ARM64) -#endif // defined(DAEMON_NACL_RUNTIME_ENABLED) - #if defined(DAEMON_NACL_BOOSTRAP_ENABLED) static Cvar::Cvar vm_nacl_bootstrap( "vm.nacl.bootstrap", @@ -349,11 +340,20 @@ static std::pair InternalLoadModule(std::pair("LD_LIBRARY_PATH=lib-armhf"); + + if (0 != posix_spawn_file_actions_addchdir_np(&fileActions, FS::GetLibPath().c_str())) { + Sys::Error("failed posix_spawn_file_actions_addchdir"); + } + } +#endif // By default, the child process gets an empty environment for sandboxing. // When Box64 emulation is used, the child needs to inherit the parent's // environment so Box64 can find its configuration (e.g. ~/.box64rc, HOME) // and honor settings like BOX64_DYNAREC_PERFMAP. - char* emptyEnv[] = {nullptr}; char** envp = inheritEnvironment ? environ : emptyEnv; int err = posix_spawn(&pid, args[0], &fileActions, nullptr, const_cast(args), envp); posix_spawn_file_actions_destroy(&fileActions); @@ -470,13 +470,10 @@ static std::pair CreateNaClVM(std::pair CreateNaClVM(std::pair -#include -#include -#include -#include -#include - -#include "YokaiBuildInfo/DaemonEngine.h" - -int main(int argc, char *argv[]) { - if (argc < 2) { - printf("nacl_multiarch-%s: missing command line\n", DAEMON_NACL_ARCH_STRING); - return 1; - } - - char *directory = dirname(strdup(argv[0])); - - int err = chdir(directory); - - if (err != 0) { - return err; - } - - char env[100]; - sprintf(env, "LD_LIBRARY_PATH=lib-%s", DAEMON_NACL_ARCH_STRING); - - err = putenv(strdup(env)); - - if (err != 0) { - return err; - } - - execv(argv[1], &argv[1]); - - // The execv() function returns only if an error has occurred. - printf("nacl_multiarch-%s: %s\n", DAEMON_NACL_ARCH_STRING, strerror(errno)); - return 1; -} From 02b3fa49e1d30b8a61af83f095b67d054ec94e91 Mon Sep 17 00:00:00 2001 From: slipher Date: Mon, 7 Sep 2026 01:53:26 -0500 Subject: [PATCH 06/76] Don't use nacl_helper_bootstrap with x86-64 loader Remove cvars controlling whether the Linux bootstrap loader is used. Never use bootstrap with the amd64 loader. Always use bootstrap with 32-bit loaders. Co-authored-by: Thomas Debesse --- CMakeLists.txt | 15 ++++++++----- src/engine/framework/VirtualMachine.cpp | 30 ++++--------------------- 2 files changed, 13 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 68430d9fc9..71743ba430 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -998,7 +998,6 @@ if (DEPS_DIR AND HAS_NACL AND (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER ) endforeach() - # Linux uses a bootstrap program to reserve address space if (YOKAI_TARGET_SYSTEM_LINUX_COMPATIBILITY) # Backport compatibility until the external_deps script properly suffixes names in the archives. if (YOKAI_TARGET_ARCH_ARM64) @@ -1009,12 +1008,16 @@ if (DEPS_DIR AND HAS_NACL AND (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER ) endif() + # Linux uses a bootstrap program to reserve address space for 32-bit runtimes. foreach(arch_name IN LISTS DAEMON_NACL_ARCH_NAME_LIST) - add_custom_command(TARGET runtime_deps PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${DEPS_DIR}/nacl_helper_bootstrap - ${FULL_OUTPUT_DIR}/nacl_helper_bootstrap-${arch_name} - ) + set(arch_32bit "i686" "armhf") + if ("${arch_name}" IN_LIST arch_32bit) + add_custom_command(TARGET runtime_deps PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${DEPS_DIR}/nacl_helper_bootstrap + ${FULL_OUTPUT_DIR}/nacl_helper_bootstrap-${arch_name} + ) + endif() endforeach() endif() diff --git a/src/engine/framework/VirtualMachine.cpp b/src/engine/framework/VirtualMachine.cpp index d2ad026328..bed4046834 100644 --- a/src/engine/framework/VirtualMachine.cpp +++ b/src/engine/framework/VirtualMachine.cpp @@ -79,7 +79,9 @@ static Cvar::Cvar workaround_naclSystem_freebsd_disableQualification( // Many BSDs have a Linuxulator, for now we only tested one. #if defined(__linux__) || defined(__FreeBSD__) #define DAEMON_NACL_RUNTIME_LINUX +#if YOKAI_ARCH_I686 || YOKAI_ARCH_ARM64 || YOKAI_ARCH_ARMHF #define DAEMON_NACL_BOOSTRAP_ENABLED +#endif // !(YOKAI_ARCH_I686 || YOKAI_ARCH_ARM64 || YOKAI_ARCH_ARMHF) #endif // defined(__linux__) || defined(DAEMON_LINUXULATOR) #endif // defined(DAEMON_NACL_RUNTIME_ENABLED) @@ -90,11 +92,6 @@ static Cvar::Cvar workaround_box64_disableQualification( "Disable platform qualification when running amd64 NaCl loader under Box64 emulation", Cvar::NONE, true); -static Cvar::Cvar workaround_box64_disableBootstrap( - "workaround.box64.disableBootstrap", - "Disable NaCl bootstrap helper when using Box64 emulation", - Cvar::NONE, true); - static Cvar::Cvar vm_box64_path( "vm.box64.path", "Path to the box64 binary for NaCl emulation (empty = use provided one or search PATH if missing)", @@ -183,13 +180,6 @@ static Cvar::Cvar vm_nacl_qualification( Cvar::INIT, true); #endif // defined(DAEMON_NACL_RUNTIME_ENABLED) -#if defined(DAEMON_NACL_BOOSTRAP_ENABLED) -static Cvar::Cvar vm_nacl_bootstrap( - "vm.nacl.bootstrap", - "Use NaCl bootstrap helper", - Cvar::INIT, true); -#endif // defined(DAEMON_NACL_BOOSTRAP_ENABLED) - namespace VM { // https://github.com/Unvanquished/Unvanquished/issues/944#issuecomment-744454772 @@ -479,7 +469,7 @@ static std::pair CreateNaClVM(std::pair CreateNaClVM(std::pair Date: Mon, 7 Sep 2026 03:10:10 -0500 Subject: [PATCH 07/76] Windows: block NaCl process from inheriting environment When creating a NaCl (or native exe) VM on Windows, block evironment variables from being passed through to the subprocess as is done on *nix. Probably we do this since there are NACL* variables that can disable secure sandboxing. inheritEnvironment is always false on Windows, but I implemented the true case anyway since it's less code than having the Q_UNUSED and asserting it's false. --- src/engine/framework/VirtualMachine.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/engine/framework/VirtualMachine.cpp b/src/engine/framework/VirtualMachine.cpp index bed4046834..6bbda83109 100644 --- a/src/engine/framework/VirtualMachine.cpp +++ b/src/engine/framework/VirtualMachine.cpp @@ -288,8 +288,12 @@ static std::pair InternalLoadModule(std::pair InternalLoadModule(std::pair Date: Tue, 15 Sep 2026 06:45:37 -0500 Subject: [PATCH 08/76] Check mmap_min_addr only if using NaCl bootstrap Check the Linux sysctl vm.mmap_min_addr only when using the NaCl bootstrap (rather than always when using NaCl). Or equivalently, check it only with 32-bit NaCl runtimes. The bootstrap fails to start when the value is too high to due low fixed address mappings. On ARM at least, sel_ldr proper would also fail with a too-high min address since that disturbs the address space layout. On 64-bit there is neither the bootstrap nor 0-based address space layout so it always works. Co-authored-by: Thomas Debesse --- src/engine/framework/VirtualMachine.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/framework/VirtualMachine.cpp b/src/engine/framework/VirtualMachine.cpp index 6bbda83109..87a176ea25 100644 --- a/src/engine/framework/VirtualMachine.cpp +++ b/src/engine/framework/VirtualMachine.cpp @@ -440,7 +440,6 @@ static ExeSupport CheckExeSupport(Str::StringRef probe) #if defined(DAEMON_NACL_RUNTIME_ENABLED) static std::pair CreateNaClVM(std::pair pair, Str::StringRef name, bool debug, bool extract, int debugLoader) { - CheckMinAddressSysctlTooLarge(); const std::string& libPath = FS::GetLibPath(); std::vector args; char rootSocketRedir[32]; @@ -576,6 +575,8 @@ static std::pair CreateNaClVM(std::pair Date: Sun, 11 Oct 2026 21:09:44 -0500 Subject: [PATCH 09/76] cmake: raise an error when the SDK prefix is not a directory Co-authored-by: Thomas Debesse --- cmake/DaemonGame.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmake/DaemonGame.cmake b/cmake/DaemonGame.cmake index 8a4cc2e4ff..b4c449fd8f 100644 --- a/cmake/DaemonGame.cmake +++ b/cmake/DaemonGame.cmake @@ -227,6 +227,10 @@ function(GAMEMODULE) if (BUILD_GAME_NACL AND NOT YOKAI_TARGET_SYSTEM_NACL) if (USE_NACL_SAIGO) + if (NOT IS_DIRECTORY "${SAIGOSDK_PREFIX}") + message(FATAL_ERROR "SAIGOSDK_PREFIX configured as '${SAIGOSDK_PREFIX}' which is not an existing directory") + endif() + add_custom_target(nacl-vms ALL) unset(NACL_VMS_PROJECTS) @@ -251,6 +255,10 @@ function(GAMEMODULE) ) endforeach() else() + if (NOT IS_DIRECTORY "${PNACLSDK_PREFIX}") + message(FATAL_ERROR "PNACLSDK_PREFIX configured as '${PNACLSDK_PREFIX}' which is not an existing directory") + endif() + set(NACL_VMS_PROJECT nacl-vms) set(NACL_VMS_PROJECTS ${NACL_VMS_PROJECT}) From 91d87e85c786be7c3766a080fa03e020cb12b4cc Mon Sep 17 00:00:00 2001 From: slipher Date: Mon, 12 Oct 2026 02:29:55 -0500 Subject: [PATCH 10/76] Auto-download Saigo SDK for any supported host The old PNaCl toolchain has been being shipped as part of the deps package, with the host platform for the compilers assumed to be the same as the target platform of the deps package. Experimental Saigo support has thus far required manually downloading the SDK. Now, make the Saigo toolchain auto-downloadable (if USE_NACL_SAIGO=1) independently from the target platform dependencies. This has several advantages: - No need to download the NaCl toolchain if you are not building NaCl. - No need to download a useless NaCl toolchain when cross-compiling. - Toolchain can be downloaded for host systems that don't have a deps package, or where the deps package being used doesn't match the real host system. (The SDK is available for more systems than the deps package.) The toolchain is downloaded from Github and then, like the deps package, extracted into external_deps/. --- CMakeLists.txt | 13 +++-- cmake/DaemonDependenciesDownload.cmake | 72 ++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 5 deletions(-) create mode 100644 cmake/DaemonDependenciesDownload.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 71743ba430..54e0f49b48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -198,8 +198,9 @@ else() set(FULL_OUTPUT_DIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}) endif() -# Dependencies version, this must match the number in external_deps/build.sh -set(DEPS_VERSION 11) +# Dependencies versions +set(DEPS_VERSION 11) # This must match the number in external_deps/build.sh +set(SAIGOSDK_VERSION 20260925) option(USE_EXTERNAL_DEPS "Download or reuse dependencies from EXTERNAL_DEPS_DIR (mandatory for building and running NaCl .nexe binaries)." ON) @@ -277,9 +278,6 @@ option(USE_EXTERNAL_DEPS_LIBS "Build and link against libraries from the EXTERNA set(PNACLSDK_PREFIX "${DEPS_DIR}/pnacl" CACHE PATH "PNaCl SDK path") mark_as_advanced(PNACLSDK_PREFIX) -set(SAIGOSDK_PREFIX "${DEPS_DIR}/saigo_newlib" CACHE PATH "Saigo NaCl SDK path") -mark_as_advanced(SAIGOSDK_PREFIX) - if (USE_EXTERNAL_DEPS AND NOT YOKAI_TARGET_SYSTEM_NACL) if (DEPS_DIR) message(STATUS "Using external deps dir: ${DEPS_DIR}") @@ -458,6 +456,11 @@ if (DEPS_DIR) endif() endif() + if (BUILD_GAME_NACL AND USE_NACL_SAIGO AND NOT SAIGOSDK_PREFIX) + include(DaemonDependenciesDownload) + download_saigosdk() + endif() + if (USE_EXTERNAL_DEPS_LIBS) # Add to paths set(CMAKE_FIND_ROOT_PATH ${DEPS_DIR} ${CMAKE_FIND_ROOT_PATH}) diff --git a/cmake/DaemonDependenciesDownload.cmake b/cmake/DaemonDependenciesDownload.cmake new file mode 100644 index 0000000000..a4bc08a4c4 --- /dev/null +++ b/cmake/DaemonDependenciesDownload.cmake @@ -0,0 +1,72 @@ +# Daemon BSD Source Code +# Copyright (c) 2013-2026, Daemon Developers +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the Daemon developers nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL DAEMON DEVELOPERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# TODO: Move other deps downloading code in here. + +set(SAIGOSDK_BASENAME "saigosdk-${DEPS_SYSTEM}-${DEPS_ARCH}_${SAIGOSDK_VERSION}") + +# Warning: changing SAIGOSDK_PREFIX/SAIGOSDK_VERSION after subprojects have been configured WILL +# change the compiler, but it is a bad idea since flag tests and such (not to mention the actual +# compiled artifacts) will be out of date. +set(SAIGOSDK_PREFIX "${EXTERNAL_DEPS_DIR}/${SAIGOSDK_BASENAME}" CACHE PATH "PNaCl SDK path") +mark_as_advanced(SAIGOSDK_PREFIX) + +function(download_saigosdk) + if (NOT EXISTS "${SAIGOSDK_PREFIX}") + set(DEPS_FILENAME "${SAIGOSDK_BASENAME}.tar.xz") + set(REMOTE "https://github.com/DaemonEngine/saigo-nacl-sdk/releases/download/v${SAIGOSDK_VERSION}/${DEPS_FILENAME}") + message(STATUS "Downloading NaCl SDK from '${REMOTE}'") + + file(DOWNLOAD "${REMOTE}" "${OBJ_DIR}/${DEPS_FILENAME}" + SHOW_PROGRESS + STATUS DOWNLOAD_RESULT + LOG DOWNLOAD_LOG + ) + + list(GET DOWNLOAD_RESULT 0 DOWNLOAD_STATUS) + list(GET DOWNLOAD_RESULT 1 DOWNLOAD_STRING) + + if (NOT DOWNLOAD_STATUS EQUAL 0) + message(FATAL_ERROR "Failed to download '${REMOTE}': This may be a network error, or your system may be an unsupported host platform. + Status code: ${DOWNLOAD_STATUS} + Error string: ${DOWNLOAD_STRING} + Download log: ${DOWNLOAD_LOG}" + ) + endif() + + message(STATUS "SDK download completed successfully") + + # Extract the downloaded archive + execute_process( + COMMAND ${CMAKE_COMMAND} -E tar xJf ${OBJ_DIR}/${DEPS_FILENAME} + WORKING_DIRECTORY ${EXTERNAL_DEPS_DIR} + RESULT_VARIABLE EXTRACT_RESULT + ) + if (NOT EXTRACT_RESULT EQUAL 0) + message(FATAL_ERROR "Could not extract ${DEPS_FILENAME}") + endif() + endif() +endfunction() From 30f7b84faf82971ea3a3c544f935399a6d987bbb Mon Sep 17 00:00:00 2001 From: slipher Date: Tue, 13 Oct 2026 02:56:50 -0500 Subject: [PATCH 11/76] Add build script for Saigo SDK (host-mode deps) Add external_deps/sdk-build.sh which can be used as an alternative to auto-downloading Saigo. Like external_deps/build.sh, it builds the dependency package and installs it to the expected location. It is a thin wrapper around the saigo-nacl-sdk CMake build; if you need more control it is better to use CMake directly. --- .gitignore | 1 + CMakeLists.txt | 2 +- cmake/DaemonDependenciesDownload.cmake | 2 + external_deps/sdk-build.sh | 88 ++++++++++++++++++++++++++ 4 files changed, 92 insertions(+), 1 deletion(-) create mode 100755 external_deps/sdk-build.sh diff --git a/.gitignore b/.gitignore index 00e20db8da..b753d1cf66 100644 --- a/.gitignore +++ b/.gitignore @@ -40,6 +40,7 @@ build #ignore external deps external_deps/* !external_deps/build.sh +!external_deps/sdk-build.sh !external_deps/cygtar.py !external_deps/*.patch diff --git a/CMakeLists.txt b/CMakeLists.txt index 54e0f49b48..997c330061 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -200,7 +200,7 @@ endif() # Dependencies versions set(DEPS_VERSION 11) # This must match the number in external_deps/build.sh -set(SAIGOSDK_VERSION 20260925) +set(SAIGOSDK_VERSION 20260925) # This must match the number in external_deps/sdk-build.sh option(USE_EXTERNAL_DEPS "Download or reuse dependencies from EXTERNAL_DEPS_DIR (mandatory for building and running NaCl .nexe binaries)." ON) diff --git a/cmake/DaemonDependenciesDownload.cmake b/cmake/DaemonDependenciesDownload.cmake index a4bc08a4c4..2313300d3e 100644 --- a/cmake/DaemonDependenciesDownload.cmake +++ b/cmake/DaemonDependenciesDownload.cmake @@ -34,6 +34,8 @@ set(SAIGOSDK_BASENAME "saigosdk-${DEPS_SYSTEM}-${DEPS_ARCH}_${SAIGOSDK_VERSION}" set(SAIGOSDK_PREFIX "${EXTERNAL_DEPS_DIR}/${SAIGOSDK_BASENAME}" CACHE PATH "PNaCl SDK path") mark_as_advanced(SAIGOSDK_PREFIX) +# As an alternative to downloading, external_deps/sdk-build.sh can be used, to build the host-mode +# dependencies and install them in the expected path. function(download_saigosdk) if (NOT EXISTS "${SAIGOSDK_PREFIX}") set(DEPS_FILENAME "${SAIGOSDK_BASENAME}.tar.xz") diff --git a/external_deps/sdk-build.sh b/external_deps/sdk-build.sh new file mode 100755 index 0000000000..e90e0ace1f --- /dev/null +++ b/external_deps/sdk-build.sh @@ -0,0 +1,88 @@ +#!/usr/bin/env bash + +# Exit on undefined variable and error. +set -u -e -o pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +WORK_DIR="${PWD}" +DOWNLOAD_DIR="${WORK_DIR}/download_cache" + +# This should match the SAIGOSDK_VERSION in CMakeLists.txt. +# This is mostly to ensure the path the files end up at if you build deps yourself +# are the same as the ones when extracting from the downloaded packages. +SAIGOSDK_VERSION=20261013 +# Can be a tag like v${SAIGOSDK_VERSION}, or a full commit hash +SAIGOSDK_REF="v${SAIGOSDK_VERSION}" + +REPO_BASENAME=saigo-nacl-sdk +REPO_URL="https://github.com/DaemonEngine/${REPO_BASENAME}" +ARCHIVE_PATH="${DOWNLOAD_DIR}/saigosdk-${SAIGOSDK_REF}.tar.gz" + +usage() { + echo "Usage: $0 - (build | install | package | wipe)..." + echo "- should normally be your current native platform." + echo "For a list of supported platforms see ${REPO_URL}/tree/master/tools/release/conf" + echo "Actions:" + echo " build - build all tools and libraries in the SDK" + echo " install - install final build products to ${WORK_DIR}/saigosdk--_${SAIGOSDK_VERSION}/" + echo " wipe - delete build products (except download cache) AND install directory" + echo "If you want to build only a subset of packages, prefer using the" + echo "${REPO_URL} CMake build directly." + echo "Some global configuration options are available via environment" + echo "variables; see ${REPO_URL}/tree/master/tools/release/build" +} + +download() { + test -f "${ARCHIVE_PATH}" && return + mkdir -p "${DOWNLOAD_DIR}" + curl --fail -L "${DOWNLOAD_URL}" -o "${ARCHIVE_PATH}" +} + +if [ "$#" -lt 2 ] +then + usage + exit 1 +fi + +PLATFORM="$1" +shift + +if grep -q -E '^[0-9a-f]{40}$' <<< "${SAIGOSDK_REF}" +then + DOWNLOAD_URL="https://github.com/DaemonEngine/saigo-nacl-sdk/archive/${SAIGOSDK_REF}.tar.gz" + TARBALL_OUTER_DIR="${REPO_BASENAME}-${SAIGOSDK_REF}" +elif grep -q -E '^v[0-9]' <<< "${SAIGOSDK_REF}" +then + # The 'v' from the tag name is mysteriously removed??? + TARBALL_OUTER_DIR="${REPO_BASENAME}-${SAIGOSDK_REF:1}" + DOWNLOAD_URL="https://github.com/DaemonEngine/saigo-nacl-sdk/archive/refs/tags/${SAIGOSDK_REF}.tar.gz" +fi + +INSTALL_DIR="${WORK_DIR}/saigosdk-${PLATFORM}_${SAIGOSDK_VERSION}" +BUILD_DIR="${WORK_DIR}/build-saigosdk_${SAIGOSDK_VERSION}" +REPO_DIR="${BUILD_DIR}/${TARBALL_OUTER_DIR}" + +for target in "$@" +do + case "${target}" in + build) + download + mkdir -p "${BUILD_DIR}" + tar xzf "${ARCHIVE_PATH}" -C "${BUILD_DIR}" + ( + cd "${REPO_DIR}" + tools/release/build "${PLATFORM}" + ) + ;; + install) + cp -R "${REPO_DIR}/build/${PLATFORM}/install/." "${INSTALL_DIR}/" + ;; + wipe) + rm -rf "${BUILD_DIR}" "${INSTALL_DIR}" + ;; + *) + usage + exit 1 + ;; + esac +done From 21ea764ab7bfa26086b005775e41fdab395b5dfc Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 26 Jun 2026 01:16:29 +0200 Subject: [PATCH 12/76] external_deps: make possible to reconfigure for a different target --- external_deps/build.sh | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 7cdbbde02c..396d233f04 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -1324,23 +1324,34 @@ common_setup() { common_setup_arch EXE_EXT="${EXE_EXT:-}" - DOWNLOAD_DIR="${WORK_DIR}/download_cache" - PKG_BASEDIR="${PLATFORM}_${DEPS_VERSION}" - PKG_TARBALL="${PKG_BASEDIR}.tar.xz" - BUILD_BASEDIR="build-${PKG_BASEDIR}" - BUILD_DIR="${WORK_DIR}/${BUILD_BASEDIR}" - PREFIX="${BUILD_DIR}/prefix" - PATH="${PREFIX}/bin:${PATH}" + + if "${GLOBAL_SETUP_ONCE:-true}" + then + DOWNLOAD_DIR="${WORK_DIR}/download_cache" + PKG_BASEDIR="${PLATFORM}_${DEPS_VERSION}" + PKG_TARBALL="${PKG_BASEDIR}.tar.xz" + BUILD_BASEDIR="build-${PKG_BASEDIR}" + BUILD_DIR="${WORK_DIR}/${BUILD_BASEDIR}" + PREFIX="${BUILD_DIR}/prefix" + PATH="${PREFIX}/bin:${PATH}" + + mkdir -p "${DOWNLOAD_DIR}" + mkdir -p "${PREFIX}/bin" + mkdir -p "${PREFIX}/include" + mkdir -p "${PREFIX}/lib" + + export PATH + + GLOBAL_SETUP_ONCE='false' + fi + PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig:${CROSS_PKG_CONFIG_PATH}" CPPFLAGS+=" -I${PREFIX}/include" LDFLAGS+=" -L${PREFIX}/lib" - mkdir -p "${DOWNLOAD_DIR}" - mkdir -p "${PREFIX}/bin" - mkdir -p "${PREFIX}/include" - mkdir -p "${PREFIX}/lib" - - export CC CXX LD AR RANLIB STRIP PKG_CONFIG PKG_CONFIG_PATH PATH CFLAGS CXXFLAGS CPPFLAGS LDFLAGS + export PKG_CONFIG PKG_CONFIG_PATH + export CC CXX LD AR RANLIB STRIP + export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS } common_setup_arch() { From 40cc0d115266b485b45c3fecb6b68c14a80cfe3e Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 26 Jun 2026 01:59:46 +0200 Subject: [PATCH 13/76] external_deps: make defaults resetable with setup_default() --- external_deps/build.sh | 64 +++++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 22 deletions(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 396d233f04..c62797da8c 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -63,26 +63,6 @@ NCURSES_VERSION=6.5 WASISDK_VERSION=16.0 WASMTIME_VERSION=2.0.2 -# Require the compiler names to be explicitly hardcoded, we should not inherit them -# from environment as we heavily cross-compile. -CC='false' -CXX='false' -# Set defaults. -LD='ld' -AR='ar' -RANLIB='ranlib' -PKG_CONFIG='pkg-config' -CROSS_PKG_CONFIG_PATH='' -LIBS_SHARED='OFF' -LIBS_STATIC='ON' -CMAKE_TOOLCHAIN='' -# Always reset flags, we heavily cross-compile and must not inherit any stray flag -# from environment. -CPPFLAGS='' -CFLAGS='-O3 -fPIC' -CXXFLAGS='-O3 -fPIC' -LDFLAGS='-O3 -fPIC' - log() { level="${1}"; shift printf '%s: %s\n' "${level}" "${@}" >&2 @@ -1323,8 +1303,6 @@ common_setup() { "common_setup_${1}" common_setup_arch - EXE_EXT="${EXE_EXT:-}" - if "${GLOBAL_SETUP_ONCE:-true}" then DOWNLOAD_DIR="${WORK_DIR}/download_cache" @@ -1430,8 +1408,42 @@ common_setup_linux() { CXXFLAGS+=' -fPIC' } +setup_default() { + # Require the compiler names to be explicitly hardcoded, we should not inherit them + # from environment as we heavily cross-compile. + export CC='false' + export CXX='false' + + # Set defaults. + export LD='ld' + export AR='ar' + export RANLIB='ranlib' + export STRIP='strip' + export PKG_CONFIG='pkg-config' + export CROSS_PKG_CONFIG_PATH='' + + LIBS_SHARED='OFF' + LIBS_STATIC='ON' + CMAKE_TOOLCHAIN='' + EXE_EXT='' + + # Always reset flags, we heavily cross-compile and must not inherit any stray flag + # from environment. + export CPPFLAGS='' + export CFLAGS='-O3 -fPIC' + export CXXFLAGS='-O3 -fPIC' + export LDFLAGS='-O3 -fPIC' + + unset BITNESS + unset MACOS_ARCH + unset CMAKE_OSX_ARCHITECTURES + unset CROSS_PKG_CONFIG_PATH + unset MACOSX_DEPLOYMENT_TARGET +} + # Set up environment for 32-bit i686 Windows for Visual Studio (compile all as .dll) setup_windows-i686-msvc() { + setup_default BITNESS=32 CFLAGS+=' -mpreferred-stack-boundary=2' CXXFLAGS+=' -mpreferred-stack-boundary=2' @@ -1440,24 +1452,28 @@ setup_windows-i686-msvc() { # Set up environment for 64-bit amd64 Windows for Visual Studio (compile all as .dll) setup_windows-amd64-msvc() { + setup_default BITNESS=64 common_setup msvc x86_64-w64-mingw32 } # Set up environment for 32-bit i686 Windows for MinGW (compile all as .a) setup_windows-i686-mingw() { + setup_default BITNESS=32 common_setup mingw i686-w64-mingw32 } # Set up environment for 64-bit amd64 Windows for MinGW (compile all as .a) setup_windows-amd64-mingw() { + setup_default BITNESS=64 common_setup mingw x86_64-w64-mingw32 } # Set up environment for 64-bit amd64 macOS setup_macos-amd64-default() { + setup_default MACOS_ARCH=x86_64 # OpenAL requires 10.14. export MACOSX_DEPLOYMENT_TARGET=10.14 # works with CMake @@ -1466,21 +1482,25 @@ setup_macos-amd64-default() { # Set up environment for 32-bit i686 Linux setup_linux-i686-default() { + setup_default common_setup linux i686-unknown-linux-gnu } # Set up environment for 64-bit amd64 Linux setup_linux-amd64-default() { + setup_default common_setup linux x86_64-unknown-linux-gnu } # Set up environment for 32-bit little-endian hard-float arm Linux setup_linux-armhf-default() { + setup_default common_setup linux arm-unknown-linux-gnueabihf } # Set up environment for 64-bit little-endian arm Linux setup_linux-arm64-default() { + setup_default common_setup linux aarch64-unknown-linux-gnu } From 818c547f3cd87e183be53ffdf76ba592197c27ca Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 26 Jun 2026 01:48:05 +0200 Subject: [PATCH 14/76] external_deps: extract platform components --- external_deps/build.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/external_deps/build.sh b/external_deps/build.sh index c62797da8c..11f5fc7275 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -1303,6 +1303,11 @@ common_setup() { "common_setup_${1}" common_setup_arch + PLATFORM_SYSTEM="$(echo "${PLATFORM}" | cut -f1 -d-)" + PLATFORM_ARCH="$(echo "${PLATFORM}" | cut -f2 -d-)" + PLATFORM_COMPILER="$(echo "${PLATFORM}" | cut -f3 -d-)" + PLATFORM_TARGET="${PLATFORM_SYSTEM}-${PLATFORM_ARCH}" + if "${GLOBAL_SETUP_ONCE:-true}" then DOWNLOAD_DIR="${WORK_DIR}/download_cache" From 72c8de9880dfa497bcc194df8417609310e0523a Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 26 Jun 2026 08:31:21 +0200 Subject: [PATCH 15/76] external_deps: provide a reusable framework for building native tools needed for cross-compilation --- external_deps/build.sh | 71 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 61 insertions(+), 10 deletions(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 11f5fc7275..5b022064b8 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -162,6 +162,18 @@ download_extract() { configure_build() { local configure_args=() + case "${HOST}" in + native) + configure_args+=(--prefix="${NATIVE_PREFIX}") + configure_args+=(--libdir="${NATIVE_PREFIX}/lib") + ;; + *) + configure_args+=(--host="${HOST}") + configure_args+=(--prefix="${PREFIX}") + configure_args+=(--libdir="${PREFIX}/lib") + ;; + esac + if [ "${LIBS_SHARED}" = 'ON' ] then configure_args+=(--enable-shared) @@ -183,9 +195,6 @@ configure_build() { fi ./configure \ - --host="${HOST}" \ - --prefix="${PREFIX}" \ - --libdir="${PREFIX}/lib" \ "${configure_args[@]}" make @@ -209,6 +218,17 @@ get_compiler_arg1() { cmake_build() { local cmake_args=() + case "${HOST}" in + native) + cmake_args+=(-DCMAKE_PREFIX_PATH="${NATIVE_PREFIX}") + cmake_args+=(-DCMAKE_INSTALL_PREFIX="${NATIVE_PREFIX}") + ;; + *) + cmake_args+=(-DCMAKE_PREFIX_PATH="${PREFIX}") + cmake_args+=(-DCMAKE_INSTALL_PREFIX="${PREFIX}") + ;; + esac + cmake_args+=(-DCMAKE_C_COMPILER="$(get_compiler_name ${CC})") cmake_args+=(-DCMAKE_CXX_COMPILER="$(get_compiler_name ${CXX})") cmake_args+=(-DCMAKE_C_COMPILER_ARG1="$(get_compiler_arg1 ${CC})") @@ -228,8 +248,6 @@ cmake_build() { cmake -S . -B build \ -DCMAKE_TOOLCHAIN_FILE="${CMAKE_TOOLCHAIN}" \ -DCMAKE_BUILD_TYPE='Release' \ - -DCMAKE_PREFIX_PATH="${PREFIX}" \ - -DCMAKE_INSTALL_PREFIX="${PREFIX}" \ -DBUILD_SHARED_LIBS="${LIBS_SHARED}" \ "${cmake_args[@]}" @@ -237,7 +255,6 @@ cmake_build() { cmake --install build --strip } -# Build pkg-config, needed for opusfile. # As a host-mode dependency it must be provided by the system when cross-compiling. build_pkgconfig() { local dir_name="pkg-config-${PKGCONFIG_VERSION}" @@ -1316,14 +1333,17 @@ common_setup() { BUILD_BASEDIR="build-${PKG_BASEDIR}" BUILD_DIR="${WORK_DIR}/${BUILD_BASEDIR}" PREFIX="${BUILD_DIR}/prefix" - PATH="${PREFIX}/bin:${PATH}" + NATIVE_PREFIX="${BUILD_DIR}/native-prefix" mkdir -p "${DOWNLOAD_DIR}" mkdir -p "${PREFIX}/bin" mkdir -p "${PREFIX}/include" mkdir -p "${PREFIX}/lib" + mkdir -p "${NATIVE_PREFIX}/bin" + mkdir -p "${NATIVE_PREFIX}/include" + mkdir -p "${NATIVE_PREFIX}/lib" - export PATH + PATH="${NATIVE_PREFIX}/bin:${PATH}" GLOBAL_SETUP_ONCE='false' fi @@ -1332,6 +1352,7 @@ common_setup() { CPPFLAGS+=" -I${PREFIX}/include" LDFLAGS+=" -L${PREFIX}/lib" + export PATH export PKG_CONFIG PKG_CONFIG_PATH export CC CXX LD AR RANLIB STRIP export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS @@ -1355,6 +1376,8 @@ common_setup_arch() { CFLAGS+=' -march=armv7-a -mfpu=neon' CXXFLAGS+=' -march=armv7-a -mfpu=neon' ;; + *-native-*) + ;; *) log ERROR 'Unsupported platform' ;; @@ -1413,6 +1436,14 @@ common_setup_linux() { CXXFLAGS+=' -fPIC' } +common_setup_native() { + case "$(uname -s)" in + CYGWIN_NT-*|MSYS_NT-*|MINGW*_NT-*) + EXE_EXT='.exe' + ;; + esac +} + setup_default() { # Require the compiler names to be explicitly hardcoded, we should not inherit them # from environment as we heavily cross-compile. @@ -1442,7 +1473,6 @@ setup_default() { unset BITNESS unset MACOS_ARCH unset CMAKE_OSX_ARCHITECTURES - unset CROSS_PKG_CONFIG_PATH unset MACOSX_DEPLOYMENT_TARGET } @@ -1509,6 +1539,27 @@ setup_linux-arm64-default() { common_setup linux aarch64-unknown-linux-gnu } +# Set up environment for native host tools +setup_native() { + setup_default + CC='cc' + CXX='c++' + common_setup native native +} + +setup_platform() { + case "${1}" in + native) + export PLATFORM='native-native-native' + setup_native + ;; + *) + export PLATFORM="${1}" + "setup_${PLATFORM}" + ;; + esac +} + base_windows_amd64_msvc_packages='zlib gmp nettle curl sdl3 glew png jpeg webp openal ogg vorbis opus opusfile naclsdk depcheck genlib' all_windows_amd64_msvc_packages="${base_windows_amd64_msvc_packages}" @@ -1696,6 +1747,6 @@ esac for PLATFORM in ${platform_list} do ( - "setup_${PLATFORM}" + setup_platform "${PLATFORM}" build "${@}" ) done From f6686364ba4e09139f9a6981196df41911f41b92 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 26 Jun 2026 08:49:11 +0200 Subject: [PATCH 16/76] external_deps: build pkg-config as a native tool --- external_deps/build.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 5b022064b8..27bd43f411 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -255,26 +255,26 @@ cmake_build() { cmake --install build --strip } -# As a host-mode dependency it must be provided by the system when cross-compiling. -build_pkgconfig() { +# Build pkg-config, needed for opusfile on macos. +# It is part of the cross-compilation toolchain. +# As a host-mode native dependency it must be provided by the system when cross-compiling. +build_native-pkgconfig() { local dir_name="pkg-config-${PKGCONFIG_VERSION}" local archive_name="${dir_name}.tar.gz" - download_extract pkgconfig "${archive_name}" \ + download_extract native-pkgconfig "${archive_name}" \ "${PKGCONFIG_BASEURL}/${archive_name}" "${download_only}" && return cd "${dir_name}" - # Reset the environment variables, we don't cross-compile this, - # it is part of the cross-compilation toolchain. - # CXXFLAGS is unused. - CFLAGS='-Wno-error=int-conversion' \ - LDFLAGS='' \ - HOST='' \ - configure_build \ + ( + setup_platform 'native' + CFLAGS='-Wno-error=int-conversion' \ + configure_build \ --with-internal-glib + ) } # Build NASM @@ -1572,7 +1572,7 @@ all_windows_amd64_mingw_packages="${base_windows_amd64_mingw_packages}" base_windows_i686_mingw_packages="${base_windows_amd64_mingw_packages}" all_windows_i686_mingw_packages="${base_windows_amd64_mingw_packages}" -base_macos_amd64_default_packages='pkgconfig nasm gmp nettle sdl3 glew png jpeg webp openal ogg vorbis opus opusfile naclsdk' +base_macos_amd64_default_packages='native-pkgconfig nasm gmp nettle sdl3 glew png jpeg webp openal ogg vorbis opus opusfile naclsdk' all_macos_amd64_default_packages="${base_macos_amd64_default_packages}" base_linux_i686_default_packages='sdl3 naclsdk' @@ -1613,7 +1613,7 @@ printHelp() { all linux windows macos Packages: - pkgconfig nasm zlib gmp nettle curl sdl3 glew png jpeg webp openal ogg vorbis opus opusfile naclsdk wasisdk wasmtime + native-pkgconfig nasm zlib gmp nettle curl sdl3 glew png jpeg webp openal ogg vorbis opus opusfile naclsdk wasisdk wasmtime Virtual packages: base build packages for pre-built binaries to be downloaded when building the game From 2ecff5c35f32296a7713b2c31dfb737fb065484c Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 26 Jun 2026 09:05:48 +0200 Subject: [PATCH 17/76] external_deps: build nasm as a native tool --- external_deps/build.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 27bd43f411..328736fb3a 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -277,19 +277,21 @@ build_native-pkgconfig() { ) } -# Build NASM -build_nasm() { +# Build NASM, needed for jpeg on macos-amd64. +# It is part of the compilation toolchain. +# As a host-mode native dependency it must be provided by the system when compiling. +build_native-nasm() { case "${PLATFORM}" in macos-*-*) local dir_name="nasm-${NASM_VERSION}" local archive_name="${dir_name}-macosx.zip" - download_extract nasm "${archive_name}" \ + download_extract native-nasm "${archive_name}" \ "${NASM_BASEURL}/${NASM_VERSION}/macosx/${archive_name}" "${download_only}" && return - smart_copy "${dir_name}/nasm" "${PREFIX}/bin" + smart_copy "${dir_name}/nasm" "${NATIVE_PREFIX}/bin" ;; *) log ERROR 'Unsupported platform for NASM' @@ -1572,7 +1574,7 @@ all_windows_amd64_mingw_packages="${base_windows_amd64_mingw_packages}" base_windows_i686_mingw_packages="${base_windows_amd64_mingw_packages}" all_windows_i686_mingw_packages="${base_windows_amd64_mingw_packages}" -base_macos_amd64_default_packages='native-pkgconfig nasm gmp nettle sdl3 glew png jpeg webp openal ogg vorbis opus opusfile naclsdk' +base_macos_amd64_default_packages='native-pkgconfig native-nasm gmp nettle sdl3 glew png jpeg webp openal ogg vorbis opus opusfile naclsdk' all_macos_amd64_default_packages="${base_macos_amd64_default_packages}" base_linux_i686_default_packages='sdl3 naclsdk' @@ -1613,7 +1615,7 @@ printHelp() { all linux windows macos Packages: - native-pkgconfig nasm zlib gmp nettle curl sdl3 glew png jpeg webp openal ogg vorbis opus opusfile naclsdk wasisdk wasmtime + native-pkgconfig native-nasm zlib gmp nettle curl sdl3 glew png jpeg webp openal ogg vorbis opus opusfile naclsdk wasisdk wasmtime Virtual packages: base build packages for pre-built binaries to be downloaded when building the game From fef349169e2cfa14d8b0172fffd3d0ed906919a3 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 26 Jun 2026 09:37:54 +0200 Subject: [PATCH 18/76] cmake,external_deps: bump deps version to 12, expect the loader be packaged with architecture suffix --- CMakeLists.txt | 76 +++++++++++-------------- external_deps/build.sh | 23 ++++---- src/engine/framework/VirtualMachine.cpp | 6 +- 3 files changed, 49 insertions(+), 56 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 997c330061..6b2a3ccf6f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -199,7 +199,7 @@ else() endif() # Dependencies versions -set(DEPS_VERSION 11) # This must match the number in external_deps/build.sh +set(DEPS_VERSION 12) # This must match the number in external_deps/build.sh set(SAIGOSDK_VERSION 20260925) # This must match the number in external_deps/sdk-build.sh option(USE_EXTERNAL_DEPS "Download or reuse dependencies from EXTERNAL_DEPS_DIR (mandatory for building and running NaCl .nexe binaries)." ON) @@ -411,33 +411,33 @@ if (DEPS_DIR) if (NOT EXISTS ${DEPS_DIR}) file(MAKE_DIRECTORY ${EXTERNAL_DEPS_DIR}) get_filename_component(BASENAME ${DEPS_DIR} NAME) - set(DEPS_FILENAME "${BASENAME}${DEPS_EXT}") - - # Download test DEPS archive if DEPS archive isn't available yet. - # This makes possible to get the CI working before releasing the DEPS archive. - foreach(REMOTE_BASEURL https://dl.unvanquished.net/deps;https://dl.unvanquished.net/test/deps) - set(REMOTE "${REMOTE_BASEURL}/${DEPS_FILENAME}") - message(STATUS "Downloading dependencies from '${REMOTE}'") - - file(DOWNLOAD "${REMOTE}" "${OBJ_DIR}/${DEPS_FILENAME}" - SHOW_PROGRESS - STATUS DOWNLOAD_RESULT - LOG DOWNLOAD_LOG - ) - - list(GET DOWNLOAD_RESULT 0 DOWNLOAD_STATUS) - list(GET DOWNLOAD_RESULT 1 DOWNLOAD_STRING) - - if (DOWNLOAD_STATUS EQUAL 0) - break() - else () - message(WARNING "Error downloading '${REMOTE}': - Status code: ${DOWNLOAD_STATUS} - Error string: ${DOWNLOAD_STRING} - Download log: ${DOWNLOAD_LOG}" - ) - endif() - endforeach() + set(DEPS_FILENAME "${BASENAME}${DEPS_EXT}") + + # Download test DEPS archive if DEPS archive isn't available yet. + # This makes possible to get the CI working before releasing the DEPS archive. + foreach(REMOTE_BASEURL https://dl.unvanquished.net/deps;https://dl.unvanquished.net/test/deps) + set(REMOTE "${REMOTE_BASEURL}/${DEPS_FILENAME}") + message(STATUS "Downloading dependencies from '${REMOTE}'") + + file(DOWNLOAD "${REMOTE}" "${OBJ_DIR}/${DEPS_FILENAME}" + SHOW_PROGRESS + STATUS DOWNLOAD_RESULT + LOG DOWNLOAD_LOG + ) + + list(GET DOWNLOAD_RESULT 0 DOWNLOAD_STATUS) + list(GET DOWNLOAD_RESULT 1 DOWNLOAD_STRING) + + if (DOWNLOAD_STATUS EQUAL 0) + break() + else () + message(WARNING "Error downloading '${REMOTE}': + Status code: ${DOWNLOAD_STATUS} + Error string: ${DOWNLOAD_STRING} + Download log: ${DOWNLOAD_LOG}" + ) + endif() + endforeach() if (NOT DOWNLOAD_STATUS EQUAL 0) message(FATAL_ERROR "Failed to download '${DEPS_FILENAME}'") @@ -979,20 +979,11 @@ if (DEPS_DIR AND HAS_NACL AND (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER foreach(arch_name IN LISTS DAEMON_NACL_ARCH_NAME_LIST) # The NaCl loader and IRT are required to load .nexe files - if (YOKAI_TARGET_SYSTEM_WINDOWS AND YOKAI_TARGET_ARCH_I686 AND "${arch_name}" STREQUAL "amd64") - # Backport compatibility until the external_deps script properly suffixes names in the archives. add_custom_command(TARGET runtime_deps PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DEPS_DIR}/nacl_loader-${arch_name}${CMAKE_EXECUTABLE_SUFFIX} ${FULL_OUTPUT_DIR}/nacl_loader-${arch_name}${CMAKE_EXECUTABLE_SUFFIX} ) - else() - add_custom_command(TARGET runtime_deps PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${DEPS_DIR}/nacl_loader${CMAKE_EXECUTABLE_SUFFIX} - ${FULL_OUTPUT_DIR}/nacl_loader-${arch_name}${CMAKE_EXECUTABLE_SUFFIX} - ) - endif() add_custom_command(TARGET runtime_deps PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different @@ -1002,14 +993,13 @@ if (DEPS_DIR AND HAS_NACL AND (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER endforeach() if (YOKAI_TARGET_SYSTEM_LINUX_COMPATIBILITY) - # Backport compatibility until the external_deps script properly suffixes names in the archives. - if (YOKAI_TARGET_ARCH_ARM64) + foreach(arch_name IN LISTS DAEMON_NACL_MULTILIB_ARCH_NAME_LIST) add_custom_command(TARGET runtime_deps PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory - ${DEPS_DIR}/lib-armhf - ${FULL_OUTPUT_DIR}/lib-armhf + ${DEPS_DIR}/libs-linux-${arch_name} + ${FULL_OUTPUT_DIR}/libs-linux-${arch_name} ) - endif() + endforeach() # Linux uses a bootstrap program to reserve address space for 32-bit runtimes. foreach(arch_name IN LISTS DAEMON_NACL_ARCH_NAME_LIST) @@ -1017,7 +1007,7 @@ if (DEPS_DIR AND HAS_NACL AND (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER if ("${arch_name}" IN_LIST arch_32bit) add_custom_command(TARGET runtime_deps PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${DEPS_DIR}/nacl_helper_bootstrap + ${DEPS_DIR}/nacl_helper_bootstrap-${arch_name} ${FULL_OUTPUT_DIR}/nacl_helper_bootstrap-${arch_name} ) endif() diff --git a/external_deps/build.sh b/external_deps/build.sh index 328736fb3a..84912ee7a6 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -9,7 +9,7 @@ WORK_DIR="${PWD}" # This should match the DEPS_VERSION in CMakeLists.txt. # This is mostly to ensure the path the files end up at if you build deps yourself # are the same as the ones when extracting from the downloaded packages. -DEPS_VERSION=11 +DEPS_VERSION=12 # Package download pages PKGCONFIG_BASEURL='https://pkg-config.freedesktop.org/releases' @@ -1032,7 +1032,7 @@ build_naclsdk() { linux-amd64-*) ;; # Get sel_ldr from naclruntime package *) - smart_copy pepper_*"/tools/sel_ldr_${NACLSDK_ARCH}${EXE_EXT}" "${PREFIX}/nacl_loader${EXE_EXT}" + smart_copy pepper_*"/tools/sel_ldr_${NACLSDK_ARCH}${EXE_EXT}" "${PREFIX}/nacl_loader-${DAEMON_ARCH}${EXE_EXT}" ;; esac case "${PLATFORM}" in @@ -1064,22 +1064,25 @@ build_naclsdk() { chmod 644 "${PREFIX}/irt_core-${DAEMON_ARCH}.nexe" ;; linux-i686-*|linux-armhf-*|linux-arm64-*) - smart_copy pepper_*"/tools/nacl_helper_bootstrap_${NACLSDK_ARCH}" "${PREFIX}/nacl_helper_bootstrap" + smart_copy pepper_*"/tools/nacl_helper_bootstrap_${NACLSDK_ARCH}" "${PREFIX}/nacl_helper_bootstrap-${DAEMON_ARCH}" # Fix permissions on a few files which deny access to non-owner chmod 644 "${PREFIX}/irt_core-${DAEMON_ARCH}.nexe" - chmod 755 "${PREFIX}/nacl_helper_bootstrap" "${PREFIX}/nacl_loader" + chmod 755 "${PREFIX}/nacl_helper_bootstrap-${DAEMON_ARCH}" "${PREFIX}/nacl_loader-${DAEMON_ARCH}" ;; esac case "${PLATFORM}" in linux-arm64-*) - mkdir -p "${PREFIX}/lib-armhf" - smart_copy -R pepper_*"/tools/lib/arm_trusted/lib/." "${PREFIX}/lib-armhf/." + local libdir_path='libs-linux-armhf' + local loader_path="${libdir_path}/loader" + mkdir -p "${PREFIX}/${libdir_path}" + smart_copy -R pepper_*"/tools/lib/arm_trusted/lib/." "${PREFIX}/${libdir_path}/." # Copy the library loader instead of renaming it because there may still be some # references to ld-linux-armhf.so.3 in binaries. - smart_copy "${PREFIX}/lib-armhf/ld-linux-armhf.so.3" "${PREFIX}/lib-armhf/ld-linux-armhf" + smart_copy "${PREFIX}/${libdir_path}/ld-linux-armhf.so.3" "${PREFIX}/${loader_path}" # We can't use patchelf or 'nacl_helper_bootstrap nacl_loader' will complain: # bootstrap_helper: nacl_loader: ELF file has unreasonable e_phnum=13 - sed -e 's|/lib/ld-linux-armhf.so.3|lib-armhf/ld-linux-armhf|' -i "${PREFIX}/nacl_loader" + # We're lucky that the replacement string isn't larger than the original one. + sed -e "s|/lib/ld-linux-armhf.so.3|${loader_path}|" -i "${PREFIX}/nacl_loader-armhf" ;; esac } @@ -1105,8 +1108,8 @@ build_naclruntime() { cd "${dir_name}" env -i /usr/bin/env bash -l -c "python3 /usr/bin/scons --mode=opt-linux 'platform=${NACL_ARCH}' werror=0 sysinfo=0 sel_ldr" - smart_copy "scons-out/opt-linux-${NACL_ARCH}/staging/nacl_helper_bootstrap" "${PREFIX}/nacl_helper_bootstrap" - smart_copy "scons-out/opt-linux-${NACL_ARCH}/staging/sel_ldr" "${PREFIX}/nacl_loader" + smart_copy "scons-out/opt-linux-${NACL_ARCH}/staging/nacl_helper_bootstrap" "${PREFIX}/nacl_helper_bootstrap-amd64" + smart_copy "scons-out/opt-linux-${NACL_ARCH}/staging/sel_ldr" "${PREFIX}/nacl_loader-amd64" } # Check for DLL dependencies on MinGW stuff. For MSVC platforms this is bad because it should work diff --git a/src/engine/framework/VirtualMachine.cpp b/src/engine/framework/VirtualMachine.cpp index 87a176ea25..d53afd5c62 100644 --- a/src/engine/framework/VirtualMachine.cpp +++ b/src/engine/framework/VirtualMachine.cpp @@ -336,7 +336,7 @@ static std::pair InternalLoadModule(std::pair("LD_LIBRARY_PATH=lib-armhf"); + emptyEnv[0] = const_cast("LD_LIBRARY_PATH=libs-linux-armhf"); if (0 != posix_spawn_file_actions_addchdir_np(&fileActions, FS::GetLibPath().c_str())) { Sys::Error("failed posix_spawn_file_actions_addchdir"); @@ -500,8 +500,8 @@ static std::pair CreateNaClVM(std::pair Date: Fri, 26 Jun 2026 00:29:15 +0200 Subject: [PATCH 19/76] external_deps: build naclruntime with cmake --- external_deps/build.sh | 152 ++++++++++++++++++++++++----------------- 1 file changed, 90 insertions(+), 62 deletions(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 84912ee7a6..1b894e82bb 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -58,7 +58,7 @@ VORBIS_VERSION=1.3.7 OPUS_VERSION=1.5.2 OPUSFILE_VERSION=0.12 NACLSDK_VERSION=44.0.2403.155 -NACLRUNTIME_REVISION=2aea5fcfce504862a825920fcaea1a8426afbd6f +NACLRUNTIME_REVISION='70beec35eb5fa3ddd571f18f9ad57b5da674d85d' NCURSES_VERSION=6.5 WASISDK_VERSION=16.0 WASMTIME_VERSION=2.0.2 @@ -1005,6 +1005,7 @@ build_naclsdk() { local TAR_EXT=tar ;; esac + case "${PLATFORM}" in *-i686-*) local NACLSDK_ARCH=x86_32 @@ -1014,10 +1015,13 @@ build_naclsdk() { local NACLSDK_ARCH=x86_64 local DAEMON_ARCH=amd64 ;; - *-armhf-*|linux-arm64-*) + linux-armhf-*|linux-arm64-*) local NACLSDK_ARCH=arm local DAEMON_ARCH=armhf ;; + *) + log ERROR 'Unsupported platform for NaCl SDK' + ;; esac local archive_name="naclsdk_${NACLSDK_PLATFORM}-${NACLSDK_VERSION}.${TAR_EXT}.bz2" @@ -1028,13 +1032,7 @@ build_naclsdk() { "${download_only}" && return smart_copy pepper_*"/tools/irt_core_${NACLSDK_ARCH}.nexe" "${PREFIX}/irt_core-${DAEMON_ARCH}.nexe" - case "${PLATFORM}" in - linux-amd64-*) - ;; # Get sel_ldr from naclruntime package - *) - smart_copy pepper_*"/tools/sel_ldr_${NACLSDK_ARCH}${EXE_EXT}" "${PREFIX}/nacl_loader-${DAEMON_ARCH}${EXE_EXT}" - ;; - esac + case "${PLATFORM}" in windows-i686-*|*-amd64-*) smart_copy pepper_*"/toolchain/${NACLSDK_PLATFORM}_x86_newlib/bin/x86_64-nacl-gdb${EXE_EXT}" "${PREFIX}/nacl-gdb${EXE_EXT}" @@ -1056,42 +1054,41 @@ build_naclsdk() { esac case "${PLATFORM}" in windows-i686-*) - smart_copy pepper_*"/tools/sel_ldr_x86_64.exe" "${PREFIX}/nacl_loader-amd64.exe" smart_copy pepper_*"/tools/irt_core_x86_64.nexe" "${PREFIX}/irt_core-amd64.nexe" ;; - linux-amd64-*) - # Fix permissions on a few files which deny access to non-owner - chmod 644 "${PREFIX}/irt_core-${DAEMON_ARCH}.nexe" - ;; - linux-i686-*|linux-armhf-*|linux-arm64-*) - smart_copy pepper_*"/tools/nacl_helper_bootstrap_${NACLSDK_ARCH}" "${PREFIX}/nacl_helper_bootstrap-${DAEMON_ARCH}" + linux-*-*) # Fix permissions on a few files which deny access to non-owner chmod 644 "${PREFIX}/irt_core-${DAEMON_ARCH}.nexe" - chmod 755 "${PREFIX}/nacl_helper_bootstrap-${DAEMON_ARCH}" "${PREFIX}/nacl_loader-${DAEMON_ARCH}" - ;; - esac - case "${PLATFORM}" in - linux-arm64-*) - local libdir_path='libs-linux-armhf' - local loader_path="${libdir_path}/loader" - mkdir -p "${PREFIX}/${libdir_path}" - smart_copy -R pepper_*"/tools/lib/arm_trusted/lib/." "${PREFIX}/${libdir_path}/." - # Copy the library loader instead of renaming it because there may still be some - # references to ld-linux-armhf.so.3 in binaries. - smart_copy "${PREFIX}/${libdir_path}/ld-linux-armhf.so.3" "${PREFIX}/${loader_path}" - # We can't use patchelf or 'nacl_helper_bootstrap nacl_loader' will complain: - # bootstrap_helper: nacl_loader: ELF file has unreasonable e_phnum=13 - # We're lucky that the replacement string isn't larger than the original one. - sed -e "s|/lib/ld-linux-armhf.so.3|${loader_path}|" -i "${PREFIX}/nacl_loader-armhf" ;; esac } # Only builds nacl_loader and nacl_helper_bootstrap for now, not IRT. build_naclruntime() { + local nacl_arch_list=() + case "${PLATFORM}" in + windows-amd64-*) + nacl_arch_list+=('amd64') + ;; + windows-i686-*) + nacl_arch_list+=('i686') + nacl_arch_list+=('amd64') + ;; linux-amd64-*) - local NACL_ARCH=x86-64 + nacl_arch_list+=('amd64') + ;; + linux-i686-*) + nacl_arch_list+=('i686') + ;; + linux-arm64-*) + nacl_arch_list+=('armhf') + ;; + linux-armhf-*) + nacl_arch_list+=('armhf') + ;; + macos-amd64-*) + nacl_arch_list+=('amd64') ;; *) log ERROR 'Unsupported platform for naclruntime' @@ -1102,14 +1099,51 @@ build_naclruntime() { local archive_name="native_client-${NACLRUNTIME_REVISION}.zip" download_extract naclruntime "${archive_name}" \ - "{$NACLRUNTIME_BASEURL}/${NACLRUNTIME_REVISION}" + "${NACLRUNTIME_BASEURL}/${NACLRUNTIME_REVISION}" "${download_only}" && return cd "${dir_name}" - env -i /usr/bin/env bash -l -c "python3 /usr/bin/scons --mode=opt-linux 'platform=${NACL_ARCH}' werror=0 sysinfo=0 sel_ldr" - smart_copy "scons-out/opt-linux-${NACL_ARCH}/staging/nacl_helper_bootstrap" "${PREFIX}/nacl_helper_bootstrap-amd64" - smart_copy "scons-out/opt-linux-${NACL_ARCH}/staging/sel_ldr" "${PREFIX}/nacl_loader-amd64" + + for nacl_arch in "${nacl_arch_list[@]}" + do + ( + setup_platform "${PLATFORM_SYSTEM}-${nacl_arch}-${PLATFORM_COMPILER}" + cmake_build + ) + + case "${PLATFORM}" in + linux-*) + mv "${PREFIX}/bin/nacl_helper_bootstrap" "${PREFIX}/nacl_helper_bootstrap-${nacl_arch}" + ;; + esac + + mv "${PREFIX}/bin/sel_ldr${EXE_EXT}" "${PREFIX}/nacl_loader-${nacl_arch}${EXE_EXT}" + + case "${PLATFORM}" in + linux-arm64-*) + case "${nacl_arch}" in + armhf) + local libdir_path='libs-linux-armhf' + + mkdir -p "${PREFIX}/${libdir_path}" + + smart_copy -L \ + '/lib/arm-linux-gnueabihf/ld-linux-armhf.so.3' \ + '/lib/arm-linux-gnueabihf/libstdc++.so.6' \ + '/lib/arm-linux-gnueabihf/libc.so.6' \ + '/lib/arm-linux-gnueabihf/libm.so.6' \ + '/lib/arm-linux-gnueabihf/libgcc_s.so.1' \ + '/lib/arm-linux-gnueabihf/librt.so.1' \ + '/lib/arm-linux-gnueabihf/libpthread.so.0' \ + "${PREFIX}/${libdir_path}/" + + patchelf --set-interpreter "${libdir_path}/ld-linux-armhf.so.3" "${PREFIX}/nacl_loader-armhf" + ;; + esac + ;; + esac + done } # Check for DLL dependencies on MinGW stuff. For MSVC platforms this is bad because it should work @@ -1565,32 +1599,32 @@ setup_platform() { esac } -base_windows_amd64_msvc_packages='zlib gmp nettle curl sdl3 glew png jpeg webp openal ogg vorbis opus opusfile naclsdk depcheck genlib' -all_windows_amd64_msvc_packages="${base_windows_amd64_msvc_packages}" - -base_windows_i686_msvc_packages="${base_windows_amd64_msvc_packages}" -all_windows_i686_msvc_packages="${base_windows_amd64_msvc_packages}" - -base_windows_amd64_mingw_packages='zlib gmp nettle curl sdl3 glew png jpeg webp openal ogg vorbis opus opusfile naclsdk depcheck' +base_windows_amd64_mingw_packages='native-jwasm zlib gmp nettle curl sdl3 glew png jpeg webp openal ogg vorbis opus opusfile naclsdk naclruntime depcheck' all_windows_amd64_mingw_packages="${base_windows_amd64_mingw_packages}" base_windows_i686_mingw_packages="${base_windows_amd64_mingw_packages}" all_windows_i686_mingw_packages="${base_windows_amd64_mingw_packages}" -base_macos_amd64_default_packages='native-pkgconfig native-nasm gmp nettle sdl3 glew png jpeg webp openal ogg vorbis opus opusfile naclsdk' +base_windows_amd64_msvc_packages="${base_windows_amd64_mingw_packages} genlib" +all_windows_amd64_msvc_packages="${base_windows_amd64_msvc_packages}" + +base_windows_i686_msvc_packages="${base_windows_amd64_msvc_packages}" +all_windows_i686_msvc_packages="${base_windows_amd64_msvc_packages}" + +base_macos_amd64_default_packages='native-pkgconfig native-nasm gmp nettle sdl3 glew png jpeg webp openal ogg vorbis opus opusfile naclsdk naclruntime' all_macos_amd64_default_packages="${base_macos_amd64_default_packages}" -base_linux_i686_default_packages='sdl3 naclsdk' -all_linux_i686_default_packages='zlib gmp nettle curl sdl3 glew png jpeg webp openal ogg vorbis opus opusfile ncurses naclsdk' +base_linux_amd64_default_packages='sdl3 naclsdk naclruntime' +all_linux_amd64_default_packages='zlib gmp nettle curl sdl3 glew png jpeg webp openal ogg vorbis opus opusfile ncurses naclsdk naclruntime' -base_linux_amd64_default_packages="${base_linux_i686_default_packages} naclruntime" -all_linux_amd64_default_packages="${all_linux_i686_default_packages} naclruntime" +base_linux_i686_default_packages="${base_linux_amd64_default_packages}" +all_linux_i686_default_packages="${all_linux_amd64_default_packages}" -base_linux_arm64_default_packages='sdl3 naclsdk' -all_linux_arm64_default_packages='zlib gmp nettle curl sdl3 glew png jpeg webp openal ogg vorbis opus opusfile ncurses naclsdk' +base_linux_arm64_default_packages="${base_linux_amd64_default_packages}" +all_linux_arm64_default_packages="${all_linux_amd64_default_packages}" -base_linux_armhf_default_packages="${base_linux_arm64_default_packages}" -all_linux_armhf_default_packages="${all_linux_arm64_default_packages}" +base_linux_armhf_default_packages="${base_linux_amd64_default_packages}" +all_linux_armhf_default_packages="${all_linux_amd64_default_packages}" all_linux_platforms='linux-amd64-default linux-arm64-default linux-armhf-default linux-i686-default' all_windows_platforms='windows-amd64-mingw windows-amd64-msvc windows-i686-mingw windows-i686-msvc' @@ -1618,7 +1652,7 @@ printHelp() { all linux windows macos Packages: - native-pkgconfig native-nasm zlib gmp nettle curl sdl3 glew png jpeg webp openal ogg vorbis opus opusfile naclsdk wasisdk wasmtime + native-pkgconfig native-nasm zlib gmp nettle curl sdl3 glew png jpeg webp openal ogg vorbis opus opusfile naclsdk naclruntime wasisdk wasmtime Virtual packages: base build packages for pre-built binaries to be downloaded when building the game @@ -1646,17 +1680,11 @@ printHelp() { all same linux-amd64-default: - base ${base_linux_amd64_default_packages} - all ${all_linux_amd64_default_packages} - linux-i686-default: - base ${base_linux_i686_default_packages} - all ${all_linux_i686_default_packages} - linux-arm64-default: linux-armhf-default: - base ${base_linux_arm64_default_packages} - all ${all_linux_arm64_default_packages} + base ${base_linux_amd64_default_packages} + all ${all_linux_amd64_default_packages} EOF From e51cfb72c5a86253420c18546bd49ce756cc8802 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 27 Jun 2026 04:42:36 +0200 Subject: [PATCH 20/76] external_deps: rework the cmake toolchain configuration --- external_deps/build.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 1b894e82bb..3bb7eb35ef 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -237,6 +237,11 @@ cmake_build() { cmake_args+=(-DCMAKE_CXX_FLAGS="${CXXFLAGS}") cmake_args+=(-DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}") + if [ -n "${CMAKE_TOOLCHAIN:-}" ] + then + cmake_args+=(-DCMAKE_TOOLCHAIN_FILE="${CMAKE_TOOLCHAIN}") + fi + # Check for ${@} not being empty to workaround a macOS bash limitation. if [ -n "${1:-}" ] then @@ -246,7 +251,6 @@ cmake_build() { rm -rf build cmake -S . -B build \ - -DCMAKE_TOOLCHAIN_FILE="${CMAKE_TOOLCHAIN}" \ -DCMAKE_BUILD_TYPE='Release' \ -DBUILD_SHARED_LIBS="${LIBS_SHARED}" \ "${cmake_args[@]}" @@ -1499,7 +1503,7 @@ setup_default() { LIBS_SHARED='OFF' LIBS_STATIC='ON' - CMAKE_TOOLCHAIN='' + EXE_EXT='' # Always reset flags, we heavily cross-compile and must not inherit any stray flag @@ -1511,8 +1515,7 @@ setup_default() { unset BITNESS unset MACOS_ARCH - unset CMAKE_OSX_ARCHITECTURES - unset MACOSX_DEPLOYMENT_TARGET + unset CMAKE_TOOLCHAIN } # Set up environment for 32-bit i686 Windows for Visual Studio (compile all as .dll) From 6298e4b84b7539de014543a972b635e559bdc988 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 27 Jun 2026 04:36:07 +0200 Subject: [PATCH 21/76] external_deps: rework the macos configuration --- external_deps/build.sh | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 3bb7eb35ef..e3a5061e11 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -229,6 +229,13 @@ cmake_build() { ;; esac + case "${HOST}" in + macos-*) + cmake_args+=(-DCMAKE_OSX_ARCHITECTURES="${MACOS_ARCH}") + cmake_args+=(-DCMAKE_OSX_DEPLOYMENT_TARGET="${MACOS_VERSION}") + ;; + esac + cmake_args+=(-DCMAKE_C_COMPILER="$(get_compiler_name ${CC})") cmake_args+=(-DCMAKE_CXX_COMPILER="$(get_compiler_name ${CXX})") cmake_args+=(-DCMAKE_C_COMPILER_ARG1="$(get_compiler_arg1 ${CC})") @@ -1464,10 +1471,9 @@ common_setup_macos() { CC='clang' CXX='clang++' STRIP='strip' - CFLAGS+=" -arch ${MACOS_ARCH}" - CXXFLAGS+=" -arch ${MACOS_ARCH}" - LDFLAGS+=" -arch ${MACOS_ARCH}" - export CMAKE_OSX_ARCHITECTURES="${MACOS_ARCH}" + CFLAGS+=" -arch ${MACOS_ARCH} -mmacosx-version-min=${MACOS_VERSION}" + CXXFLAGS+=" -arch ${MACOS_ARCH} -mmacosx-version-min=${MACOS_VERSION}" + LDFLAGS+=" -arch ${MACOS_ARCH} -mmacosx-version-min=${MACOS_VERSION}" } common_setup_linux() { @@ -1515,6 +1521,8 @@ setup_default() { unset BITNESS unset MACOS_ARCH + unset MACOS_VERSION + unset MACOS_HOST unset CMAKE_TOOLCHAIN } @@ -1548,13 +1556,18 @@ setup_windows-amd64-mingw() { common_setup mingw x86_64-w64-mingw32 } +setup_macos() { + MACOS_HOST="${MACOS_ARCH}-apple-macos${MACOS_VERSION}" + common_setup macos "${MACOS_HOST}" +} + # Set up environment for 64-bit amd64 macOS setup_macos-amd64-default() { setup_default MACOS_ARCH=x86_64 # OpenAL requires 10.14. - export MACOSX_DEPLOYMENT_TARGET=10.14 # works with CMake - common_setup macos "x86_64-apple-macos${MACOSX_DEPLOYMENT_TARGET}" + MACOS_VERSION='10.14' + setup_macos } # Set up environment for 32-bit i686 Linux From 664f5cc0e2026738b57d1dd6eec5cd30ea64be97 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 26 Jun 2026 02:28:57 +0200 Subject: [PATCH 22/76] external_deps: add macos-arm64-default --- external_deps/build.sh | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index e3a5061e11..922a42945a 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -293,7 +293,7 @@ build_native-pkgconfig() { # As a host-mode native dependency it must be provided by the system when compiling. build_native-nasm() { case "${PLATFORM}" in - macos-*-*) + macos-amd64-*) local dir_name="nasm-${NASM_VERSION}" local archive_name="${dir_name}-macosx.zip" @@ -897,6 +897,8 @@ build_opusfile() { cd "${dir_name}" + # The old configure script doesn't recognize the arm64 prefix. + HOST="${HOST/arm64-apple/aarch64-apple}" \ configure_build \ --disable-http } @@ -1022,7 +1024,7 @@ build_naclsdk() { local NACLSDK_ARCH=x86_32 local DAEMON_ARCH=i686 ;; - *-amd64-*) + *-amd64-*|macos-arm64-*) local NACLSDK_ARCH=x86_64 local DAEMON_ARCH=amd64 ;; @@ -1101,6 +1103,9 @@ build_naclruntime() { macos-amd64-*) nacl_arch_list+=('amd64') ;; + macos-arm64-*) + nacl_arch_list+=('amd64') + ;; *) log ERROR 'Unsupported platform for naclruntime' ;; @@ -1564,12 +1569,20 @@ setup_macos() { # Set up environment for 64-bit amd64 macOS setup_macos-amd64-default() { setup_default - MACOS_ARCH=x86_64 + MACOS_ARCH='x86_64' # OpenAL requires 10.14. MACOS_VERSION='10.14' setup_macos } +# Set up environment for 64-bit arm64 macOS +setup_macos-arm64-default() { + setup_default + MACOS_ARCH='arm64' + MACOS_VERSION='11.7' + setup_macos +} + # Set up environment for 32-bit i686 Linux setup_linux-i686-default() { setup_default @@ -1627,7 +1640,10 @@ all_windows_amd64_msvc_packages="${base_windows_amd64_msvc_packages}" base_windows_i686_msvc_packages="${base_windows_amd64_msvc_packages}" all_windows_i686_msvc_packages="${base_windows_amd64_msvc_packages}" -base_macos_amd64_default_packages='native-pkgconfig native-nasm gmp nettle sdl3 glew png jpeg webp openal ogg vorbis opus opusfile naclsdk naclruntime' +base_macos_arm64_default_packages='native-pkgconfig gmp nettle sdl3 glew png jpeg webp openal ogg vorbis opus opusfile naclsdk naclruntime' +all_macos_arm64_default_packages="${base_macos_arm64_default_packages}" + +base_macos_amd64_default_packages="native-nasm ${base_macos_arm64_default_packages}" all_macos_amd64_default_packages="${base_macos_amd64_default_packages}" base_linux_amd64_default_packages='sdl3 naclsdk naclruntime' @@ -1644,7 +1660,7 @@ all_linux_armhf_default_packages="${all_linux_amd64_default_packages}" all_linux_platforms='linux-amd64-default linux-arm64-default linux-armhf-default linux-i686-default' all_windows_platforms='windows-amd64-mingw windows-amd64-msvc windows-i686-mingw windows-i686-msvc' -all_macos_platforms='macos-amd64-default' +all_macos_platforms='macos-amd64-default macos-arm64-default' all_platforms="${all_linux_platforms} ${all_windows_platforms} ${all_macos_platforms}" printHelp() { @@ -1695,6 +1711,10 @@ printHelp() { base ${base_macos_amd64_default_packages} all same + macos-arm64-default: + base ${base_macos_arm64_default_packages} + all same + linux-amd64-default: linux-i686-default: linux-arm64-default: From 81fe3910c99feda43725f7f77f7b2612c667b00b Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 26 Jun 2026 12:25:47 +0200 Subject: [PATCH 23/76] external_deps: upgrade sdl3 --- external_deps/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 922a42945a..5f11d7b8c9 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -45,7 +45,7 @@ ZLIB_VERSION=1.3.1 GMP_VERSION=6.3.0 NETTLE_VERSION=3.10.2 CURL_VERSION=8.15.0 -SDL3_VERSION=3.2.22 +SDL3_VERSION=3.4.10 GLEW_VERSION=2.2.0 PNG_VERSION=1.6.50 JPEG_VERSION=3.1.1 From d233051bde934935eecdbf7418dcc2c3e4f2c87f Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 26 Jun 2026 12:27:16 +0200 Subject: [PATCH 24/76] external_deps: upgrade zlib --- external_deps/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 5f11d7b8c9..233a7b5ca4 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -41,7 +41,7 @@ WASMTIME_BASEURL='https://github.com/bytecodealliance/wasmtime/releases' # Package versions PKGCONFIG_VERSION=0.29.2 NASM_VERSION=2.16.03 -ZLIB_VERSION=1.3.1 +ZLIB_VERSION=1.3.2 GMP_VERSION=6.3.0 NETTLE_VERSION=3.10.2 CURL_VERSION=8.15.0 From ccb02eeb9b82bf7e3b2d5d9eb6995fdd6c0d1f4b Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 26 Jun 2026 12:28:12 +0200 Subject: [PATCH 25/76] external_deps: upgrade nettle --- external_deps/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 233a7b5ca4..06027275d0 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -43,7 +43,7 @@ PKGCONFIG_VERSION=0.29.2 NASM_VERSION=2.16.03 ZLIB_VERSION=1.3.2 GMP_VERSION=6.3.0 -NETTLE_VERSION=3.10.2 +NETTLE_VERSION=4.0 CURL_VERSION=8.15.0 SDL3_VERSION=3.4.10 GLEW_VERSION=2.2.0 From 78496c79ddeeba8ac3dcdf718b9f137dfe8c2e0b Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 26 Jun 2026 12:29:11 +0200 Subject: [PATCH 26/76] external_deps: upgrade curl --- external_deps/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 06027275d0..035809894e 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -44,7 +44,7 @@ NASM_VERSION=2.16.03 ZLIB_VERSION=1.3.2 GMP_VERSION=6.3.0 NETTLE_VERSION=4.0 -CURL_VERSION=8.15.0 +CURL_VERSION=8.21.0 SDL3_VERSION=3.4.10 GLEW_VERSION=2.2.0 PNG_VERSION=1.6.50 From e88df7332ec52034f5a06de64e929fb4727dcac4 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 26 Jun 2026 12:29:40 +0200 Subject: [PATCH 27/76] external_deps: upgrade glew --- external_deps/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 035809894e..8461feea3b 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -46,7 +46,7 @@ GMP_VERSION=6.3.0 NETTLE_VERSION=4.0 CURL_VERSION=8.21.0 SDL3_VERSION=3.4.10 -GLEW_VERSION=2.2.0 +GLEW_VERSION=2.3.1 PNG_VERSION=1.6.50 JPEG_VERSION=3.1.1 # WebP 1.6.0 introduced AVX2 intrinsics that are not available on From 6a9ea020164be1e5fe23c9ec40073787c5187409 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 26 Jun 2026 12:30:32 +0200 Subject: [PATCH 28/76] external_deps: upgrade png --- external_deps/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 8461feea3b..7c83427200 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -47,7 +47,7 @@ NETTLE_VERSION=4.0 CURL_VERSION=8.21.0 SDL3_VERSION=3.4.10 GLEW_VERSION=2.3.1 -PNG_VERSION=1.6.50 +PNG_VERSION=1.6.58 JPEG_VERSION=3.1.1 # WebP 1.6.0 introduced AVX2 intrinsics that are not available on # the GCC 10 compiler provided by Debian Bullseye. From 87bded0901bcf4614eaac8d822f8bc6d1bb9c83f Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 26 Jun 2026 12:30:47 +0200 Subject: [PATCH 29/76] external_deps: upgrade jpeg --- external_deps/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 7c83427200..941d870b18 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -48,7 +48,7 @@ CURL_VERSION=8.21.0 SDL3_VERSION=3.4.10 GLEW_VERSION=2.3.1 PNG_VERSION=1.6.58 -JPEG_VERSION=3.1.1 +JPEG_VERSION=3.1.4.1 # WebP 1.6.0 introduced AVX2 intrinsics that are not available on # the GCC 10 compiler provided by Debian Bullseye. WEBP_VERSION=1.5.0 From 3916280fd7627cc2006736d66e75d24af0590edf Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 26 Jun 2026 12:31:37 +0200 Subject: [PATCH 30/76] external_deps: do not upgrade openal --- external_deps/build.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/external_deps/build.sh b/external_deps/build.sh index 941d870b18..942208f8fa 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -52,6 +52,8 @@ JPEG_VERSION=3.1.4.1 # WebP 1.6.0 introduced AVX2 intrinsics that are not available on # the GCC 10 compiler provided by Debian Bullseye. WEBP_VERSION=1.5.0 +# OpenAL 0.25.0 requires C++20 that is not available on +# the GCC 10 compiler provided by Debian Bullseye. OPENAL_VERSION=1.24.3 OGG_VERSION=1.3.6 VORBIS_VERSION=1.3.7 From 5d93670cd50eb35ac6d8a88e30bf0d4f0eb2e435 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 26 Jun 2026 12:32:27 +0200 Subject: [PATCH 31/76] external_deps: upgrade opus --- external_deps/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 942208f8fa..9e16fac9f9 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -57,7 +57,7 @@ WEBP_VERSION=1.5.0 OPENAL_VERSION=1.24.3 OGG_VERSION=1.3.6 VORBIS_VERSION=1.3.7 -OPUS_VERSION=1.5.2 +OPUS_VERSION=1.6.1 OPUSFILE_VERSION=0.12 NACLSDK_VERSION=44.0.2403.155 NACLRUNTIME_REVISION='70beec35eb5fa3ddd571f18f9ad57b5da674d85d' From 592c22672739ec9dd660df9e019a52a8059167ac Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 26 Jun 2026 16:10:18 +0200 Subject: [PATCH 32/76] external_deps: disable the GPU framework --- external_deps/build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 9e16fac9f9..ccb2f4d9ed 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -510,7 +510,8 @@ build_sdl3() { cmake_build \ -DSDL_TEST_LIBRARY=OFF \ - -DSDL_AUDIO=OFF + -DSDL_AUDIO=OFF \ + -DSDL_GPU=OFF ;; esac } From b78b2777001013a40f13f65c67a6995d6ca4ce03 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 27 Jun 2026 05:49:16 +0200 Subject: [PATCH 33/76] cmake: download macos-arm64 deps archive --- CMakeLists.txt | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b2a3ccf6f..bdbddee206 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -230,17 +230,7 @@ if (USE_EXTERNAL_DEPS AND NOT YOKAI_TARGET_SYSTEM_NACL) set(SUPPORTED_${DEPS_SYSTEM}_ARCH amd64 i686) elseif (YOKAI_TARGET_SYSTEM_MACOS) set(DEPS_SYSTEM macos) - set(SUPPORTED_${DEPS_SYSTEM}_ARCH amd64) - - if (YOKAI_TARGET_ARCH_ARM64) - set(DEPS_ARCH amd64) - - set_deps_dir() - - if (NOT EXISTS ${DEPS_DIR}) - set(DEFAULT_USE_EXTERNAL_DEPS_LIBS OFF) - endif() - endif() + set(SUPPORTED_${DEPS_SYSTEM}_ARCH amd64 arm64) elseif (YOKAI_TARGET_SYSTEM_LINUX) set(DEPS_SYSTEM linux) set(SUPPORTED_${DEPS_SYSTEM}_ARCH amd64 i686 arm64 armhf) From fb2620430cb3937cf9fc30df9eaae06ec8711805 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 3 Jul 2026 06:23:15 +0200 Subject: [PATCH 34/76] external_deps: box64 --- external_deps/build.sh | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index ccb2f4d9ed..af54ac1d28 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -31,6 +31,7 @@ OGG_BASEURL='https://downloads.xiph.org/releases/ogg' VORBIS_BASEURL='https://downloads.xiph.org/releases/vorbis' OPUS_BASEURL='https://downloads.xiph.org/releases/opus' OPUSFILE_BASEURL='https://downloads.xiph.org/releases/opus' +BOX64_BASEURL='https://api.github.com/repos/ptitSeb/box64/zipball' NACLSDK_BASEURL='https://dl.unvanquished.net/mirror/storage.googleapis.com/nativeclient-mirror/nacl/nacl_sdk' # No index. NACLRUNTIME_BASEURL='https://api.github.com/repos/DaemonEngine/native_client/zipball' @@ -59,6 +60,7 @@ OGG_VERSION=1.3.6 VORBIS_VERSION=1.3.7 OPUS_VERSION=1.6.1 OPUSFILE_VERSION=0.12 +BOX64_REVISION='b1d094f9bd37cd69865c56d72a94747b22c16dd6' NACLSDK_VERSION=44.0.2403.155 NACLRUNTIME_REVISION='70beec35eb5fa3ddd571f18f9ad57b5da674d85d' NCURSES_VERSION=6.5 @@ -660,7 +662,7 @@ build_jpeg() { jpeg_cmake_args+=(-DUNIX=True) ;; esac - + cd "${dir_name}" # -DHAVE_THREAD_LOCAL=0 overrides the compiler test to avoid the silly thread_local variable, @@ -930,6 +932,23 @@ build_ncurses() { --with-default-terminfo-dir=/usr/share/terminfo } +# Build box64 +build_box64() { + local dir_name="ptitSeb-box64-${BOX64_REVISION:0:7}" + local archive_name="box64-${BOX64_REVISION}.zip" + + download_extract box64 "${archive_name}" \ + "${BOX64_BASEURL}/${BOX64_REVISION}" + + "${download_only}" && return + + cd "${dir_name}" + + cmake_build + + smart_copy 'build/box64' "${PREFIX}/box64" +} + # "Builds" (downloads) the WASI SDK build_wasisdk() { case "${PLATFORM}" in @@ -1687,7 +1706,7 @@ printHelp() { all linux windows macos Packages: - native-pkgconfig native-nasm zlib gmp nettle curl sdl3 glew png jpeg webp openal ogg vorbis opus opusfile naclsdk naclruntime wasisdk wasmtime + native-pkgconfig native-nasm zlib gmp nettle curl sdl3 glew png jpeg webp openal ogg vorbis opus opusfile naclsdk naclruntime wasisdk wasmtime box64 Virtual packages: base build packages for pre-built binaries to be downloaded when building the game @@ -1726,7 +1745,7 @@ printHelp() { all ${all_linux_amd64_default_packages} EOF - + exit } From 24c6073f1dba8174f1fd88cb8a0d44b78c0a4791 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 3 Jul 2026 07:16:22 +0200 Subject: [PATCH 35/76] external_deps: amd64 nacl_loader on arm64 --- external_deps/build.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index af54ac1d28..0a1fb3c84f 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -1087,15 +1087,25 @@ build_naclsdk() { rm -rf "${PREFIX}/pnacl/x86_64-nacl" rm -rf "${PREFIX}/pnacl/x86_64_bc-nacl" esac + case "${PLATFORM}" in - windows-i686-*) + windows-i686-*|linux-arm64-*) smart_copy pepper_*"/tools/irt_core_x86_64.nexe" "${PREFIX}/irt_core-amd64.nexe" ;; + esac + + case "${PLATFORM}" in linux-*-*) # Fix permissions on a few files which deny access to non-owner chmod 644 "${PREFIX}/irt_core-${DAEMON_ARCH}.nexe" ;; esac + + case "${PLATFORM}" in + linux-arm64-*) + chmod 644 "${PREFIX}/irt_core-amd64.nexe" + ;; + esac } # Only builds nacl_loader and nacl_helper_bootstrap for now, not IRT. @@ -1118,6 +1128,7 @@ build_naclruntime() { ;; linux-arm64-*) nacl_arch_list+=('armhf') + nacl_arch_list+=('amd64') ;; linux-armhf-*) nacl_arch_list+=('armhf') From 693e75b70b8c9bf941cf09e0cbc21fc8e52252b2 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 3 Jul 2026 14:42:50 +0200 Subject: [PATCH 36/76] external_deps: box64 install for arm64 --- external_deps/build.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 0a1fb3c84f..aa3abcf667 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -947,6 +947,11 @@ build_box64() { cmake_build smart_copy 'build/box64' "${PREFIX}/box64" + + mkdir -p "${PREFIX}/libs-linux-amd64" + smart_copy -L \ + '/usr/lib/x86_64-linux-gnu/libgcc_s.so.1' \ + "${PREFIX}/libs-linux-amd64/" } # "Builds" (downloads) the WASI SDK @@ -1685,12 +1690,12 @@ all_linux_amd64_default_packages='zlib gmp nettle curl sdl3 glew png jpeg webp o base_linux_i686_default_packages="${base_linux_amd64_default_packages}" all_linux_i686_default_packages="${all_linux_amd64_default_packages}" -base_linux_arm64_default_packages="${base_linux_amd64_default_packages}" -all_linux_arm64_default_packages="${all_linux_amd64_default_packages}" - base_linux_armhf_default_packages="${base_linux_amd64_default_packages}" all_linux_armhf_default_packages="${all_linux_amd64_default_packages}" +base_linux_arm64_default_packages="${base_linux_amd64_default_packages} box64" +all_linux_arm64_default_packages="${all_linux_amd64_default_packages} box64" + all_linux_platforms='linux-amd64-default linux-arm64-default linux-armhf-default linux-i686-default' all_windows_platforms='windows-amd64-mingw windows-amd64-msvc windows-i686-mingw windows-i686-msvc' all_macos_platforms='macos-amd64-default macos-arm64-default' @@ -1750,11 +1755,14 @@ printHelp() { linux-amd64-default: linux-i686-default: - linux-arm64-default: linux-armhf-default: base ${base_linux_amd64_default_packages} all ${all_linux_amd64_default_packages} + linux-arm64-default: + base ${base_linux_arm64_default_packages} + all ${all_linux_arm64_default_packages} + EOF exit From c885ee10a97446b0ae9490613b40a8915c242e4a Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 3 Jul 2026 13:06:27 +0200 Subject: [PATCH 37/76] cmake: enable box64 on arm64 --- cmake/DaemonNaclArchitecture.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/DaemonNaclArchitecture.cmake b/cmake/DaemonNaclArchitecture.cmake index 1c6726d9ba..506621300e 100644 --- a/cmake/DaemonNaclArchitecture.cmake +++ b/cmake/DaemonNaclArchitecture.cmake @@ -51,7 +51,7 @@ function(daemon_detect_nacl_arch target_arch) endif() set(armhf_usage "arm64" "armel") - set(box64_usage "ppc64el" "riscv64" "loong64") + set(box64_usage "arm64" "ppc64el" "riscv64" "loong64") if ("${target_arch}" IN_LIST armhf_usage) # Load 32-bit armhf nexe on 64-bit arm64 engine on Linux with multiarch. From 821fc0f6271fcb6e859d7c383b3c8c5fd7d39f7b Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 3 Jul 2026 14:22:20 +0200 Subject: [PATCH 38/76] cmake: copy box64 --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index bdbddee206..d6c4ae86f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1002,6 +1002,14 @@ if (DEPS_DIR AND HAS_NACL AND (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER ) endif() endforeach() + + if (DAEMON_NACL_BOX64_EMULATION) + add_custom_command(TARGET runtime_deps PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${DEPS_DIR}/box64 + ${FULL_OUTPUT_DIR}/box64 + ) + endif() endif() # Mac requires some libraries from external_deps From 8dd7d65a08b63bae5a05afc427866f100934ba30 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 26 Sep 2025 01:25:59 +0200 Subject: [PATCH 39/76] external_deps: let jpeg build for unknown platforms --- external_deps/build.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index aa3abcf667..393b77799f 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -626,29 +626,36 @@ build_jpeg() { ;; esac - local jpeg_cmake_args=(-DREQUIRE_SIMD=ON) + local jpeg_cmake_args=() + + local SYSTEM_PROCESSOR='unknown' + local jpeg_require_simd='OFF' case "${PLATFORM}" in *-amd64-*) - local SYSTEM_PROCESSOR='x86_64' + SYSTEM_PROCESSOR='x86_64' + jpeg_require_simd='ON' # Ensure NASM is available nasm --help >/dev/null ;; *-i686-*) - local SYSTEM_PROCESSOR='i386' + SYSTEM_PROCESSOR='i386' + jpeg_require_simd='ON' # Ensure NASM is available nasm --help >/dev/null ;; *-arm64-*) - local SYSTEM_PROCESSOR='aarch64' + SYSTEM_PROCESSOR='aarch64' + jpeg_require_simd='ON' jpeg_cmake_args+=(-DNEON_INTRINSICS=ON) ;; *-armhf-*) - local SYSTEM_PROCESSOR='arm' + SYSTEM_PROCESSOR='arm' + jpeg_require_simd='ON' jpeg_cmake_args+=(-DNEON_INTRINSICS=ON) ;; *) - log ERROR 'Unsupported platform for JPEG' + log WARNING 'Unknown platform for JPEG' ;; esac @@ -673,6 +680,7 @@ build_jpeg() { -DENABLE_STATIC="${LIBS_STATIC}" \ -DCMAKE_SYSTEM_NAME="${SYSTEM_NAME}" \ -DCMAKE_SYSTEM_PROCESSOR="${SYSTEM_PROCESSOR}" \ + -DREQUIRE_SIMD=${jpeg_require_simd} \ -DWITH_JPEG8=1 \ -DWITH_TURBOJPEG=0 \ "${jpeg_cmake_args[@]}" From b98ab6a200ea53e2393f2756c226beb532d5c9f9 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 4 Jul 2026 04:42:31 +0200 Subject: [PATCH 40/76] jpeg: default on PLATFORM_ARCH --- external_deps/build.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 393b77799f..d136358cc1 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -628,7 +628,12 @@ build_jpeg() { local jpeg_cmake_args=() - local SYSTEM_PROCESSOR='unknown' + # When there is no platform code implemented in libjpeg yet, + # we can build it without SIMD code. + # This string will then only be used for warnings like that: + # > SIMD extensions not available for this CPU (riscv64). Performance will suffer. + local SYSTEM_PROCESSOR="${PLATFORM_ARCH}" + local jpeg_require_simd='OFF' case "${PLATFORM}" in @@ -654,9 +659,6 @@ build_jpeg() { jpeg_require_simd='ON' jpeg_cmake_args+=(-DNEON_INTRINSICS=ON) ;; - *) - log WARNING 'Unknown platform for JPEG' - ;; esac case "${PLATFORM}" in From a880897f08aa925255ab20c70a873868d80f2f63 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 4 Jul 2026 03:58:05 +0200 Subject: [PATCH 41/76] external_deps: add linux-armel platform --- external_deps/build.sh | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index d136358cc1..c351b44b5b 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -659,6 +659,11 @@ build_jpeg() { jpeg_require_simd='ON' jpeg_cmake_args+=(-DNEON_INTRINSICS=ON) ;; + *-armel-*) + SYSTEM_PROCESSOR='arm' + jpeg_require_simd='OFF' + jpeg_cmake_args+=(-DNEON_INTRINSICS=OFF) + ;; esac case "${PLATFORM}" in @@ -769,6 +774,9 @@ build_openal() { *-armhf-*|*-arm64-*) openal_cmake_args+=(-DALSOFT_CPUEXT_NEON=ON -DALSOFT_REQUIRE_NEON=ON) ;; + *-armel-*) + openal_cmake_args+=(-DALSOFT_CPUEXT_NEON=ON -DALSOFT_REQUIRE_NEON=OFF) + ;; esac case "${PLATFORM}" in @@ -889,6 +897,9 @@ build_opus() { *-armhf-*|*-arm64-*) opus_cmake_args+=(-DOPUS_MAY_HAVE_NEON=OFF -DOPUS_PRESUME_NEON=ON) ;; + *-armel-*) + opus_cmake_args+=(-DOPUS_MAY_HAVE_NEON=ON -DOPUS_PRESUME_NEON=OFF) + ;; esac cd "${dir_name}" @@ -1065,7 +1076,7 @@ build_naclsdk() { local NACLSDK_ARCH=x86_64 local DAEMON_ARCH=amd64 ;; - linux-armhf-*|linux-arm64-*) + linux-armhf-*|linux-armel-*|linux-arm64-*) local NACLSDK_ARCH=arm local DAEMON_ARCH=armhf ;; @@ -1148,6 +1159,9 @@ build_naclruntime() { linux-armhf-*) nacl_arch_list+=('armhf') ;; + linux-armel-*) + nacl_arch_list+=('armhf') + ;; macos-amd64-*) nacl_arch_list+=('amd64') ;; @@ -1479,6 +1493,10 @@ common_setup_arch() { CFLAGS+=' -march=armv7-a -mfpu=neon' CXXFLAGS+=' -march=armv7-a -mfpu=neon' ;; + *-armel-*) + CFLAGS+=' -mfpu=vfp -mfloat-abi=softfp' + CXXFLAGS+=' -mfpu=vfp -mfloat-abi=softfp' + ;; *-native-*) ;; *) @@ -1643,6 +1661,12 @@ setup_linux-amd64-default() { common_setup linux x86_64-unknown-linux-gnu } +# Set up environment for 32-bit little-endian hard-float arm Linux +setup_linux-armel-default() { + setup_default + common_setup linux arm-unknown-linux-gnueabi +} + # Set up environment for 32-bit little-endian hard-float arm Linux setup_linux-armhf-default() { setup_default @@ -1703,6 +1727,9 @@ all_linux_i686_default_packages="${all_linux_amd64_default_packages}" base_linux_armhf_default_packages="${base_linux_amd64_default_packages}" all_linux_armhf_default_packages="${all_linux_amd64_default_packages}" +base_linux_armel_default_packages="${base_linux_armhf_default_packages}" +all_linux_armel_default_packages="${all_linux_armhf_default_packages}" + base_linux_arm64_default_packages="${base_linux_amd64_default_packages} box64" all_linux_arm64_default_packages="${all_linux_amd64_default_packages} box64" @@ -1766,6 +1793,7 @@ printHelp() { linux-amd64-default: linux-i686-default: linux-armhf-default: + linux-armel-default: base ${base_linux_amd64_default_packages} all ${all_linux_amd64_default_packages} From c0b5ff060ec82169dd561d93a27d4ec9f88b148f Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 26 Sep 2025 01:25:59 +0200 Subject: [PATCH 42/76] external_deps: add linux-riscv64 platform --- external_deps/build.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index c351b44b5b..44ddc84cb0 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -1072,7 +1072,7 @@ build_naclsdk() { local NACLSDK_ARCH=x86_32 local DAEMON_ARCH=i686 ;; - *-amd64-*|macos-arm64-*) + *-amd64-*|macos-arm64-*|linux-riscv64-*) local NACLSDK_ARCH=x86_64 local DAEMON_ARCH=amd64 ;; @@ -1162,6 +1162,9 @@ build_naclruntime() { linux-armel-*) nacl_arch_list+=('armhf') ;; + linux-riscv64-*) + nacl_arch_list+=('amd64') + ;; macos-amd64-*) nacl_arch_list+=('amd64') ;; @@ -1497,6 +1500,8 @@ common_setup_arch() { CFLAGS+=' -mfpu=vfp -mfloat-abi=softfp' CXXFLAGS+=' -mfpu=vfp -mfloat-abi=softfp' ;; + *-riscv64-*) + ;; *-native-*) ;; *) @@ -1679,6 +1684,12 @@ setup_linux-arm64-default() { common_setup linux aarch64-unknown-linux-gnu } +# Set up environment for 64-bit little-endian riscv Linux +setup_linux-riscv64-default() { + setup_default + common_setup linux riscv64-unknown-linux-gnu +} + # Set up environment for native host tools setup_native() { setup_default @@ -1733,6 +1744,9 @@ all_linux_armel_default_packages="${all_linux_armhf_default_packages}" base_linux_arm64_default_packages="${base_linux_amd64_default_packages} box64" all_linux_arm64_default_packages="${all_linux_amd64_default_packages} box64" +base_linux_riscv64_default_packages="${base_linux_arm64_default_packages}" +all_linux_riscv64_default_packages="${all_linux_arm64_default_packages}" + all_linux_platforms='linux-amd64-default linux-arm64-default linux-armhf-default linux-i686-default' all_windows_platforms='windows-amd64-mingw windows-amd64-msvc windows-i686-mingw windows-i686-msvc' all_macos_platforms='macos-amd64-default macos-arm64-default' @@ -1798,6 +1812,7 @@ printHelp() { all ${all_linux_amd64_default_packages} linux-arm64-default: + linux-riscv64-default: base ${base_linux_arm64_default_packages} all ${all_linux_arm64_default_packages} From 4e4cb874cf47fb1af7f03f489e2c596fa83f0650 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 4 Jul 2026 04:06:34 +0200 Subject: [PATCH 43/76] external_deps: add linux-ppc64el platform --- external_deps/build.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 44ddc84cb0..89d38a0015 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -1072,7 +1072,7 @@ build_naclsdk() { local NACLSDK_ARCH=x86_32 local DAEMON_ARCH=i686 ;; - *-amd64-*|macos-arm64-*|linux-riscv64-*) + *-amd64-*|macos-arm64-*|linux-riscv64-*|linux-ppc64el-*) local NACLSDK_ARCH=x86_64 local DAEMON_ARCH=amd64 ;; @@ -1165,6 +1165,9 @@ build_naclruntime() { linux-riscv64-*) nacl_arch_list+=('amd64') ;; + linux-ppc64el-*) + nacl_arch_list+=('amd64') + ;; macos-amd64-*) nacl_arch_list+=('amd64') ;; @@ -1502,6 +1505,8 @@ common_setup_arch() { ;; *-riscv64-*) ;; + *-ppc64el-*) + ;; *-native-*) ;; *) @@ -1690,6 +1695,12 @@ setup_linux-riscv64-default() { common_setup linux riscv64-unknown-linux-gnu } +# Set up environment for 64-bit little-endian ppc Linux +setup_linux-ppc64el-default() { + setup_default + common_setup linux powerpc64le-unknown-linux-gnu +} + # Set up environment for native host tools setup_native() { setup_default @@ -1747,6 +1758,9 @@ all_linux_arm64_default_packages="${all_linux_amd64_default_packages} box64" base_linux_riscv64_default_packages="${base_linux_arm64_default_packages}" all_linux_riscv64_default_packages="${all_linux_arm64_default_packages}" +base_linux_ppc64el_default_packages="${base_linux_arm64_default_packages}" +all_linux_ppc64el_default_packages="${all_linux_arm64_default_packages}" + all_linux_platforms='linux-amd64-default linux-arm64-default linux-armhf-default linux-i686-default' all_windows_platforms='windows-amd64-mingw windows-amd64-msvc windows-i686-mingw windows-i686-msvc' all_macos_platforms='macos-amd64-default macos-arm64-default' @@ -1813,6 +1827,7 @@ printHelp() { linux-arm64-default: linux-riscv64-default: + linux-ppc64el-default: base ${base_linux_arm64_default_packages} all ${all_linux_arm64_default_packages} From 13b9b020e5872aca932d323738bafaab69953753 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 4 Jul 2026 04:34:43 +0200 Subject: [PATCH 44/76] external_deps: add linux-loong64 architecture --- external_deps/build.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 89d38a0015..667cc45835 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -1072,7 +1072,7 @@ build_naclsdk() { local NACLSDK_ARCH=x86_32 local DAEMON_ARCH=i686 ;; - *-amd64-*|macos-arm64-*|linux-riscv64-*|linux-ppc64el-*) + *-amd64-*|macos-arm64-*|linux-riscv64-*|linux-ppc64el-*|linux-loong64-*) local NACLSDK_ARCH=x86_64 local DAEMON_ARCH=amd64 ;; @@ -1168,6 +1168,9 @@ build_naclruntime() { linux-ppc64el-*) nacl_arch_list+=('amd64') ;; + linux-loong64-*) + nacl_arch_list+=('amd64') + ;; macos-amd64-*) nacl_arch_list+=('amd64') ;; @@ -1507,6 +1510,8 @@ common_setup_arch() { ;; *-ppc64el-*) ;; + *-loong64-*) + ;; *-native-*) ;; *) @@ -1701,6 +1706,12 @@ setup_linux-ppc64el-default() { common_setup linux powerpc64le-unknown-linux-gnu } +# Set up environment for 64-bit loongarch Linux +setup_linux-loong64-default() { + setup_default + common_setup linux loongarch64-linux-gnu +} + # Set up environment for native host tools setup_native() { setup_default @@ -1761,6 +1772,9 @@ all_linux_riscv64_default_packages="${all_linux_arm64_default_packages}" base_linux_ppc64el_default_packages="${base_linux_arm64_default_packages}" all_linux_ppc64el_default_packages="${all_linux_arm64_default_packages}" +base_linux_loong64_default_packages="${base_linux_arm64_default_packages}" +all_linux_loong64_default_packages="${all_linux_arm64_default_packages}" + all_linux_platforms='linux-amd64-default linux-arm64-default linux-armhf-default linux-i686-default' all_windows_platforms='windows-amd64-mingw windows-amd64-msvc windows-i686-mingw windows-i686-msvc' all_macos_platforms='macos-amd64-default macos-arm64-default' @@ -1828,6 +1842,7 @@ printHelp() { linux-arm64-default: linux-riscv64-default: linux-ppc64el-default: + linux-loong64-default: base ${base_linux_arm64_default_packages} all ${all_linux_arm64_default_packages} From 6adbac1a1b1450b941ff1bf679e9deca13f88574 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 26 Sep 2025 01:25:59 +0200 Subject: [PATCH 45/76] external_deps: distinguish between supported and extra deps packages --- external_deps/build.sh | 48 +++++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 667cc45835..1c33e3fa9a 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -1775,9 +1775,18 @@ all_linux_ppc64el_default_packages="${all_linux_arm64_default_packages}" base_linux_loong64_default_packages="${base_linux_arm64_default_packages}" all_linux_loong64_default_packages="${all_linux_arm64_default_packages}" -all_linux_platforms='linux-amd64-default linux-arm64-default linux-armhf-default linux-i686-default' -all_windows_platforms='windows-amd64-mingw windows-amd64-msvc windows-i686-mingw windows-i686-msvc' -all_macos_platforms='macos-amd64-default macos-arm64-default' +supported_linux_platforms='linux-amd64-default linux-arm64-default linux-armhf-default linux-i686-default' +supported_windows_platforms='windows-amd64-mingw windows-amd64-msvc windows-i686-mingw windows-i686-msvc' +supported_macos_platforms='macos-amd64-default macos-arm64-default' + +extra_linux_platforms='linux-armel-default linux-riscv64-default linux-ppc64el-default linux-loong64-default' + +supported_platforms="${supported_linux_platforms} ${supported_windows_platforms} ${supported_macos_platforms}" + +all_linux_platforms="${supported_linux_platforms} ${extra_linux_platforms}" +all_windows_platforms="${supported_windows_platforms}" +all_macos_platforms="${supported_macos_platforms}" + all_platforms="${all_linux_platforms} ${all_windows_platforms} ${all_macos_platforms}" printHelp() { @@ -1795,10 +1804,14 @@ printHelp() { ${all_platforms} Virtual platforms: - linux ${all_linux_platforms} - windows ${all_windows_platforms} - macos ${all_macos_platforms} - all linux windows macos + supported-linux ${supported_linux_platforms} + supported-windows ${supported_windows_platforms} + supported-macos ${supported_macos_platforms} + supported supported-linux supported-windows supported-macos + extra-linux ${extra_linux_platforms} + extra extra-linux + all-linux linux extra-linux + all supported extra Packages: native-pkgconfig native-nasm zlib gmp nettle curl sdl3 glew png jpeg webp openal ogg vorbis opus opusfile naclsdk naclruntime wasisdk wasmtime box64 @@ -1913,15 +1926,30 @@ case "${platform}" in all) platform_list="${all_platforms}" ;; -linux) +supported) + platform_list="${supported_platforms}" + ;; +all-linux) platform_list="${all_linux_platforms}" ;; -windows) +supported-linux) + platform_list="${supported_linux_platforms}" + ;; +extra-linux) + platform_list="${extra_linux_platforms}" + ;; +all-windows) platform_list="${all_windows_platforms}" ;; -macos) +supported-windows) + platform_list="${supported_windows_platforms}" + ;; +all-macos) platform_list="${all_macos_platforms}" ;; +supported-macos) + platform_list="${supported_macos_platforms}" + ;; *) for known_platform in ${all_platforms} do From e9f98d692ff5987d1f6f02092b04682953fe0c84 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 26 Sep 2025 20:39:36 +0200 Subject: [PATCH 46/76] external_deps: use gmake instead of make on FreeBSD --- external_deps/build.sh | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 1c33e3fa9a..404d0e3dfb 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -67,6 +67,16 @@ NCURSES_VERSION=6.5 WASISDK_VERSION=16.0 WASMTIME_VERSION=2.0.2 +case "$(uname -s)" in + 'FreeBSD') + # The builtin make isn't compatible enough. + MAKE='gmake' + ;; + *) + MAKE='make' + ;; +esac + log() { level="${1}"; shift printf '%s: %s\n' "${level}" "${@}" >&2 @@ -201,8 +211,8 @@ configure_build() { ./configure \ "${configure_args[@]}" - make - make install + "${MAKE}" + "${MAKE}" install } get_compiler_name() { @@ -286,8 +296,8 @@ build_native-pkgconfig() { ( setup_platform 'native' - CFLAGS='-Wno-error=int-conversion' \ - configure_build \ + CFLAGS='-Wno-error=int-conversion' \ + configure_build \ --with-internal-glib ) } @@ -331,8 +341,8 @@ build_zlib() { case "${PLATFORM}" in windows-*-*) - LOC="${CFLAGS}" make -f win32/Makefile.gcc PREFIX="${HOST}-" - make -f win32/Makefile.gcc install BINARY_PATH="${PREFIX}/bin" LIBRARY_PATH="${PREFIX}/lib" INCLUDE_PATH="${PREFIX}/include" SHARED_MODE=1 + LOC="${CFLAGS}" "${MAKE}" -f win32/Makefile.gcc PREFIX="${HOST}-" + "${MAKE}" -f win32/Makefile.gcc install BINARY_PATH="${PREFIX}/bin" LIBRARY_PATH="${PREFIX}/lib" INCLUDE_PATH="${PREFIX}/include" SHARED_MODE=1 ;; *) CFLAGS="${CFLAGS} -DZLIB_CONST" \ @@ -560,12 +570,12 @@ build_glew() { # manually re-add the required flags there. case "${PLATFORM}" in macos-*-*) - make "${glew_env[@]}" "${glew_options[@]}" - make install "${glew_env[@]}" "${glew_options[@]}" + "${MAKE}" "${glew_env[@]}" "${glew_options[@]}" + "${MAKE}" install "${glew_env[@]}" "${glew_options[@]}" ;; *) - env "${glew_env[@]}" make "${glew_options[@]}" - env "${glew_env[@]}" make install "${glew_options[@]}" + env "${glew_env[@]}" "${MAKE}" "${glew_options[@]}" + env "${glew_env[@]}" "${MAKE}" install "${glew_options[@]}" ;; esac From 5d286b070bfa8123adf3e2c8c047f9365b7e4b76 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 26 Sep 2025 23:53:28 +0200 Subject: [PATCH 47/76] external_deps: workaround a GLEW build error on FreeBSD --- external_deps/build.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/external_deps/build.sh b/external_deps/build.sh index 404d0e3dfb..35e75bac20 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -557,6 +557,11 @@ build_glew() { glew_env+=(CFLAGS.EXTRA="${CFLAGS}") glew_options+=(LIBDIR="${PREFIX}/lib" LD="${CC}") ;; + freebsd-*-*) + glew_env+=(CFLAGS.EXTRA="${CFLAGS}") + sed -e 's/ -soname / -Wl,-soname=/' config/Makefile.freebsd > config/Makefile.freebsd-fix + glew_options+=(SYSTEM=freebsd-fix LD="${CC}") + ;; *) log ERROR 'Unsupported platform for GLEW' ;; From 0350e6073969b0bdd39d81b5c7fb35a4be6ed94b Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 4 Jul 2026 07:31:52 +0200 Subject: [PATCH 48/76] external_deps: add freebsd-amd64 and freebsd-i686 platforms --- external_deps/build.sh | 51 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 35e75bac20..ed7128687b 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -633,6 +633,9 @@ build_jpeg() { linux-*-*) local SYSTEM_NAME='Linux' ;; + freebsd-*-*) + local SYSTEM_NAME='FreeBSD' + ;; *) # Other platforms can build but we need to explicitly # set CMAKE_SYSTEM_NAME for CMAKE_CROSSCOMPILING to be set @@ -1076,7 +1079,7 @@ build_naclsdk() { local NACLSDK_PLATFORM=mac local TAR_EXT=tar ;; - linux-*-*) + linux-*-*|freebsd-*-*) local NACLSDK_PLATFORM=linux local TAR_EXT=tar ;; @@ -1136,7 +1139,7 @@ build_naclsdk() { esac case "${PLATFORM}" in - linux-*-*) + linux-*-*|freebsd-*-*) # Fix permissions on a few files which deny access to non-owner chmod 644 "${PREFIX}/irt_core-${DAEMON_ARCH}.nexe" ;; @@ -1373,7 +1376,7 @@ build_install() { # Fix import lib paths to use MSVC-style instead of MinGW ones (see 'genlib' target) find "${PKG_PREFIX}/lib/cmake" -name '*.cmake' -execdir sed -i -E 's@[.]dll[.]a\b@.lib@g' {} \; ;; - linux-*-*) + linux-*-*|freebsd-*-*) find "${PKG_PREFIX}/lib" -name '*.so' -execdir rm -f -- {} \; find "${PKG_PREFIX}/lib" -name '*.so.*' -execdir rm -f -- {} \; find "${PKG_PREFIX}/lib" -name '*_g.a' -execdir rm -f -- {} \; @@ -1586,6 +1589,15 @@ common_setup_linux() { CXXFLAGS+=' -fPIC' } +common_setup_freebsd() { + CC='clang' + CXX='clang++' + STRIP='strip' + CFLAGS+=" -target ${HOST}" + CXXFLAGS+=" -target ${HOST}" + LDFLAGS+=" -target ${HOST}" +} + common_setup_native() { case "$(uname -s)" in CYGWIN_NT-*|MSYS_NT-*|MINGW*_NT-*) @@ -1727,6 +1739,18 @@ setup_linux-loong64-default() { common_setup linux loongarch64-linux-gnu } +# Set up environment for 32-bit i686 FreeBSD +setup_freebsd-i686-default() { + setup_default + common_setup freebsd i386-unknown-freebsd +} + +# Set up environment for 64-bit amd64 FreeBSD +setup_freebsd-amd64-default() { + setup_default + common_setup freebsd x86_64-unknown-freebsd +} + # Set up environment for native host tools setup_native() { setup_default @@ -1790,11 +1814,19 @@ all_linux_ppc64el_default_packages="${all_linux_arm64_default_packages}" base_linux_loong64_default_packages="${base_linux_arm64_default_packages}" all_linux_loong64_default_packages="${all_linux_arm64_default_packages}" +# FIXME: The naclruntime will fail to build, we need to download a prebuilt one. +base_freebsd_amd64_default_packages='sdl3 naclsdk saigosdk' +all_freebsd_amd64_default_packages='gmp nettle sdl3 glew png jpeg webp openal ogg vorbis opus opusfile naclsdk saigosdk' + +base_freebsd_i686_default_packages="${base_freebsd_amd64_default_packages}" +all_freebsd_i686_default_packages="${all_freebsd_amd64_default_packages}" + supported_linux_platforms='linux-amd64-default linux-arm64-default linux-armhf-default linux-i686-default' supported_windows_platforms='windows-amd64-mingw windows-amd64-msvc windows-i686-mingw windows-i686-msvc' supported_macos_platforms='macos-amd64-default macos-arm64-default' extra_linux_platforms='linux-armel-default linux-riscv64-default linux-ppc64el-default linux-loong64-default' +extra_freebsd_platforms='freebsd-amd64-default freebsd-i686-default' supported_platforms="${supported_linux_platforms} ${supported_windows_platforms} ${supported_macos_platforms}" @@ -1802,7 +1834,7 @@ all_linux_platforms="${supported_linux_platforms} ${extra_linux_platforms}" all_windows_platforms="${supported_windows_platforms}" all_macos_platforms="${supported_macos_platforms}" -all_platforms="${all_linux_platforms} ${all_windows_platforms} ${all_macos_platforms}" +all_platforms="${all_linux_platforms} ${all_windows_platforms} ${all_macos_platforms} ${extra_freebsd_platforms}" printHelp() { # Please align to 4-space tabs. @@ -1824,7 +1856,8 @@ printHelp() { supported-macos ${supported_macos_platforms} supported supported-linux supported-windows supported-macos extra-linux ${extra_linux_platforms} - extra extra-linux + extra-freebsd ${extra_freebsd_platforms} + extra extra-linux extra-freebsd all-linux linux extra-linux all supported extra @@ -1874,6 +1907,11 @@ printHelp() { base ${base_linux_arm64_default_packages} all ${all_linux_arm64_default_packages} + freebsd-amd64-default: + freebsd-i686-default: + base ${base_freebsd_amd64_default_packages} + all ${all_freebsd_amd64_default_packages} + EOF exit @@ -1953,6 +1991,9 @@ supported-linux) extra-linux) platform_list="${extra_linux_platforms}" ;; +extra-freebsd) + platform_list="${extra_freebsd_platforms}" + ;; all-windows) platform_list="${all_windows_platforms}" ;; From 829a19bbdcaf737a72532ce2d711db31bf6ed72c Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 26 Jun 2026 06:45:18 +0200 Subject: [PATCH 49/76] cmake: use Saigo by default to compile NaCl binaries --- cmake/DaemonGame.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/DaemonGame.cmake b/cmake/DaemonGame.cmake index b4c449fd8f..1fbaf66946 100644 --- a/cmake/DaemonGame.cmake +++ b/cmake/DaemonGame.cmake @@ -71,7 +71,7 @@ include(CMakeParseArguments) list(APPEND NACL_ALL_TARGETS "amd64" "i686" "armhf") if (NOT GAME_BUILD_SUBINVOCATION) - option(USE_NACL_SAIGO "Use the Saigo toolchain to build NaCl executables" OFF) + option(USE_NACL_SAIGO "Use the Saigo toolchain to build NaCl executables" ON) if (USE_NACL_SAIGO) set(HAS_NACL_SDK ON) From 2a2000d93ee80d835e45e31af6fa1c57958402cd Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Tue, 7 Jul 2026 09:41:54 +0200 Subject: [PATCH 50/76] external_deps: set MinGW flags as flags --- external_deps/build.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index ed7128687b..af89bd6b2e 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -250,10 +250,8 @@ cmake_build() { ;; esac - cmake_args+=(-DCMAKE_C_COMPILER="$(get_compiler_name ${CC})") - cmake_args+=(-DCMAKE_CXX_COMPILER="$(get_compiler_name ${CXX})") - cmake_args+=(-DCMAKE_C_COMPILER_ARG1="$(get_compiler_arg1 ${CC})") - cmake_args+=(-DCMAKE_CXX_COMPILER_ARG1="$(get_compiler_arg1 ${CXX})") + cmake_args+=(-DCMAKE_C_COMPILER="${CC}") + cmake_args+=(-DCMAKE_CXX_COMPILER="${CXX}") cmake_args+=(-DCMAKE_C_FLAGS="${CFLAGS}") cmake_args+=(-DCMAKE_CXX_FLAGS="${CXXFLAGS}") cmake_args+=(-DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}") @@ -1559,9 +1557,11 @@ common_setup_windows() { common_setup_msvc() { LIBS_SHARED='ON' LIBS_STATIC='OFF' + CC="${HOST}-gcc" + CXX="${HOST}-g++" # Libtool bug prevents -static-libgcc from being set in LDFLAGS - CC="${HOST}-gcc -static-libgcc" - CXX="${HOST}-g++ -static-libgcc" + CFLAGS+=' -static-libgcc' + CXXFLAGS+=' -static-libgcc' common_setup_windows } From 7bc8c25ddae1631c4b74a87edb6beb37af79a488 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Tue, 7 Jul 2026 09:49:40 +0200 Subject: [PATCH 51/76] external_deps: use ccache when available --- external_deps/build.sh | 57 +++++++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 15 deletions(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index af89bd6b2e..1c0c4c089b 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -250,8 +250,14 @@ cmake_build() { ;; esac - cmake_args+=(-DCMAKE_C_COMPILER="${CC}") - cmake_args+=(-DCMAKE_CXX_COMPILER="${CXX}") + if [ -n "${COMPILER_LAUNCHER}" ] + then + cmake_args+=(-DCMAKE_C_COMPILER_LAUNCHER="${COMPILER_LAUNCHER}") + cmake_args+=(-DCMAKE_CXX_COMPILER_LAUNCHER="${COMPILER_LAUNCHER}") + fi + + cmake_args+=(-DCMAKE_C_COMPILER="${C_COMPILER}") + cmake_args+=(-DCMAKE_CXX_COMPILER="${CXX_COMPILER}") cmake_args+=(-DCMAKE_C_FLAGS="${CFLAGS}") cmake_args+=(-DCMAKE_CXX_FLAGS="${CXXFLAGS}") cmake_args+=(-DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}") @@ -1494,9 +1500,25 @@ common_setup() { CPPFLAGS+=" -I${PREFIX}/include" LDFLAGS+=" -L${PREFIX}/lib" + if command -v ccmake >/dev/null 2>&1 + then + export COMPILER_LAUNCHER='ccache' + export CCACHE_CPP2='true' + export CCACHE_HASHDIR='true' + fi + + if [ -n "${COMPILER_LAUNCHER}" ] + then + export CC="${COMPILER_LAUNCHER} ${C_COMPILER}" + export CXX="${COMPILER_LAUNCHER} ${CXX_COMPILER}" + else + export CC="${C_COMPILER}" + export CXX="${CXX_COMPILER}" + fi + export PATH export PKG_CONFIG PKG_CONFIG_PATH - export CC CXX LD AR RANLIB STRIP + export LD AR RANLIB STRIP export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS } @@ -1557,8 +1579,8 @@ common_setup_windows() { common_setup_msvc() { LIBS_SHARED='ON' LIBS_STATIC='OFF' - CC="${HOST}-gcc" - CXX="${HOST}-g++" + C_COMPILER="${HOST}-gcc" + CXX_COMPILER="${HOST}-g++" # Libtool bug prevents -static-libgcc from being set in LDFLAGS CFLAGS+=' -static-libgcc' CXXFLAGS+=' -static-libgcc' @@ -1566,14 +1588,14 @@ common_setup_msvc() { } common_setup_mingw() { - CC="${HOST}-gcc" - CXX="${HOST}-g++" + C_COMPILER="${HOST}-gcc" + CXX_COMPILER="${HOST}-g++" common_setup_windows } common_setup_macos() { - CC='clang' - CXX='clang++' + C_COMPILER='clang' + CXX_COMPILER='clang++' STRIP='strip' CFLAGS+=" -arch ${MACOS_ARCH} -mmacosx-version-min=${MACOS_VERSION}" CXXFLAGS+=" -arch ${MACOS_ARCH} -mmacosx-version-min=${MACOS_VERSION}" @@ -1581,8 +1603,8 @@ common_setup_macos() { } common_setup_linux() { - CC="${HOST/-unknown-/-}-gcc" - CXX="${HOST/-unknown-/-}-g++" + C_COMPILER="${HOST/-unknown-/-}-gcc" + CXX_COMPILER="${HOST/-unknown-/-}-g++" STRIP="${HOST/-unknown-/-}-strip" CROSS_PKG_CONFIG_PATH="/usr/lib/${HOST/-unknown-/-}/pkgconfig" CFLAGS+=' -fPIC' @@ -1590,8 +1612,8 @@ common_setup_linux() { } common_setup_freebsd() { - CC='clang' - CXX='clang++' + C_COMPILER='clang' + CXX_COMPILER='clang++' STRIP='strip' CFLAGS+=" -target ${HOST}" CXXFLAGS+=" -target ${HOST}" @@ -1612,6 +1634,11 @@ setup_default() { export CC='false' export CXX='false' + export C_COMPILER='false' + export CXX_COMPILER='false' + + export COMPILER_LAUNCHER='' + # Set defaults. export LD='ld' export AR='ar' @@ -1754,8 +1781,8 @@ setup_freebsd-amd64-default() { # Set up environment for native host tools setup_native() { setup_default - CC='cc' - CXX='c++' + C_COMPILER='cc' + CXX_COMPILER='c++' common_setup native native } From 36f2e5b9283d9fd420c5a3a855419bed5d096b71 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Wed, 8 Jul 2026 11:54:28 +0200 Subject: [PATCH 52/76] cmake: make possible for the game cmake to tell which variable to pass to the NaCl subinvocation It's used by Unvanquished to pass CBSE_PYTHON_PATH. Also delete DAEMON_CBSE_PYTHON_PATH (already moved to the game as CBSE_PYTHON_PATH). --- CMakeLists.txt | 1 - cmake/DaemonGame.cmake | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d6c4ae86f4..1ab418474f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,7 +150,6 @@ set(DEFAULT_NACL_VM_INHERITED_OPTIONS BUILD_SGAME CMAKE_BUILD_TYPE CMAKE_VERBOSE_MAKEFILE - DAEMON_CBSE_PYTHON_PATH USE_ARCH_INTRINSICS USE_COMPILER_CUSTOMIZATION USE_COMPILER_INTRINSICS diff --git a/cmake/DaemonGame.cmake b/cmake/DaemonGame.cmake index 1fbaf66946..ebc746a942 100644 --- a/cmake/DaemonGame.cmake +++ b/cmake/DaemonGame.cmake @@ -220,8 +220,8 @@ function(GAMEMODULE) set(INHERITED_OPTION_ARGS) - foreach(inherited_option ${NACL_VM_INHERITED_OPTIONS}) - set(INHERITED_OPTION_ARGS ${INHERITED_OPTION_ARGS} + foreach(inherited_option IN LISTS NACL_VM_INHERITED_OPTIONS GAME_NACL_VM_INHERITED_OPTIONS) + list(APPEND INHERITED_OPTION_ARGS "-D${inherited_option}=${${inherited_option}}") endforeach(inherited_option) From 92dc51bf31e2c91cdff78c81c71953f394bda6c2 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 10 Jul 2026 11:01:37 +0200 Subject: [PATCH 53/76] virtualmachine: increase timeout --- src/engine/framework/VirtualMachine.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/engine/framework/VirtualMachine.cpp b/src/engine/framework/VirtualMachine.cpp index d53afd5c62..3ed41176ed 100644 --- a/src/engine/framework/VirtualMachine.cpp +++ b/src/engine/framework/VirtualMachine.cpp @@ -169,10 +169,15 @@ static Cvar::Cvar vm_nacl_available( Cvar::ROM, vmAvailable); #if defined(DAEMON_NACL_RUNTIME_ENABLED) +/* We were initially using 2, but loading a nexe on an emulator +like box64 can be much longer than that. +Also, increasing the timeout makes possible to run the game when +stored on very slow filesystems. +This doesn't make loading longer, it allows it to be longer. */ static Cvar::Cvar vm_timeout( "vm.timeout", "Receive timeout in seconds", - Cvar::NONE, 2); + Cvar::NONE, 10); static Cvar::Cvar vm_nacl_qualification( "vm.nacl.qualification", From 21cd45d0f2a1d90aa81538b070475e30cec3a70e Mon Sep 17 00:00:00 2001 From: slipher Date: Mon, 7 Sep 2026 01:53:26 -0500 Subject: [PATCH 54/76] external_deps: remove amd64 bootstrap usage from deps. Closes #1327. Co-authored-by: Thomas Debesse --- external_deps/build.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 1c0c4c089b..4f1b4de5ec 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -1222,8 +1222,12 @@ build_naclruntime() { ) case "${PLATFORM}" in - linux-*) - mv "${PREFIX}/bin/nacl_helper_bootstrap" "${PREFIX}/nacl_helper_bootstrap-${nacl_arch}" + linux-i686-*|linux-arm64-*|linux-armhf-*) + case "${nacl_arch}" in + i686|armhf) + mv "${PREFIX}/bin/nacl_helper_bootstrap" "${PREFIX}/nacl_helper_bootstrap-${nacl_arch}" + ;; + esac ;; esac From fe987a318d55f9801c643e4d5e879755cc5f6c71 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 17 Oct 2026 00:35:55 +0200 Subject: [PATCH 55/76] external_deps: upgrade webp --- external_deps/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 4f1b4de5ec..679d8fa43c 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -52,7 +52,7 @@ PNG_VERSION=1.6.58 JPEG_VERSION=3.1.4.1 # WebP 1.6.0 introduced AVX2 intrinsics that are not available on # the GCC 10 compiler provided by Debian Bullseye. -WEBP_VERSION=1.5.0 +WEBP_VERSION=1.6.0 # OpenAL 0.25.0 requires C++20 that is not available on # the GCC 10 compiler provided by Debian Bullseye. OPENAL_VERSION=1.24.3 From 5c12632ecfeb97436f76f3184cce84d8b6c49ec1 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 17 Oct 2026 00:36:14 +0200 Subject: [PATCH 56/76] external_deps: ++ webp --- external_deps/build.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 679d8fa43c..e1093d53c0 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -50,8 +50,6 @@ SDL3_VERSION=3.4.10 GLEW_VERSION=2.3.1 PNG_VERSION=1.6.58 JPEG_VERSION=3.1.4.1 -# WebP 1.6.0 introduced AVX2 intrinsics that are not available on -# the GCC 10 compiler provided by Debian Bullseye. WEBP_VERSION=1.6.0 # OpenAL 0.25.0 requires C++20 that is not available on # the GCC 10 compiler provided by Debian Bullseye. From 3526407be1266bd6bdf52ec29a147a999e7dfeae Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 17 Oct 2026 00:37:04 +0200 Subject: [PATCH 57/76] external_deps: upgrade openal --- external_deps/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index e1093d53c0..458fa22579 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -53,7 +53,7 @@ JPEG_VERSION=3.1.4.1 WEBP_VERSION=1.6.0 # OpenAL 0.25.0 requires C++20 that is not available on # the GCC 10 compiler provided by Debian Bullseye. -OPENAL_VERSION=1.24.3 +OPENAL_VERSION=1.25.2 OGG_VERSION=1.3.6 VORBIS_VERSION=1.3.7 OPUS_VERSION=1.6.1 From a515a4262fd7662a54d8dff033a1f6a1b25aca6e Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 17 Oct 2026 00:37:17 +0200 Subject: [PATCH 58/76] external_deps: ++ openal --- external_deps/build.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 458fa22579..fd02cd5b93 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -51,8 +51,6 @@ GLEW_VERSION=2.3.1 PNG_VERSION=1.6.58 JPEG_VERSION=3.1.4.1 WEBP_VERSION=1.6.0 -# OpenAL 0.25.0 requires C++20 that is not available on -# the GCC 10 compiler provided by Debian Bullseye. OPENAL_VERSION=1.25.2 OGG_VERSION=1.3.6 VORBIS_VERSION=1.3.7 From ee5aee398ae96ad4a70e23c1498e475a9c00450f Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 17 Oct 2026 01:06:17 +0200 Subject: [PATCH 59/76] external_deps: upgrade nasm --- external_deps/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index fd02cd5b93..7f0d4f3d75 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -41,7 +41,7 @@ WASMTIME_BASEURL='https://github.com/bytecodealliance/wasmtime/releases' # Package versions PKGCONFIG_VERSION=0.29.2 -NASM_VERSION=2.16.03 +NASM_VERSION=3.02 ZLIB_VERSION=1.3.2 GMP_VERSION=6.3.0 NETTLE_VERSION=4.0 From c6f2959c3f64c93a64f916f4411cb263562c7f81 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 17 Oct 2026 01:07:19 +0200 Subject: [PATCH 60/76] fixup: build naclruntime with cmake --- external_deps/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 7f0d4f3d75..e0898a70b8 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -1799,7 +1799,7 @@ setup_platform() { esac } -base_windows_amd64_mingw_packages='native-jwasm zlib gmp nettle curl sdl3 glew png jpeg webp openal ogg vorbis opus opusfile naclsdk naclruntime depcheck' +base_windows_amd64_mingw_packages='zlib gmp nettle curl sdl3 glew png jpeg webp openal ogg vorbis opus opusfile naclsdk naclruntime depcheck' all_windows_amd64_mingw_packages="${base_windows_amd64_mingw_packages}" base_windows_i686_mingw_packages="${base_windows_amd64_mingw_packages}" From 5ec77cab839fbccbd20ae005dd294cc8411ecd2d Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 17 Oct 2026 01:18:11 +0200 Subject: [PATCH 61/76] external_deps: upgrade png --- external_deps/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index e0898a70b8..0a5d2bc79a 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -48,7 +48,7 @@ NETTLE_VERSION=4.0 CURL_VERSION=8.21.0 SDL3_VERSION=3.4.10 GLEW_VERSION=2.3.1 -PNG_VERSION=1.6.58 +PNG_VERSION=1.6.59 JPEG_VERSION=3.1.4.1 WEBP_VERSION=1.6.0 OPENAL_VERSION=1.25.2 From 5b1f878950f8bca4df4d29037bbc7e1bcd09bf87 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 17 Oct 2026 01:18:27 +0200 Subject: [PATCH 62/76] external_deps: upgrade jpeg --- external_deps/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 0a5d2bc79a..200e7d8bca 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -49,7 +49,7 @@ CURL_VERSION=8.21.0 SDL3_VERSION=3.4.10 GLEW_VERSION=2.3.1 PNG_VERSION=1.6.59 -JPEG_VERSION=3.1.4.1 +JPEG_VERSION=3.2.0 WEBP_VERSION=1.6.0 OPENAL_VERSION=1.25.2 OGG_VERSION=1.3.6 From 99a3752aef5f49ba6f92d41ac5ccca72edc1017e Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 17 Oct 2026 01:18:47 +0200 Subject: [PATCH 63/76] external_deps: upgrade curl --- external_deps/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 200e7d8bca..09f0b7909e 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -45,7 +45,7 @@ NASM_VERSION=3.02 ZLIB_VERSION=1.3.2 GMP_VERSION=6.3.0 NETTLE_VERSION=4.0 -CURL_VERSION=8.21.0 +CURL_VERSION=8.23.0 SDL3_VERSION=3.4.10 GLEW_VERSION=2.3.1 PNG_VERSION=1.6.59 From 2ae7be69a0cea7ab8083a60d191954f8e5dac67c Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 17 Oct 2026 01:19:02 +0200 Subject: [PATCH 64/76] external_deps: upgrade ncurses --- external_deps/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 09f0b7909e..08fd3b5aea 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -59,7 +59,7 @@ OPUSFILE_VERSION=0.12 BOX64_REVISION='b1d094f9bd37cd69865c56d72a94747b22c16dd6' NACLSDK_VERSION=44.0.2403.155 NACLRUNTIME_REVISION='70beec35eb5fa3ddd571f18f9ad57b5da674d85d' -NCURSES_VERSION=6.5 +NCURSES_VERSION=6.6 WASISDK_VERSION=16.0 WASMTIME_VERSION=2.0.2 From b18bd52748d72624aaf558adb396a19b49453138 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 17 Oct 2026 01:19:26 +0200 Subject: [PATCH 65/76] external_deps: upgrade sdl3 --- external_deps/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 08fd3b5aea..9dee2711a2 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -46,7 +46,7 @@ ZLIB_VERSION=1.3.2 GMP_VERSION=6.3.0 NETTLE_VERSION=4.0 CURL_VERSION=8.23.0 -SDL3_VERSION=3.4.10 +SDL3_VERSION=3.4.18 GLEW_VERSION=2.3.1 PNG_VERSION=1.6.59 JPEG_VERSION=3.2.0 From df1e179e389ae6524dadcd52f21125d7c5e30199 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 17 Oct 2026 01:46:46 +0200 Subject: [PATCH 66/76] fixup-macos-platform --- external_deps/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 9dee2711a2..7df76c8478 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -228,7 +228,7 @@ get_compiler_arg1() { cmake_build() { local cmake_args=() - case "${HOST}" in + case "${PLATFORM}" in native) cmake_args+=(-DCMAKE_PREFIX_PATH="${NATIVE_PREFIX}") cmake_args+=(-DCMAKE_INSTALL_PREFIX="${NATIVE_PREFIX}") @@ -239,7 +239,7 @@ cmake_build() { ;; esac - case "${HOST}" in + case "${PLATFORM}" in macos-*) cmake_args+=(-DCMAKE_OSX_ARCHITECTURES="${MACOS_ARCH}") cmake_args+=(-DCMAKE_OSX_DEPLOYMENT_TARGET="${MACOS_VERSION}") From c7f1cf5b5c62f448fefb8f9b83e055d6acd18c6a Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 17 Oct 2026 01:47:41 +0200 Subject: [PATCH 67/76] fixup-space --- external_deps/build.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 7df76c8478..afc075e697 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -296,9 +296,9 @@ build_native-pkgconfig() { ( setup_platform 'native' - CFLAGS='-Wno-error=int-conversion' \ - configure_build \ - --with-internal-glib + CFLAGS='-Wno-error=int-conversion' \ + configure_build \ + --with-internal-glib ) } From 126c53951f7660de7c05b204e43d1ff0e4c8cff6 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 17 Oct 2026 01:59:32 +0200 Subject: [PATCH 68/76] sdl-no-camera --- external_deps/build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index afc075e697..614b3f0f4e 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -523,7 +523,8 @@ build_sdl3() { cmake_build \ -DSDL_TEST_LIBRARY=OFF \ -DSDL_AUDIO=OFF \ - -DSDL_GPU=OFF + -DSDL_GPU=OFF \ + -DSDL_CAMERA=OFF ;; esac } From 54a1df36142b954133409e24b9fa039c8898c013 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 17 Oct 2026 02:01:55 +0200 Subject: [PATCH 69/76] curl-disable-options --- external_deps/build.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/external_deps/build.sh b/external_deps/build.sh index 614b3f0f4e..d668d0cd28 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -432,6 +432,9 @@ build_curl() { cmake_build \ -DBUILD_CURL_EXE=OFF \ + -DBUILD_EXAMPLES=OFF \ + -DBUILD_LIBCURL_DOCS=OFF \ + -DBUILD_MISC_DOCS=OFF \ -DBUILD_TESTING=OFF \ -DENABLE_CURL_MANUAL=OFF \ -DENABLE_THREADED_RESOLVER=OFF \ From f0b55e4733710d54ba148128822ed8f1c4a96d58 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 17 Oct 2026 02:57:39 +0200 Subject: [PATCH 70/76] workaround-openal-macos --- external_deps/build.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/external_deps/build.sh b/external_deps/build.sh index d668d0cd28..0bc150b86b 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -832,6 +832,13 @@ build_openal() { *) cd "${dir_name}" + case "${PLATFORM}" in + macos-*-*) + sed -e 's/-Werror=function-effects/-Wfunction-effects/' CMakeLists.txt > CMakeLists.txt-fix + mv CMakeLists.txt-fix CMakeLists.txt + ;; + esac + cmake_build \ -DALSOFT_UTILS=OFF \ "${openal_cmake_args[@]}" From dfd6f3ca35ffba5903155638cd5521348e4cd34a Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 17 Oct 2026 03:22:20 +0200 Subject: [PATCH 71/76] bootstrap --- external_deps/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 0bc150b86b..1b4b42024b 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -1229,7 +1229,7 @@ build_naclruntime() { ) case "${PLATFORM}" in - linux-i686-*|linux-arm64-*|linux-armhf-*) + linux-*-*) case "${nacl_arch}" in i686|armhf) mv "${PREFIX}/bin/nacl_helper_bootstrap" "${PREFIX}/nacl_helper_bootstrap-${nacl_arch}" From ee7eb9be76512a2d01d0bd85a7bfa75f826910ae Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 23 Oct 2026 11:47:00 +0200 Subject: [PATCH 72/76] box64 --- external_deps/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 1b4b42024b..488cef1664 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -56,7 +56,7 @@ OGG_VERSION=1.3.6 VORBIS_VERSION=1.3.7 OPUS_VERSION=1.6.1 OPUSFILE_VERSION=0.12 -BOX64_REVISION='b1d094f9bd37cd69865c56d72a94747b22c16dd6' +BOX64_REVISION='827f0ee54e54087baab2ed1e33ebc38998700589' NACLSDK_VERSION=44.0.2403.155 NACLRUNTIME_REVISION='70beec35eb5fa3ddd571f18f9ad57b5da674d85d' NCURSES_VERSION=6.6 From 575ec508df2ce448e1388dd7b4690e4d22aa791d Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 23 Oct 2026 11:47:23 +0200 Subject: [PATCH 73/76] naclruntime --- external_deps/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external_deps/build.sh b/external_deps/build.sh index 488cef1664..cd3d8bb7f7 100755 --- a/external_deps/build.sh +++ b/external_deps/build.sh @@ -58,7 +58,7 @@ OPUS_VERSION=1.6.1 OPUSFILE_VERSION=0.12 BOX64_REVISION='827f0ee54e54087baab2ed1e33ebc38998700589' NACLSDK_VERSION=44.0.2403.155 -NACLRUNTIME_REVISION='70beec35eb5fa3ddd571f18f9ad57b5da674d85d' +NACLRUNTIME_REVISION='ed51ac99f5675538e5bedde9bcae632eabee30ea' NCURSES_VERSION=6.6 WASISDK_VERSION=16.0 WASMTIME_VERSION=2.0.2 From fcf80c457ab6959c7dce9e0c5d64a2d0c75c7b01 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Fri, 23 Oct 2026 12:38:50 +0200 Subject: [PATCH 74/76] space --- src/engine/framework/VirtualMachine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/framework/VirtualMachine.cpp b/src/engine/framework/VirtualMachine.cpp index 3ed41176ed..279138f4a2 100644 --- a/src/engine/framework/VirtualMachine.cpp +++ b/src/engine/framework/VirtualMachine.cpp @@ -604,7 +604,7 @@ static std::pair CreateNaClVM(std::pair Date: Fri, 23 Oct 2026 14:04:01 +0200 Subject: [PATCH 75/76] implement VmFlags --- src/engine/framework/VirtualMachine.cpp | 68 ++++++++++++++++++++++--- 1 file changed, 60 insertions(+), 8 deletions(-) diff --git a/src/engine/framework/VirtualMachine.cpp b/src/engine/framework/VirtualMachine.cpp index 279138f4a2..7ba8d9879e 100644 --- a/src/engine/framework/VirtualMachine.cpp +++ b/src/engine/framework/VirtualMachine.cpp @@ -185,6 +185,47 @@ static Cvar::Cvar vm_nacl_qualification( Cvar::INIT, true); #endif // defined(DAEMON_NACL_RUNTIME_ENABLED) +enum class VmFlag : std::uint32_t { + InheritEnvironment = 1u << 0, + UseArmhfMultiarch = 1u << 1, +}; + +class VmFlags { +public: + using underlying_type = std::uint32_t; + + constexpr VmFlags() = default; + + constexpr VmFlags(VmFlag flag) + : bits_(static_cast(flag)) {} + + constexpr bool has(VmFlag flag) const noexcept { + const auto bit = static_cast(flag); + return (bits_ & bit) != 0; + } + + constexpr void set(VmFlag flag) noexcept { + bits_ |= static_cast(flag); + } + + constexpr void clear(VmFlag flag) noexcept { + bits_ &= ~static_cast(flag); + } + + constexpr underlying_type bits() const noexcept { + return bits_; + } + +private: + underlying_type bits_ = 0; +}; + +constexpr VmFlags operator|(VmFlag a, VmFlag b) noexcept { + VmFlags result{a}; + result.set(b); + return result; +} + namespace VM { // https://github.com/Unvanquished/Unvanquished/issues/944#issuecomment-744454772 @@ -229,7 +270,7 @@ static bool OnArm64() #endif // Platform-specific code to load a module -static std::pair InternalLoadModule(std::pair pair, const char* const* args, bool reserve_mem, FS::File stderrRedirect = FS::File(), bool inheritEnvironment = false) +static std::pair InternalLoadModule(std::pair pair, const char* const* args, bool reserve_mem, FS::File stderrRedirect = FS::File(), VmFlags flags = {}) { #ifdef _WIN32 // Inherit the socket in the child process @@ -297,7 +338,7 @@ static std::pair InternalLoadModule(std::pair InternalLoadModule(std::pair("LD_LIBRARY_PATH=libs-linux-armhf"); - + if (0 != posix_spawn_file_actions_addchdir_np(&fileActions, FS::GetLibPath().c_str())) { Sys::Error("failed posix_spawn_file_actions_addchdir"); } } -#endif +#endif // !DAEMON_NACL_RUNTIME_LINUX + // By default, the child process gets an empty environment for sandboxing. // When Box64 emulation is used, the child needs to inherit the parent's // environment so Box64 can find its configuration (e.g. ~/.box64rc, HOME) // and honor settings like BOX64_DYNAREC_PERFMAP. - char** envp = inheritEnvironment ? environ : emptyEnv; + char** envp = flags.has(VmFlag::InheritEnvironment) ? environ : emptyEnv; int err = posix_spawn(&pid, args[0], &fileActions, nullptr, const_cast(args), envp); posix_spawn_file_actions_destroy(&fileActions); if (err != 0) { @@ -719,7 +762,16 @@ static std::pair CreateNaClVM(std::pair Date: Fri, 23 Oct 2026 16:00:27 +0200 Subject: [PATCH 76/76] make possible to force box64 on armhf --- src/engine/framework/VirtualMachine.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/engine/framework/VirtualMachine.cpp b/src/engine/framework/VirtualMachine.cpp index 7ba8d9879e..3bfe6bab4c 100644 --- a/src/engine/framework/VirtualMachine.cpp +++ b/src/engine/framework/VirtualMachine.cpp @@ -97,6 +97,11 @@ static Cvar::Cvar vm_box64_path( "Path to the box64 binary for NaCl emulation (empty = use provided one or search PATH if missing)", Cvar::NONE, ""); +static Cvar::Cvar vm_box64_force( + "vm.box64.force", + "Force usage of box64 when supported", + Cvar::NONE, false); + // Resolve box64 binary path by looking for a provided one or searching PATH if not explicitly set. static std::string ResolveBox64Path(std::string naclPath) { std::string requestedPath = vm_box64_path.Get(); @@ -576,10 +581,12 @@ static std::pair CreateNaClVM(std::pair