Skip to content

Commit

Permalink
cmake: Offset library linking flags
Browse files Browse the repository at this point in the history
Fixes: zephyrproject-rtos#8440

This commit moves the link flag  -u_OffsetAbsSyms which is required
when linking to offset static library.

The library offset thus propagates the flags correctly during linking.
It also ensures knowledge about link flags is present where it
correctly belongs.

Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
  • Loading branch information
tejlmand committed Dec 5, 2018
1 parent 8aa8726 commit a9b9487
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -635,14 +635,23 @@ set(OFFSETS_O_PATH ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/offsets.dir/arch/${ARC
set(OFFSETS_H_PATH ${PROJECT_BINARY_DIR}/include/generated/offsets.h)

add_library( offsets STATIC ${OFFSETS_C_PATH})
target_link_libraries(offsets zephyr_interface)
target_link_libraries(offsets INTERFACE -u_OffsetAbsSyms)
add_dependencies( offsets
syscall_list_h_target
syscall_macros_h_target
driver_validation_h_target
kobj_types_h_target
)

# Kernel is a Zephyr interface dependency, which means everyone using zephyr_interface has an
# indirect dependency, which for other libraries is fine.
# However offsets does not need to link to kernel as there is no dependency.
# Instead kernel depends on generated offset.h so to avoid a non-existing circular dependency,
# offset lib only requires the compile options and include directories from zephyr_interface.
target_compile_options( offsets PRIVATE $<TARGET_PROPERTY:zephyr_interface,INTERFACE_COMPILE_OPTIONS>)
target_compile_definitions(offsets PRIVATE $<TARGET_PROPERTY:zephyr_interface,INTERFACE_COMPILE_DEFINITIONS>)
target_include_directories(offsets PRIVATE $<TARGET_PROPERTY:zephyr_interface,INTERFACE_INCLUDE_DIRECTORIES>)

add_custom_command(
OUTPUT ${OFFSETS_H_PATH}
COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/scripts/gen_offset_header.py
Expand Down Expand Up @@ -812,11 +821,9 @@ set_property(TARGET

set(zephyr_lnk
${LINKERFLAGPREFIX},-Map=${PROJECT_BINARY_DIR}/${KERNEL_MAP_NAME}
-u_OffsetAbsSyms
${LINKERFLAGPREFIX},--whole-archive
${ZEPHYR_LIBS_PROPERTY}
${LINKERFLAGPREFIX},--no-whole-archive
${OFFSETS_O_PATH}
${LIB_INCLUDE_DIR}
-L${PROJECT_BINARY_DIR}
)
Expand Down

0 comments on commit a9b9487

Please sign in to comment.