From bc67453b6c13ee5e7b06a802a4e9827d868422ab Mon Sep 17 00:00:00 2001 From: jeefo Date: Thu, 13 Nov 2025 15:41:30 +0300 Subject: [PATCH] platform: added basic riscv support --- ext/crlib | 2 +- meson.build | 11 +++++++---- src/engine.cpp | 9 ++++++--- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ext/crlib b/ext/crlib index f7b1b02..173f387 160000 --- a/ext/crlib +++ b/ext/crlib @@ -1 +1 @@ -Subproject commit f7b1b02a301f900082d2e05ebbbc2d7edc2a4e09 +Subproject commit 173f387022310148e1f9ef65d61164579ba509a9 diff --git a/meson.build b/meson.build index 9bbfd8a..5d04f24 100644 --- a/meson.build +++ b/meson.build @@ -37,6 +37,7 @@ os = host_machine.system() cpu = host_machine.cpu_family() cxx = compiler.get_id() build_type = get_option ('buildtype') +cpu_non_x86 = cpu == 'arm' or cpu.startswith('ppc') or cpu.startswith('riscv') opt_64bit = get_option('64bit') opt_native = get_option('native') @@ -111,7 +112,7 @@ if cxx == 'clang' or cxx == 'gcc' '-pthread' ] - if not opt_native and cpu != 'arm' and not cpu.startswith('ppc') + if not opt_native and not cpu_non_x86 cxxflags += '-mtune=generic' endif @@ -119,7 +120,7 @@ if cxx == 'clang' or cxx == 'gcc' cxxflags += [ '-march=armv8-a+fp+simd', ] - elif cpu != 'arm' and not cpu.startswith('ppc') + elif not cpu_non_x86 if not opt_nosimd cxxflags += [ '-msse', '-msse2', '-msse3', '-msse3', '-mfpmath=sse' @@ -143,7 +144,7 @@ if cxx == 'clang' or cxx == 'gcc' '-funroll-loops', '-fomit-frame-pointer', '-fno-stack-protector', '-fvisibility=hidden', '-fvisibility-inlines-hidden', '-fno-math-errno' ] - if os != 'darwin' and os != 'windows' and cpu != 'aarch64' and cpu != 'arm' and not cpu.startswith('ppc') + if os != 'darwin' and os != 'windows' and cpu != 'aarch64' and not cpu_non_x86 if not opt_static_linkent cxxflags += [ '-fdata-sections', @@ -203,7 +204,7 @@ if cxx == 'clang' or cxx == 'gcc' endif # by default we buid 32bit binaries - if not opt_64bit and cpu != 'aarch64' and cpu != 'arm' and not cpu.startswith('ppc') + if not opt_64bit and cpu != 'aarch64' and not cpu_non_x86 cxxflags += '-m32' ldflags += '-m32' @@ -319,6 +320,8 @@ target_name = meson.project_name() # xash specific postfix for binaries if cpu == 'aarch64' target_name += '_arm64' +elif cpu.startswith('riscv') + target_name += '_riscv64d' elif opt_64bit target_name += '_amd64' endif diff --git a/src/engine.cpp b/src/engine.cpp index 9e7fb6f..0a7c480 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -827,6 +827,9 @@ void Game::constructCSBinaryName (StringArray &libs) { else if (plat.ppc) { suffix = "_ppc64le"; } + else if (plat.riscv) { + suffix = "_riscv64d"; + } else { suffix = "_amd64"; } @@ -844,12 +847,12 @@ void Game::constructCSBinaryName (StringArray &libs) { // build base names if (plat.android) { // only "libcs" with suffix (no "mp", and must have "lib" prefix) - libs.insert (0, "libcs" + suffix); + libs.push ("libcs" + suffix); } else { // Standard: "mp" and "cs" with suffix - libs.insert (0, "cs" + suffix); - libs.insert (0, "mp" + suffix); + libs.push ("cs" + suffix); + libs.push ("mp" + suffix); } }