Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenAMP behaves differently for make and cmake when compiling for armv7-m #10401

Open
raiden00pl opened this issue Aug 25, 2023 · 6 comments · Fixed by #10328 · May be fixed by #11119
Open

OpenAMP behaves differently for make and cmake when compiling for armv7-m #10401

raiden00pl opened this issue Aug 25, 2023 · 6 comments · Fixed by #10328 · May be fixed by #11119

Comments

@raiden00pl
Copy link
Contributor

There is no problems when building with cmake for armv7-m targets, but the same configuration doesn't work with make:

./tools/configure.sh nucleo-h745zi:nsh_cm7_rptun 
make -j
...
LD: nuttx                                                                                                                                                                               
arm-none-eabi-ld: /home/raiden00/git/RTOS/nuttx/nuttx/staging/libopenamp.a(remoteproc_virtio.o): in function `metal_io_read':
/home/raiden00/git/RTOS/nuttx/nuttx/include/metal/io.h:252: undefined reference to `__atomic_load_8'
arm-none-eabi-ld: /home/raiden00/git/RTOS/nuttx/nuttx/staging/libopenamp.a(remoteproc_virtio.o): in function `metal_io_write':
/home/raiden00/git/RTOS/nuttx/nuttx/include/metal/io.h:290: undefined reference to `__atomic_store_8'
make[1]: *** [Makefile:197: nuttx] Error 1

The problem doesn't occur for armv8-m targets:

./tools/configure.sh nrf5340-dk:rptun_cpunet
make -j
...
LD: nuttx                                                                                                                                                                             
CP: nuttx.hex
CP: nuttx.bin
@xiaoxiang781216
Copy link
Contributor

it's strange that cmake and make generate the different result with the same config.

@raiden00pl
Copy link
Contributor Author

Yes, the same config. I also replaced the generated .configs but the problem persists. So there must be a subtle difference in the build systems somewhere.

@anchao
Copy link
Contributor

anchao commented Aug 25, 2023

The cmake does not add the implementation of toolchain atomic support: #9760,
from the break log, maybe armv7-m does not support 64-bit atomic

@anchao
Copy link
Contributor

anchao commented Aug 25, 2023

I have a workaround for arch armv7-m to disable toolchain atomic:

$ git diff --cached 
diff --git a/openamp/libmetal.defs b/openamp/libmetal.defs
index d2df7b5b6a..8e906bd952 100644
--- a/openamp/libmetal.defs
+++ b/openamp/libmetal.defs
@@ -67,9 +67,14 @@ LIBMETAL_HDRS_SEDEXP := \
         s/@PROJECT_SYSTEM_UPPER@/nuttx/g; \
         s/@PROJECT_PROCESSOR_UPPER@/$(LIBMETAL_ARCH)/g; \
         s/@PROJECT_MACHINE_UPPER@/$(CONFIG_ARCH_CHIP)/g; \
+
+ifeq ($(CONFIG_ARCH_ARMV7M)$(CONFIG_ARCH_ARMV6M),y)
+LIBMETAL_HDRS_SEDEXP += \
         s/cmakedefine HAVE_STDATOMIC_H/include <nuttx\/compiler.h>/g; \
-        s/defined(HAVE_STDATOMIC_H)/defined(CONFIG_HAVE_ATOMICS)/g; \
-        s/cmakedefine/undef/g"
+        s/defined(HAVE_STDATOMIC_H)/defined(CONFIG_HAVE_ATOMICS)/g;
+endif
+
+LIBMETAL_HDRS_SEDEXP += s/cmakedefine/undef/g"
 
 ifeq ($(wildcard libmetal/.git),)
 libmetal.zip:

@raiden00pl
Copy link
Contributor Author

This issue is not fixed.

@AndreHeinemans-NXP
Copy link
Contributor

Is it possible that the cmake build uses different optimization settings? Maybe it is linked to this issue #12489.

The nrf5340-dk:rptun_cpunet builds well with make using -Os

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants