File 0001-Enable-building-on-arbitrary-architectures.patch of Package 0ad

From ce0c692cf8b3d3f24e560ec60d20f7f4e2e99c3f Mon Sep 17 00:00:00 2001
From: Jan Engelhardt <jengelh@inai.de>
Date: Mon, 24 Feb 2025 20:04:23 +0000
Subject: [PATCH] Enable building on arbitrary architectures
References: https://gitea.wildfiregames.com/0ad/0ad/pulls/7663

This makes the software build on riscv64, ppc64le and s390x.
---
 build/premake/premake5.lua                 | 7 ++++++-
 source/lib/sysdep/arch.h                   | 5 -----
 source/lib/sysdep/arch/generic/generic.cpp | 6 ++++++
 3 files changed, 12 insertions(+), 6 deletions(-)
 create mode 100644 source/lib/sysdep/arch/generic/generic.cpp

diff --git a/build/premake/premake5.lua b/build/premake/premake5.lua
index dd7d6c6584..2cb5f8eaac 100644
--- a/build/premake/premake5.lua
+++ b/build/premake/premake5.lua
@@ -116,7 +116,7 @@ else
 	elseif string.find(machine, "ppc64") == 1 or string.find(machine, "powerpc64") == 1 then
 		arch = "ppc64"
 	else
-		print("WARNING: Cannot determine architecture from GCC, assuming x86")
+		arch = "generic"
 	end
 end
 
@@ -916,6 +916,8 @@ function setup_all_libs ()
 		table.insert(source_dirs, "lib/sysdep/arch/e2k");
 	elseif arch == "ppc64" then
 		table.insert(source_dirs, "lib/sysdep/arch/ppc64");
+	else
+		table.insert(source_dirs, "lib/sysdep/arch/generic");
 	end
 
 	-- OS-specific
@@ -1127,6 +1129,9 @@ function setup_main_exe ()
 			links {
 				-- Dynamic libraries (needed for linking for gold)
 				"dl",
+				-- boost lockfree algorithms cause references, satisfy them
+				-- <https://github.com/scylladb/seastar/issues/530#issuecomment-2679517925>
+				"atomic",
 			}
 		end
 
diff --git a/source/lib/sysdep/arch.h b/source/lib/sysdep/arch.h
index 74550970ce..7963e292f8 100644
--- a/source/lib/sysdep/arch.h
+++ b/source/lib/sysdep/arch.h
@@ -83,11 +83,6 @@
 # define ARCH_E2K 0
 #endif
 
-// ensure exactly one architecture has been detected
-#if (ARCH_IA32+ARCH_IA64+ARCH_AMD64+ARCH_ALPHA+ARCH_ARM+ARCH_AARCH64+ARCH_MIPS+ARCH_E2K+ARCH_PPC64) != 1
-# error "architecture not correctly detected (either none or multiple ARCH_* defined)"
-#endif
-
 // "X86_X64"-specific code requires either IA-32 or AMD64
 #define ARCH_X86_X64 (ARCH_IA32|ARCH_AMD64)
 
diff --git a/source/lib/sysdep/arch/generic/generic.cpp b/source/lib/sysdep/arch/generic/generic.cpp
new file mode 100644
index 0000000000..bdd0562a87
--- /dev/null
+++ b/source/lib/sysdep/arch/generic/generic.cpp
@@ -0,0 +1,6 @@
+#include "precompiled.h"
+#include "lib/sysdep/cpu.h"
+const char* cpu_IdentifierString()
+{
+	return "generic";
+}
-- 
2.48.1

openSUSE Build Service is sponsored by