You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/06/29 14:38:55 UTC
(nuttx) 02/02: libmetal/atomic: enable 64-bit atomic by toolchain builtin flags
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit ab51eae836019f7ceb0b56d084ad3ff001eb2470
Author: chao an <an...@lixiang.com>
AuthorDate: Sat Jun 29 09:52:21 2024 +0800
libmetal/atomic: enable 64-bit atomic by toolchain builtin flags
Fix compile error:
arm-none-eabi-ld: (remoteproc_virtio.o): in function `metal_io_read':
metal/io.h:252: undefined reference to `__atomic_load_8'
arm-none-eabi-ld: (remoteproc_virtio.o): in function `metal_io_write':
metal/io.h:290: undefined reference to `__atomic_store_8'
Not all 32-bit architectures support 64bit atomic, gcc/clang
toolchains have built-in properties to indicate whether support atomic64:
| $ arm-none-eabi-gcc -march=armv7e-m -dM -E - < /dev/null | grep SYNC
| #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
| #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
| #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
Signed-off-by: chao an <an...@lixiang.com>
---
...omic-enable-64-bit-atomic-by-toolchain-bu.patch | 44 ++++++++++++++++++++++
openamp/libmetal.cmake | 2 +
openamp/libmetal.defs | 1 +
3 files changed, 47 insertions(+)
diff --git a/openamp/0004-libmetal-atomic-enable-64-bit-atomic-by-toolchain-bu.patch b/openamp/0004-libmetal-atomic-enable-64-bit-atomic-by-toolchain-bu.patch
new file mode 100644
index 0000000000..73b95c3a81
--- /dev/null
+++ b/openamp/0004-libmetal-atomic-enable-64-bit-atomic-by-toolchain-bu.patch
@@ -0,0 +1,44 @@
+From f17ee493475793be52b364b0ad7cd7042bc27ffe Mon Sep 17 00:00:00 2001
+From: chao an <an...@lixiang.com>
+Date: Sat, 29 Jun 2024 09:40:26 +0800
+Subject: [PATCH] libmetal/atomic: enable 64-bit atomic by toolchain builtin
+ flags
+
+Fix compile error:
+arm-none-eabi-ld: (remoteproc_virtio.o): in function `metal_io_read':
+metal/io.h:252: undefined reference to `__atomic_load_8'
+arm-none-eabi-ld: (remoteproc_virtio.o): in function `metal_io_write':
+metal/io.h:290: undefined reference to `__atomic_store_8'
+
+Not all 32-bit architectures support 64bit atomic, gcc/clang
+toolchains have built-in properties to indicate whether support atomic64:
+
+| $ arm-none-eabi-gcc -march=armv7e-m -dM -E - < /dev/null | grep SYNC
+| #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+| #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+| #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+
+Signed-off-by: chao an <an...@lixiang.com>
+---
+ openamp/libmetal/lib/io.h | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/lib/io.h libmetal/lib/io.h
+index ba416dd505..8cd03e41db 100644
+--- a/lib/io.h
++++ libmetal/lib/io.h
+@@ -30,8 +30,9 @@ extern "C" {
+ * @{
+ */
+
+-#ifdef __MICROBLAZE__
+-#define NO_ATOMIC_64_SUPPORT
++#if defined(__MICROBLAZE__) || \
++ (defined(__GNUC__) && !defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8))
++# define NO_ATOMIC_64_SUPPORT
+ #endif
+
+ struct metal_io_region;
+--
+2.34.1
+
diff --git a/openamp/libmetal.cmake b/openamp/libmetal.cmake
index 41f3aa9d08..498bdc1874 100644
--- a/openamp/libmetal.cmake
+++ b/openamp/libmetal.cmake
@@ -40,6 +40,8 @@ if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/libmetal)
${CMAKE_CURRENT_LIST_DIR}/0002-libmetal-nuttx-io.c-align-access-when-read-write-siz.patch
&& patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
${CMAKE_CURRENT_LIST_DIR}/0003-libmetal-nuttx-io.c-Fix-void-pointer-arithmetic-in-a.patch
+ && patch -p0 -d ${CMAKE_CURRENT_LIST_DIR} <
+ ${CMAKE_CURRENT_LIST_DIR}/0004-libmetal-atomic-enable-64-bit-atomic-by-toolchain-bu.patch
DOWNLOAD_NO_PROGRESS true
TIMEOUT 30)
diff --git a/openamp/libmetal.defs b/openamp/libmetal.defs
index 90e8a690be..8e5d439bc8 100644
--- a/openamp/libmetal.defs
+++ b/openamp/libmetal.defs
@@ -80,6 +80,7 @@ libmetal.zip:
$(Q) patch -p0 < 0001-libmetal-add-metal_list_for_each_safe-support.patch
$(Q) patch -p0 < 0002-libmetal-nuttx-io.c-align-access-when-read-write-siz.patch
$(Q) patch -p0 < 0003-libmetal-nuttx-io.c-Fix-void-pointer-arithmetic-in-a.patch
+ $(Q) patch -p0 < 0004-libmetal-atomic-enable-64-bit-atomic-by-toolchain-bu.patch
.libmetal_headers: libmetal.zip
else