platform: added basic riscv support

This commit is contained in:
jeefo 2025-11-13 15:41:30 +03:00
commit bc67453b6c
No known key found for this signature in database
GPG key ID: D696786B81B667C8
3 changed files with 14 additions and 8 deletions

@ -1 +1 @@
Subproject commit f7b1b02a301f900082d2e05ebbbc2d7edc2a4e09
Subproject commit 173f387022310148e1f9ef65d61164579ba509a9

View file

@ -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

View file

@ -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);
}
}