Skip to content

Commit

Permalink
fix(build): include libbpf during libbpfgo compilation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rscampos authored and vagrant committed Jul 12, 2024
1 parent 73c0323 commit ffe4d10
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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"'

Expand Down

0 comments on commit ffe4d10

Please sign in to comment.