Dear maintainers,

On Mon, 30 Oct 2023 15:06:26 +0800 zhangdandan wrote:

> Source: ceph
> Version: 16.2.11+ds-5
> Severity: wishlist
> Tags: ftbfs patch
> User: [email protected]
> Usertags: loong64
>
> Dear maintainers,
>
> The package ceph failed to compile on loong64 in the Debian Package
> Auto-Building environment. The error messages are as follows,
> ```
> /usr/bin/ld: /usr/include/c++/13/bits/atomic_base.h:1015:(.text+0x9dc):
> undefined reference to `__atomic_compare_exchange_16'
> /usr/bin/ld: /usr/include/c++/13/bits/atomic_base.h:1015:(.text+0xa00):
> undefined reference to `__atomic_compare_exchange_16'
> [ 95%] Linking CXX shared library ../../lib/librbd.so
> cd /<>/obj-loongarch64-linux-gnu/src/librbd &&
> /usr/bin/cmake -E cmake_link_script CMakeFiles/librbd.dir/link.txt
> --verbose=1
> ```
>
> The full compilation log can be found at
> https://buildd.debian.org/status/logs.php?pkg=ceph&ver=16.2.11%2Bds-5&arch=loong64
>
> BTW, ceph upstream uses the "__SIZEOF_INT128__" macro definitions
> starting with version v18.0.0, please see details at
> https://github.com/ceph/ceph/blob/v18.0.0/cmake/modules/CheckCxxAtomic.cmake.
> Environment information for loong64 rootfs:
> root@localhost:/home/ceph# dpkg-architecture  |grep DEB_HOST_ARCH_CPU
> DEB_HOST_ARCH_CPU=loong64
> root@localhost:/home/ceph# gcc -dM -E - > #define __SIZEOF_INT128__ 16
>
> For the ceph version in the debian sid, please consider the patch I have
> attached.
> If you have any questions, you can contact me at any time.

- enable loongarch64 support in d/control.
Please consider the below patch.
```
diff -Nru ceph-16.2.11+ds/debian/control ceph-16.2.11+ds/debian/control
--- ceph-16.2.11+ds/debian/control    2023-10-09 06:53:31.000000000 +0000
+++ ceph-16.2.11+ds/debian/control    2023-10-09 06:53:31.000000000 +0000
@@ -50,7 +50,7 @@
  libfuse-dev,
  libgf-complete-dev,
  libgnutls28-dev,
- libgoogle-perftools-dev [amd64 arm64 armel armhf i386 mips64el mipsel ppc64 ppc64el riscv64 powerpc s390x], + libgoogle-perftools-dev [amd64 arm64 armel armhf i386 loong64 mips64el mipsel ppc64 ppc64el riscv64 powerpc s390x],
  libhwloc-dev,
```

- add loongarch64 support in src/rocksdb.
In addition, please consider the attached patch (For src/rocksdb).
loongarch64 was supported in rocksdb's upstream, you can also refer to https://github.com/facebook/rocksdb/pull/10036/files.

I have built ceph successfully on my local loong64 rootfs, and I have uploaded the ceph packages to unreleased repo. For loong64, the unreleased source package of ceph can be found at http://ftp.ports.debian.org/debian-ports/pool-loong64/main/c/ceph/.

Could you add loongarch64 support in the next upload?
Any questions, you can contact me at any time.

Sincerely
Dandan

