Skip to content

Commit f335417

Browse files
committed
Fix native builds on Rocky Linux and Azur
1 parent f2b3207 commit f335417

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

‎CMakeLists.txt‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,18 @@ execute_process(
8080
OUTPUT_VARIABLE TARGET_MULTIARCH
8181
OUTPUT_STRIP_TRAILING_WHITESPACE
8282
RESULT_VARIABLE TARGET_MULTIARCH_RESULT
83+
ERROR_QUIET
8384
)
84-
if(NOT TARGET_MULTIARCH_RESULT EQUAL 0 OR NOT TARGET_MULTIARCH)
85-
message(FATAL_ERROR "Failed to determine the target multiarch tuple")
85+
# Debian-based toolchains use a multiarch include directory. Native RPM-based
86+
# toolchains may return an empty tuple and use /usr/include directly instead.
87+
# Keep this nonempty because the eBPF compile command passes it to -isystem.
88+
set(TARGET_MULTIARCH_INCLUDE "/usr/include")
89+
if(TARGET_MULTIARCH_RESULT EQUAL 0 AND TARGET_MULTIARCH AND
90+
IS_DIRECTORY "/usr/include/${TARGET_MULTIARCH}")
91+
set(TARGET_MULTIARCH_INCLUDE "/usr/include/${TARGET_MULTIARCH}")
92+
elseif(CMAKE_CROSSCOMPILING)
93+
message(FATAL_ERROR
94+
"Failed to determine the target multiarch include directory for cross-compilation")
8695
endif()
8796
execute_process(
8897
COMMAND "${CMAKE_C_COMPILER}" -print-file-name=include
@@ -95,7 +104,6 @@ if(NOT TARGET_COMPILER_INCLUDE_RESULT EQUAL 0 OR
95104
TARGET_COMPILER_INCLUDE STREQUAL "include")
96105
message(FATAL_ERROR "Failed to determine the target compiler include directory")
97106
endif()
98-
set(TARGET_MULTIARCH_INCLUDE "/usr/include/${TARGET_MULTIARCH}")
99107

100108
set(SYSINTERNALS_EBPF_ROOT "/opt/sysinternalsEBPF" CACHE PATH
101109
"Path containing the target SysinternalsEBPF eBPF resources")

0 commit comments

Comments
 (0)