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


The following commit(s) were added to refs/heads/master by this push:
     new 8de922186e Exported CMake toolchain file is broken when the target is 
linked against NuttX and another library that shall also be linked against 
NuttX too. Fix: ensure that NuttX libraries are linked at the end as they are 
the root of linkage dependency tree.
8de922186e is described below

commit 8de922186e62e4aa741cae8790acc30a537c9c53
Author: Philippe Leduc <[email protected]>
AuthorDate: Fri Mar 1 09:24:27 2024 +0100

    Exported CMake toolchain file is broken when the target is linked against 
NuttX and another library that shall also be linked against NuttX too.
    Fix: ensure that NuttX libraries are linked at the end as they are the root 
of linkage dependency tree.
---
 tools/toolchain.cmake.export | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/tools/toolchain.cmake.export b/tools/toolchain.cmake.export
index c879954df0..9aa56529f1 100644
--- a/tools/toolchain.cmake.export
+++ b/tools/toolchain.cmake.export
@@ -21,13 +21,12 @@ set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES
 add_compile_options(-nostdlib)
 add_compile_options(-ffunction-sections -fdata-sections)
 
-link_libraries(
-  "-L${NUTTX_PATH}/libs -Wl,--start-group ${LDLIBS} ${EXTRA_LIBS} 
-Wl,--end-group"
+set(CMAKE_C_LINK_EXECUTABLE
+    "<CMAKE_LINKER> ${LDFLAGS} --entry=__start -T${LINKER_SCRIPT} <OBJECTS> -o 
<TARGET> <LINK_LIBRARIES> -L${NUTTX_PATH}/libs --start-group ${LDLIBS} 
${EXTRA_LIBS} --end-group"
+)
+set(CMAKE_CXX_LINK_EXECUTABLE
+    "<CMAKE_LINKER> ${LDFLAGS} --entry=__start -T${LINKER_SCRIPT} <OBJECTS> -o 
<TARGET> <LINK_LIBRARIES> -L${NUTTX_PATH}/libs --start-group ${LDLIBS} 
${EXTRA_LIBS} --end-group"
 )
-add_link_options(-Wl,--entry=__start)
-add_link_options(-nostdlib)
-add_link_options(-Wl,--gc-sections)
-add_link_options(-T${LINKER_SCRIPT})
 
 set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
 set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)

Reply via email to