bcc/libbpf-tools-Allow-to-use-different-cflags-for-bpf-t.patch
Jerome Marchand a7f5f38c0d Rebase to the latest version
Rebase bcc to v0.24 and misc fixes:
- Fix cmake build
- Add explicit Requires: bcc for bcc-tools
- Remove deprecated python_provide macro

Resolves #2023581

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-04-19 11:44:11 +02:00

49 lines
2.2 KiB
Diff

From c353d172e34f93eb281b679ee6ab3e039db0f420 Mon Sep 17 00:00:00 2001
From: Jerome Marchand <jmarchan@redhat.com>
Date: Tue, 15 Mar 2022 17:59:24 +0100
Subject: [PATCH] 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 faa26139..aba19e00 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/')
@@ -107,7 +108,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