From a11b69e2bcde42c1357de41caf8b81a1e8c5defe Mon Sep 17 00:00:00 2001 From: kbkpbot Date: Tue, 15 Jul 2025 20:47:54 +0800 Subject: [PATCH] ast: fix arch loongarch64 comptime support (fix #24906) (#24907) --- vlib/v/ast/comptime_valid_idents.v | 2 +- vlib/v/tests/comptime/comptime_arch_test.v | 28 ++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 vlib/v/tests/comptime/comptime_arch_test.v diff --git a/vlib/v/ast/comptime_valid_idents.v b/vlib/v/ast/comptime_valid_idents.v index 88d05e2d70..3d9e00d126 100644 --- a/vlib/v/ast/comptime_valid_idents.v +++ b/vlib/v/ast/comptime_valid_idents.v @@ -5,7 +5,7 @@ pub const valid_comptime_if_os = ['windows', 'ios', 'macos', 'mach', 'darwin', ' 'haiku', 'serenity', 'vinix', 'plan9', 'wasm32_emscripten'] pub const valid_comptime_if_compilers = ['gcc', 'tinyc', 'clang', 'mingw', 'msvc', 'cplusplus'] pub const valid_comptime_if_platforms = ['amd64', 'i386', 'aarch64', 'arm64', 'arm32', 'rv64', - 'rv32', 's390x', 'ppc64le'] + 'rv32', 's390x', 'ppc64le', 'loongarch64'] pub const valid_comptime_if_cpu_features = ['x64', 'x32', 'little_endian', 'big_endian'] pub const valid_comptime_if_other = ['apk', 'js', 'debug', 'prod', 'test', 'glibc', 'prealloc', 'no_bounds_checking', 'freestanding', 'threads', 'js_node', 'js_browser', 'js_freestanding', diff --git a/vlib/v/tests/comptime/comptime_arch_test.v b/vlib/v/tests/comptime/comptime_arch_test.v new file mode 100644 index 0000000000..1d887ec454 --- /dev/null +++ b/vlib/v/tests/comptime/comptime_arch_test.v @@ -0,0 +1,28 @@ +const arch = $if amd64 { + 'amd64' +} $else $if i386 { + 'i386' +} +//$else $if aarch64 {'aarch64'} +$else $if arm64 { + 'arm64' +} $else $if arm32 { + 'arm32' +} $else $if rv64 { + 'rv64' +} $else $if rv32 { + 'rv32' +} $else $if s390x { + 's390x' +} $else $if ppc64le { + 'ppc64le' +} $else $if loongarch64 { + 'loongarch64' +} $else { + 'unknown' +} + +fn test_main() { + println('arch is ${arch}') + assert arch != 'unknown' +}