Skip to content

Commit 2d747e5

Browse files
Nicolas Pitreaescolar
authored andcommitted
cmake: prohibit LTO for heap_constants.c offsets source
Commit 518d842 ("lib: heap: compute Z_HEAP_MIN_SIZE from actual struct layouts") added heap_constants.c to the offsets library, but did not add the prohibit_lto compile option that offsets.c has. When LTO is enabled, the compiler optimizes away the absolute symbols emitted by GEN_ABSOLUTE_SYM, causing them to be missing from the generated offsets.h. This breaks builds that use Z_HEAP_MIN_SIZE (via kernel/mempool.c) with LTO-enabled configurations. Fix by adding heap_constants.c to the same set_source_files_properties call that disables LTO for offsets.c. Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
1 parent 356f6e9 commit 2d747e5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

‎CMakeLists.txt‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,8 +1045,9 @@ target_include_directories(${OFFSETS_LIB} PRIVATE
10451045
${ARCH_DIR}/${ARCH}/include
10461046
)
10471047

1048-
# Make sure that LTO will never be enabled when compiling offsets.c
1049-
set_source_files_properties(${OFFSETS_C_PATH} PROPERTIES COMPILE_OPTIONS $<TARGET_PROPERTY:compiler,prohibit_lto>)
1048+
# Make sure that LTO will never be enabled when compiling offsets sources
1049+
set_source_files_properties(${OFFSETS_C_PATH} ${ZEPHYR_BASE}/lib/heap/heap_constants.c
1050+
PROPERTIES COMPILE_OPTIONS $<TARGET_PROPERTY:compiler,prohibit_lto>)
10501051

10511052
target_sources(${OFFSETS_LIB} PRIVATE ${ZEPHYR_BASE}/lib/heap/heap_constants.c)
10521053

0 commit comments

Comments
 (0)