Browse Source

cmake: only allow gold linker for posix builds

- the gold linker doesn't currently work for NuttX builds
 - NuttX skip --print-memory-usage if using the GOLD linker
 - fixes #15400
sbg
Daniel Agar 5 years ago
parent
commit
9426c68a13
  1. 12
      CMakeLists.txt
  2. 5
      platforms/nuttx/CMakeLists.txt

12
CMakeLists.txt

@ -221,14 +221,15 @@ endif() @@ -221,14 +221,15 @@ endif()
#=============================================================================
# gold linker - use if available
include(CMakeDependentOption)
CMAKE_DEPENDENT_OPTION(USE_LD_GOLD
# gold linker - use if available (posix only for now)
if(${PX4_PLATFORM} STREQUAL "posix")
include(CMakeDependentOption)
CMAKE_DEPENDENT_OPTION(USE_LD_GOLD
"Use GNU gold linker" ON
"NOT WIN32;NOT APPLE" OFF
)
)
if(USE_LD_GOLD)
if(USE_LD_GOLD)
execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
if("${LD_VERSION}" MATCHES "GNU gold")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
@ -236,6 +237,7 @@ if(USE_LD_GOLD) @@ -236,6 +237,7 @@ if(USE_LD_GOLD)
else()
set(USE_LD_GOLD OFF)
endif()
endif()
endif()
#=============================================================================

5
platforms/nuttx/CMakeLists.txt

@ -124,7 +124,6 @@ target_link_libraries(px4 PRIVATE @@ -124,7 +124,6 @@ target_link_libraries(px4 PRIVATE
-Wl,-Map=${PX4_CONFIG}.map
-Wl,--warn-common
-Wl,--gc-sections
-Wl,--print-memory-usage
-Wl,--start-group
${nuttx_libs}
@ -134,6 +133,10 @@ target_link_libraries(px4 PRIVATE @@ -134,6 +133,10 @@ target_link_libraries(px4 PRIVATE
gcc
)
if(NOT USE_LD_GOLD)
target_link_libraries(px4 PRIVATE -Wl,--print-memory-usage)
endif()
target_link_libraries(px4 PRIVATE ${module_libraries})
if (config_romfs_root)

Loading…
Cancel
Save