Add RISCV CPU architecture support to build config

Remove assert statement from make_update.py, making it ready for any
architecture.

Add riscv 32, 64 and 128 bit cpu architecture with little/big endian
to Blender's BLI_build_config.h and Libmv's build_config.h

Tested (to compile) on riscv64 little endian machine.

Pull Request: https://projects.blender.org/blender/blender/pulls/130920
This commit is contained in:
Raphael Langerhorst 2024-11-28 12:37:26 +01:00 committed by Sergey Sharybin
parent 9e28809695
commit f662caf722
4 changed files with 56 additions and 3 deletions

View file

@ -116,8 +116,6 @@ def get_effective_architecture(args: argparse.Namespace) -> str:
if architecture == "aarch64":
architecture = "arm64"
assert (architecture in {"x64", "arm64"})
assert isinstance(architecture, str)
return architecture

View file

@ -345,6 +345,23 @@
# define ARCH_CPU_32_BITS 1
# define ARCH_CPU_BIG_ENDIAN 1
# endif
#elif defined(__riscv)
# define ARCH_CPU_RISCV_FAMILY 1
# if defined(__LP128__)
# define ARCH_CPU_RISCV128 1
# define ARCH_CPU_128_BITS 1
# elif defined(__LP64__)
# define ARCH_CPU_RISCV64 1
# define ARCH_CPU_64_BITS 1
# else
# define ARCH_CPU_RISCV32 1
# define ARCH_CPU_32_BITS 1
# endif
# if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
# define ARCH_CPU_LITTLE_ENDIAN 1
# else
# define ARCH_CPU_BIG_ENDIAN 1
# endif
#else
# error Please add support for your architecture in build/build_config.h
#endif
@ -362,6 +379,9 @@
#if !defined(ARCH_CPU_64_BITS)
# define ARCH_CPU_64_BITS 0
#endif
#if !defined(ARCH_CPU_128_BITS)
# define ARCH_CPU_128_BITS 0
#endif
#if !defined(ARCH_CPU_X86_FAMILY)
# define ARCH_CPU_X86_FAMILY 0
@ -378,5 +398,8 @@
#if !defined(ARCH_CPU_S390_FAMILY)
# define ARCH_CPU_S390_FAMILY 0
#endif
#if !defined(ARCH_CPU_RISCV_FAMILY)
# define ARCH_CPU_RISCV_FAMILY 0
#endif
#endif // LIBMV_BUILD_BUILD_CONFIG_H_

View file

@ -337,6 +337,23 @@
# define ARCH_CPU_32_BITS 1
# define ARCH_CPU_BIG_ENDIAN 1
# endif
#elif defined(__riscv)
# define ARCH_CPU_RISCV_FAMILY 1
# if defined(__LP128__)
# define ARCH_CPU_RISCV128 1
# define ARCH_CPU_128_BITS 1
# elif defined(__LP64__)
# define ARCH_CPU_RISCV64 1
# define ARCH_CPU_64_BITS 1
# else
# define ARCH_CPU_RISCV32 1
# define ARCH_CPU_32_BITS 1
# endif
# if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
# define ARCH_CPU_LITTLE_ENDIAN 1
# else
# define ARCH_CPU_BIG_ENDIAN 1
# endif
#else
# error Please add support for your architecture in BLI_build_config.h
#endif
@ -357,6 +374,9 @@
#if !defined(ARCH_CPU_64_BITS)
# define ARCH_CPU_64_BITS 0
#endif
#if !defined(ARCH_CPU_128_BITS)
# define ARCH_CPU_128_BITS 0
#endif
#if !defined(ARCH_CPU_X86_FAMILY)
# define ARCH_CPU_X86_FAMILY 0
@ -373,6 +393,9 @@
#if !defined(ARCH_CPU_S390_FAMILY)
# define ARCH_CPU_S390_FAMILY 0
#endif
#if !defined(ARCH_CPU_RISCV_FAMILY)
# define ARCH_CPU_RISCV_FAMILY 0
#endif
#if !defined(ARCH_CPU_ARM64)
# define ARCH_CPU_ARM64 0
@ -407,5 +430,14 @@
#if !defined(ARCH_CPU_X86_64)
# define ARCH_CPU_X86_64 0
#endif
#if !defined(ARCH_CPU_RISCV32)
# define ARCH_CPU_RISCV32 0
#endif
#if !defined(ARCH_CPU_RISCV64)
# define ARCH_CPU_RISCV64 0
#endif
#if !defined(ARCH_CPU_RISCV128)
# define ARCH_CPU_RISCV128 0
#endif
/** \} */

View file

@ -13,7 +13,7 @@ namespace blender::tests {
* build_config implementation. */
TEST(BLI_build_config, Basic)
{
static_assert(ARCH_CPU_31_BITS || ARCH_CPU_32_BITS || ARCH_CPU_64_BITS);
static_assert(ARCH_CPU_31_BITS || ARCH_CPU_32_BITS || ARCH_CPU_64_BITS || ARCH_CPU_128_BITS);
}
TEST(BLI_build_config, Endian)