From ffe4d100e13fdecd16c4c4731cea2a9407b9d96a Mon Sep 17 00:00:00 2001 From: Raphael Campos Date: Fri, 12 Jul 2024 15:23:22 -0500 Subject: [PATCH] fix(build): include libbpf during libbpfgo compilation An issue appears when we try to compile libbpfgo on an older kernel that doesn't have the XDP_FLAGS_REPLACE defined in /usr/include/linux/if_link.h. To overcome this, it is necessary to include the directory of libbpf under 3rdparty during the compilation, since install_uapi_headers doesn't install if_link.h. --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b1bae250..78872cc0 100644 --- a/Makefile +++ b/Makefile @@ -24,6 +24,7 @@ ARCH ?= $(shell uname -m | sed 's/x86_64/amd64/g; s/aarch64/arm64/g') # libbpf LIBBPF_SRC = $(abspath ./libbpf/src) +LIBBPF_INCLUDE = $(abspath ./libbpf/include/uapi) LIBBPF_OBJ = $(abspath ./$(OUTPUT)/libbpf.a) LIBBPF_OBJDIR = $(abspath ./$(OUTPUT)/libbpf) LIBBPF_DESTDIR = $(abspath ./$(OUTPUT)) @@ -33,7 +34,7 @@ LDFLAGS = # golang -CGO_CFLAGS_STATIC = "-I$(abspath $(OUTPUT))" +CGO_CFLAGS_STATIC = "-I$(abspath $(OUTPUT)) -I$(LIBBPF_INCLUDE)" CGO_LDFLAGS_STATIC = "$(shell PKG_CONFIG_PATH=$(LIBBPF_OBJDIR) $(PKGCONFIG) --static --libs libbpf)" CGO_EXTLDFLAGS_STATIC = '-w -extldflags "-static"'