50 lines
2.2 KiB
Diff
50 lines
2.2 KiB
Diff
From a6a5dba23d19f6a900b0359a7390df4a6b9a42f4 Mon Sep 17 00:00:00 2001
|
|
From: Jerome Marchand <jmarchan@redhat.com>
|
|
Date: Tue, 15 Mar 2022 17:59:24 +0100
|
|
Subject: [PATCH 1/3] libbpf-tools: Allow to use different cflags for bpf
|
|
targets
|
|
|
|
commit 531b698cdc20 ("libbpf-tools: Enable compilation warnings for
|
|
BPF programs") applies CFLAGS to all targets. However, some of the c
|
|
flags typically used by distribution are not available to the bpf
|
|
target. Add a new BPFCFLAGS macro to take care of that.
|
|
|
|
Fixes the following compilation error on fedora:
|
|
|
|
BPF bashreadline.bpf.o
|
|
clang-13: warning: optimization flag '-ffat-lto-objects' is not supported [-Wignored-optimization-argument]
|
|
clang-13: warning: argument unused during compilation: '-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1' [-Wunused-command-line-argument]
|
|
clang-13: warning: argument unused during compilation: '-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1' [-Wunused-command-line-argument]
|
|
clang-13: warning: argument unused during compilation: '-fstack-clash-protection' [-Wunused-command-line-argument]
|
|
error: option 'cf-protection=return' cannot be specified on this target
|
|
error: option 'cf-protection=branch' cannot be specified on this target
|
|
2 errors generated.
|
|
---
|
|
libbpf-tools/Makefile | 3 ++-
|
|
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/libbpf-tools/Makefile b/libbpf-tools/Makefile
|
|
index 6bf1ed08..39af95ec 100644
|
|
--- a/libbpf-tools/Makefile
|
|
+++ b/libbpf-tools/Makefile
|
|
@@ -7,6 +7,7 @@ LIBBPF_SRC := $(abspath ../src/cc/libbpf/src)
|
|
LIBBPF_OBJ := $(abspath $(OUTPUT)/libbpf.a)
|
|
INCLUDES := -I$(OUTPUT) -I../src/cc/libbpf/include/uapi
|
|
CFLAGS := -g -O2 -Wall
|
|
+BPFCFLAGS := -g -O2 -Wall
|
|
INSTALL ?= install
|
|
prefix ?= /usr/local
|
|
ARCH := $(shell uname -m | sed 's/x86_64/x86/' | sed 's/aarch64/arm64/' | sed 's/ppc64le/powerpc/' | sed 's/mips.*/mips/')
|
|
@@ -106,7 +107,7 @@ $(OUTPUT)/%.skel.h: $(OUTPUT)/%.bpf.o | $(OUTPUT)
|
|
|
|
$(OUTPUT)/%.bpf.o: %.bpf.c $(LIBBPF_OBJ) $(wildcard %.h) $(ARCH)/vmlinux.h | $(OUTPUT)
|
|
$(call msg,BPF,$@)
|
|
- $(Q)$(CLANG) $(CFLAGS) -target bpf -D__TARGET_ARCH_$(ARCH) \
|
|
+ $(Q)$(CLANG) $(BPFCFLAGS) -target bpf -D__TARGET_ARCH_$(ARCH) \
|
|
-I$(ARCH)/ $(INCLUDES) -c $(filter %.c,$^) -o $@ && \
|
|
$(LLVM_STRIP) -g $@
|
|
|
|
--
|
|
2.35.1
|
|
|