From 7ba9efe31afb16c025ab2277774be0d8cfeb276c Mon Sep 17 00:00:00 2001 From: barracuda156 Date: Thu, 22 Jun 2023 00:38:48 +0800 Subject: [PATCH] Allow building for 32-bit and PPC --- src/is_supported_platform.h.orig 2025-10-08 03:57:41.000000000 +0800 +++ src/is_supported_platform.h 2025-10-22 08:02:20.000000000 +0800 @@ -21,7 +21,7 @@ // WARNING: do not #include anything in here! #if !defined(__BYTE_ORDER__) || __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__ -#error "Unfortunately we only work on litte-endian systems." +#warning "Big-endian systems are not supported by upstream." #endif #if (defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64)) @@ -36,21 +36,21 @@ #define DT_SUPPORTED_ARMv8A 0 #endif -#if defined(__PPC64__) -#define DT_SUPPORTED_PPC64 1 +#if defined(__PPC64__) && (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) +#define DT_SUPPORTED_PPC64LE 1 #else -#define DT_SUPPORTED_PPC64 0 +#define DT_SUPPORTED_PPC64LE 0 #endif #if DT_SUPPORTED_X86 && DT_SUPPORTED_ARMv8A #error "Looks like hardware platform detection macros are broken?" #endif -#if !DT_SUPPORTED_X86 && !DT_SUPPORTED_ARMv8A && !DT_SUPPORTED_PPC64 -#error "Unfortunately we only work on amd64, ARMv8-A and PPC64 (64-bit little-endian only)." +#if !DT_SUPPORTED_X86 && !DT_SUPPORTED_ARMv8A && !DT_SUPPORTED_PPC64LE +#warning "This platform is not supported by upstream." #endif -#undef DT_SUPPORTED_PPC64 +#undef DT_SUPPORTED_PPC64LE #undef DT_SUPPORTED_ARMv8A #undef DT_SUPPORTED_X86 @@ -61,7 +61,7 @@ // double check for 32-bit architecture #if defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ < 8 -#error "Unfortunately we only work on the 64-bit architectures amd64, ARMv8-A and PPC64." +#warning "32-bit systems are not supported by upstream." #endif // clang-format off @@ -69,4 +69,3 @@ // vim: shiftwidth=2 expandtab tabstop=2 cindent // kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified; // clang-format on - --- src/CMakeLists.txt 2023-06-30 14:13:18.000000000 +0800 +++ src/CMakeLists.txt 2024-04-29 17:27:08.000000000 +0800 @@ -226,7 +226,8 @@ set(SOURCES ${SOURCE_FILES} ${HEADER_FILES}) -if(CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64le") +# There is nothing LE there. +if(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc|powerpc") include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ppc64le) endif() @@ -551,6 +552,8 @@ add_definitions(-DHAVE_OPENCL=1) endif(USE_OPENCL) +# The check below does not work correctly, and this builtin not relevant anyway. +if(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "ppc|powerpc") # Check for __builtin_cpu_supports here due to a bug in clang/llvm. LLVM uses # libgcc to provide the symbols, so if clang wasn't compiled with libgcc, the # compiler will say it's available; however the linker cannot find the symbols. @@ -565,6 +568,7 @@ add_definitions(-DHAVE_BUILTIN_CPU_SUPPORTS=1) endif(HAVE_BUILTIN_CPU_SUPPORTS) MESSAGE(STATUS "Does the compiler support __builtin_cpu_supports(): ${HAVE_BUILTIN_CPU_SUPPORTS}") +endif() check_c_source_compiles(" static __thread int tls;