openwrt/package/network/utils/xdp-tools/patches/024-lib-allow-overwriting-W-flags-via-BPF_CFLAGS.patch
Christian Marangi 5acc4f919c
xdp-tools: fix compilation wrongly using host header
Currently it's needed to have gcc-multilib on the host to correctly
compile xdp-tools. This is wrong and means that we are using host header
to compile a tool.

By some searching in how the makefile works it was discovered that
BPF_CFLAGS were not used and required to be appended to config.mk

Only one single header was added but we should include each BPF_CFLAGS
from bpf.mk. To make this some patching to bpf-header were required and
some patches to xdp-tools were required.
Also it's needed to pass the correct target to BPF_CFLAGS.

With the following changes xdp-tools can correctly compile with each
header from bpf-headers and should not use any host header.

Co-Developed-by: Andre Heider <a.heider@gmail.com>
Signed-off-by: Andre Heider <a.heider@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/11825
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
2024-05-01 19:11:34 +02:00

50 lines
1.5 KiB
Diff

From e2d8eae9477f6ba41ab75ad77202f235e34c04f7 Mon Sep 17 00:00:00 2001
From: Andre Heider <a.heider@gmail.com>
Date: Wed, 18 Jan 2023 22:30:23 +0100
Subject: [PATCH] lib: allow overwriting -W* flags via BPF_CFLAGS
The bpf header file situation is a mess, and the default warning
compiler flags may not be suitable everywhere, especially with -Werror
in the mix.
Move BPF_CFLAGS further down, so these can be overwritten by builders.
Signed-off-by: Andre Heider <a.heider@gmail.com>
---
lib/common.mk | 2 +-
lib/libxdp/Makefile | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
--- a/lib/common.mk
+++ b/lib/common.mk
@@ -108,12 +108,12 @@ $(XDP_OBJ): %.o: %.c $(KERN_USER_H) $(EX
$(QUIET_CLANG)$(CLANG) -S \
-target $(BPF_TARGET) \
-D __BPF_TRACING__ \
- $(BPF_CFLAGS) \
-Wall \
-Wno-unused-value \
-Wno-pointer-sign \
-Wno-compare-distinct-pointer-types \
-Werror \
+ $(BPF_CFLAGS) \
-O2 -emit-llvm -c -g -o ${@:.o=.ll} $<
$(QUIET_LLC)$(LLC) -march=$(BPF_TARGET) -filetype=obj -o $@ ${@:.o=.ll}
--- a/lib/libxdp/Makefile
+++ b/lib/libxdp/Makefile
@@ -139,12 +139,12 @@ $(XDP_OBJS): %.o: %.c $(BPF_HEADERS) $(L
$(QUIET_CLANG)$(CLANG) -S \
-target $(BPF_TARGET) \
-D __BPF_TRACING__ \
- $(BPF_CFLAGS) \
-Wall \
-Wno-unused-value \
-Wno-pointer-sign \
-Wno-compare-distinct-pointer-types \
-Werror \
+ $(BPF_CFLAGS) \
-O2 -emit-llvm -c -g -o ${@:.o=.ll} $<
$(QUIET_LLC)$(LLC) -march=$(BPF_TARGET) -filetype=obj -o $@ ${@:.o=.ll}