Skip to content

Commit 735a022

Browse files
committed
examples/sotest: fix xxd symbol name mismatch in CMake ROMFS generation
xxd -i derives the generated array/length identifier names from the exact path string it's given. The CMake build passed the absolute ${SOTEST_ROMFS_IMG} path to xxd, so every non-alphanumeric character in the build directory path (e.g. every '/') got folded into the symbol name instead of producing plain 'sotest_romfs_img'/ 'sotest_romfs_img_len' - the names sotest_main.c actually declares extern and links against. This built fine with the Makefile build (which already only ever passes xxd a bare relative filename) but failed to link on any CMake-built configuration with CONFIG_EXAMPLES_SOTEST_BUILTINFS enabled, e.g.: undefined reference to `sotest_romfs_img_len' undefined reference to `sotest_romfs_img' Fix by extracting just the bare filename (get_filename_component ... NAME) and running xxd with WORKING_DIRECTORY set to CMAKE_CURRENT_BINARY_DIR, matching what the Makefile path already does correctly. Reported-by: Alan (CI failure on Linux arm64 qemu-armv8a/sotest) Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
1 parent 40329b7 commit 735a022

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

examples/sotest/main/CMakeLists.txt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,22 @@ if(CONFIG_EXAMPLES_SOTEST)
9191
DEPENDS ${SOTEST_ROMFS_DEPS}
9292
VERBATIM)
9393

94+
get_filename_component(SOTEST_ROMFS_IMG_NAME ${SOTEST_ROMFS_IMG} NAME)
95+
96+
# xxd -i derives the generated array/length symbol names from the exact path
97+
# it is given - sotest_main.c declares them as plain
98+
# "sotest_romfs_img"/"sotest_romfs_img_len", so xxd must be run against just
99+
# the bare filename (via WORKING_DIRECTORY) rather than the absolute
100+
# ${SOTEST_ROMFS_IMG} path, or every non- alphanumeric character in that
101+
# path (e.g. every "/" in the build directory) gets folded into the symbol
102+
# name instead, leaving the names sotest_main.c expects undefined at link
103+
# time.
104+
94105
add_custom_command(
95106
OUTPUT ${SOTEST_ROMFS_SRC}
96-
COMMAND xxd -i ${SOTEST_ROMFS_IMG} > ${SOTEST_ROMFS_SRC}
97-
DEPENDS ${SOTEST_ROMFS_IMG})
107+
COMMAND xxd -i ${SOTEST_ROMFS_IMG_NAME} > ${SOTEST_ROMFS_SRC}
108+
DEPENDS ${SOTEST_ROMFS_IMG}
109+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
98110

99111
set_source_files_properties(${SOTEST_ROMFS_SRC} PROPERTIES GENERATED TRUE)
100112

0 commit comments

Comments
 (0)