Skip to content

Commit 9a2e3a7

Browse files
xzhangxaanakryiko
authored andcommitted
Fix FindBpfObject.cmake bpf object header search setup
Quote of `CLANG_SYSTEM_INCLUDES` should be removed for `add_custom_command`, otherwise all the options in this variable will be treated as a single string and it causes header searching paths not correctly set: ``` [ 56%] [clang] Building BPF object: minimal In file included from /home/debian/projects/libbpf-bootstrap/examples/c/minimal.bpf.c:3: In file included from /usr/include/linux/bpf.h:11: /usr/include/linux/types.h:5:10: fatal error: 'asm/types.h' file not found ^~~~~~~~~~~~~ 1 error generated. make[2]: *** [CMakeFiles/minimal.dir/build.make:78: minimal.bpf.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:288: CMakeFiles/minimal.dir/all] Error 2 make: *** [Makefile:91: all] Error 2 ``` Signed-off-by: Xin Zhang <[email protected]>
1 parent 8e37500 commit 9a2e3a7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tools/cmake/FindBpfObject.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ execute_process(
133133
RESULT_VARIABLE CLANG_SYSTEM_INCLUDES_result
134134
OUTPUT_STRIP_TRAILING_WHITESPACE)
135135
if(${CLANG_SYSTEM_INCLUDES_result} EQUAL 0)
136-
string(REPLACE "\n" " " CLANG_SYSTEM_INCLUDES ${CLANG_SYSTEM_INCLUDES_output})
136+
separate_arguments(CLANG_SYSTEM_INCLUDES UNIX_COMMAND ${CLANG_SYSTEM_INCLUDES_output})
137137
message(STATUS "BPF system include flags: ${CLANG_SYSTEM_INCLUDES}")
138138
else()
139139
message(FATAL_ERROR "Failed to determine BPF system includes: ${CLANG_SYSTEM_INCLUDES_error}")
@@ -165,6 +165,7 @@ macro(bpf_object name input)
165165
COMMAND ${BPFOBJECT_CLANG_EXE} -g -O2 -target bpf -D__TARGET_ARCH_${ARCH}
166166
${CLANG_SYSTEM_INCLUDES} -I${GENERATED_VMLINUX_DIR}
167167
-isystem ${LIBBPF_INCLUDE_DIRS} -c ${BPF_C_FILE} -o ${BPF_O_FILE}
168+
COMMAND_EXPAND_LISTS
168169
VERBATIM
169170
DEPENDS ${BPF_C_FILE}
170171
COMMENT "[clang] Building BPF object: ${name}")

0 commit comments

Comments
 (0)