Description: FTBFS: add loongarch64 support
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 ceph (18.2.3+ds-3+loong64) unreleased; urgency=medium
 .
   * Add build support for loong64. (Open: #1055047)
   * FTBFS: add support for loong64. (Open: #1069022)
Author: Dandan Zhang <[email protected]>

---
The information above should follow the Patch Tagging Guidelines, please
checkout https://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Applied-Upstream: https://github.com/facebook/rocksdb/pull/10036
Reviewed-By: <name and email of someone who approved/reviewed the patch>
Last-Update: 2024-07-03

--- ceph-18.2.3+ds.orig/src/rocksdb/CMakeLists.txt
+++ ceph-18.2.3+ds/src/rocksdb/CMakeLists.txt
@@ -245,6 +245,14 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "s390x
   endif(HAS_S390X_MARCH_NATIVE)
 endif(CMAKE_SYSTEM_PROCESSOR MATCHES "s390x")
 
+if(CMAKE_SYSTEM_PROCESSOR MATCHES "loongarch64")
+  CHECK_C_COMPILER_FLAG("-march=loongarch64" HAS_LOONGARCH64)
+  if(HAS_LOONGARCH64)
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mtune=loongarch64")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mtune=loongarch64")
+  endif(HAS_LOONGARCH64)
+endif(CMAKE_SYSTEM_PROCESSOR MATCHES "loongarch64")
+
 option(PORTABLE "build a portable binary" OFF)
 option(FORCE_SSE42 "force building with SSE4.2, even when PORTABLE=ON" OFF)
 option(FORCE_AVX "force building with AVX, even when PORTABLE=ON" OFF)
--- ceph-18.2.3+ds.orig/src/rocksdb/Makefile
+++ ceph-18.2.3+ds/src/rocksdb/Makefile
@@ -2058,7 +2058,7 @@ JAVA_INCLUDE = -I$(JAVA_HOME)/include/ -
 ifeq ($(PLATFORM), OS_SOLARIS)
 	ARCH := $(shell isainfo -b)
 else ifeq ($(PLATFORM), OS_OPENBSD)
-	ifneq (,$(filter amd64 ppc64 ppc64le s390x arm64 aarch64 sparc64, $(MACHINE)))
+	ifneq (,$(filter amd64 ppc64 ppc64le s390x arm64 aarch64 sparc64 loongarch64, $(MACHINE)))
 		ARCH := 64
 	else
 		ARCH := 32
--- ceph-18.2.3+ds.orig/src/rocksdb/port/port_posix.h
+++ ceph-18.2.3+ds/src/rocksdb/port/port_posix.h
@@ -169,6 +169,8 @@ static inline void AsmVolatilePause() {
   asm volatile("isb");
 #elif defined(__powerpc64__)
   asm volatile("or 27,27,27");
+#elif defined(__loongarch64) 
+  asm volatile("dbar 0");    
 #endif
   // it's okay for other platforms to be no-ops
 }
--- ceph-18.2.3+ds.orig/src/rocksdb/util/xxhash.h
+++ ceph-18.2.3+ds/src/rocksdb/util/xxhash.h
@@ -1287,7 +1287,8 @@ XXH_PUBLIC_API XXH128_hash_t XXH128(cons
 
 #ifndef XXH_FORCE_ALIGN_CHECK  /* can be defined externally */
 #  if defined(__i386)  || defined(__x86_64__) || defined(__aarch64__) \
-   || defined(_M_IX86) || defined(_M_X64)     || defined(_M_ARM64) /* visual */
+   || defined(_M_IX86) || defined(_M_X64)     || defined(_M_ARM64) /* visual */ \
+   || defined(__loongarch64)
 #    define XXH_FORCE_ALIGN_CHECK 0
 #  else
 #    define XXH_FORCE_ALIGN_CHECK 1
--- ceph-18.2.3+ds.orig/src/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h
+++ ceph-18.2.3+ds/src/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h
@@ -160,6 +160,10 @@ static inline tokutime_t toku_time_now(v
   struct timeval tv;
   gettimeofday(&tv, nullptr);
   return (uint64_t)tv.tv_sec * 1000000 + tv.tv_usec;
+#elif defined(__loongarch64)
+  unsigned long result;
+  asm volatile ("rdtime.d\t%0,$r0" : "=r" (result));
+  return result;
 #else
 #error No timer implementation for this platform
 #endif

Reply via email to