Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpftune-git: Rework PKGBUILD #434

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions bpftune-git/.SRCINFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pkgbase = bpftune-git
pkgdesc = BPF/tracing tools for auto-tuning Linux
pkgver = r464.f2b5ba7
pkgver = r545.870d466
pkgrel = 1
url = https://github.com/oracle-samples/bpftune
arch = x86_64
Expand All @@ -17,9 +17,9 @@ pkgbase = bpftune-git
provides = bpftune
conflicts = bpftune
options = strip
source = git+https://github.com/oracle-samples/bpftune
source = fix-makefile.patch
source = git+https://github.com/oracle/bpftune
source = makefile-tweaks.patch
sha256sums = SKIP
sha256sums = e565afc2bc7bda439b49a73c5bc9719662684ee06d3bababcc2a7496b4723882
sha256sums = 009a8a03d2b8fee5b06a4cb264d4c2966472e9a512af9a7cd91364cb0c2e11e8

pkgname = bpftune-git
28 changes: 9 additions & 19 deletions bpftune-git/PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
# Maintainer: Kirill Fries-Raevskiy <[email protected]>
_pkgbase="bpftune"
pkgname="$_pkgbase-git"
pkgver=r464.f2b5ba7
pkgver=r545.870d466
pkgrel=1
pkgdesc="BPF/tracing tools for auto-tuning Linux"
arch=("x86_64")
url="https://github.com/oracle-samples/bpftune"
license=('GPLv2 WITH Linux-syscall-note')
#groups=()
depends=("libbpf" "libnl" "libcap")
makedepends=('git' 'bpf' 'clang' 'llvm' 'llvm-libs' 'python-docutils')
provides=("$_pkgbase")
conflicts=("$_pkgbase")
#replaces=()
#backup=()
options=('strip')
#install=
source=('git+https://github.com/oracle-samples/bpftune'
'fix-makefile.patch')
#noextract=()
source=('git+https://github.com/oracle/bpftune'
'makefile-tweaks.patch')
sha256sums=('SKIP'
'e565afc2bc7bda439b49a73c5bc9719662684ee06d3bababcc2a7496b4723882')

CC=clang
'009a8a03d2b8fee5b06a4cb264d4c2966472e9a512af9a7cd91364cb0c2e11e8')

pkgver() {
cd "$_pkgbase"
Expand All @@ -31,23 +24,20 @@ pkgver() {

prepare() {
cd "$srcdir/$_pkgbase"
patch -Np1 < ../fix-makefile.patch
sed -i 's/\/lib64/\/lib/' include/bpftune/libbpftune.h
sed -i 's/\/lib64/\/lib/g' src/Makefile
msg2 "Remove native march and use O3 flag"
patch -Np1 < ../makefile-tweaks.patch
sed -i 's/\/sbin/\/bin/g' src/Makefile
sed -i 's/\/sbin/\/bin/g' src/bpftune.service

}

build() {
cd "$srcdir/$_pkgbase"
export CFLAGS="-march=x86-64 -mtune=generic"
export CXXLAGS="-march=x86-64 -mtune=generic"
make -j1 || true
make
export CC="clang"
make libdir=lib
}

package() {
cd "$srcdir/$_pkgbase"
make DESTDIR="$pkgdir" install
make DESTDIR="$pkgdir" libdir=lib install
}
38 changes: 0 additions & 38 deletions bpftune-git/fix-makefile.patch

This file was deleted.

113 changes: 113 additions & 0 deletions bpftune-git/makefile-tweaks.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
From 7bc3e12a172645e595ea87eda78b5d62c19235c4 Mon Sep 17 00:00:00 2001
From: Eric Naim <[email protected]>
Date: Thu, 21 Nov 2024 11:20:06 +0800
Subject: [PATCH] Makefile: Remove native march and use O3 flag

Signed-off-by: Eric Naim <[email protected]>
---
sample_tuner/Makefile | 10 +++++-----
src/Makefile | 12 ++++++------
test/strategy/Makefile | 2 +-
3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/sample_tuner/Makefile b/sample_tuner/Makefile
index 2003543..5a8d824 100644
--- a/sample_tuner/Makefile
+++ b/sample_tuner/Makefile
@@ -37,7 +37,7 @@ installprefix = $(DESTDIR)/$(prefix)

INSTALLPATH = $(installprefix)

-CFLAGS = -fPIC -Wall -Wextra -march=native -g -I../include -std=c99
+CFLAGS = -fPIC -Wall -Wextra -O3 -g -I../include -std=c99

CFLAGS += -DBPFTUNE_VERSION='"$(BPFTUNE_VERSION)"' $(INCLUDES)

@@ -69,7 +69,7 @@ BPF_SKELS = $(patsubst %,%.skel.h,$(TUNERS))
.PHONY: clean

all: $(TUNER_LIBS)
-
+
clean:
$(Q)$(RM) *.o *.d *.so*
$(Q)$(RM) *.skel*.h
@@ -88,12 +88,12 @@ $(TUNER_LIBS): $(BPF_SKELS) $(TUNER_OBJS)
$(QUIET_GEN)$(BPFTOOL) gen skeleton $< > $@

$(BPF_OBJS): $(patsubst %.o,%.c,$(BPF_OBJS)) ../include/bpftune/bpftune.bpf.h
- $(CLANG) -g -D__TARGET_ARCH_$(SRCARCH) -O2 -target bpf \
+ $(CLANG) -g -D__TARGET_ARCH_$(SRCARCH) -O3 -target bpf \
$(INCLUDES) -c $(patsubst %.o,%.c,$(@)) -o $(@);
- $(CLANG) -g -D__TARGET_ARCH_$(SRCARCH) -DBPFTUNE_LEGACY -O2 -target bpf \
+ $(CLANG) -g -D__TARGET_ARCH_$(SRCARCH) -DBPFTUNE_LEGACY -O3 -target bpf \
$(INCLUDES) -c $(patsubst %.o,%.c,$(@)) \
-o $(patsubst %.o,%.legacy.o,$(@));
- $(CLANG) -g -D__TARGET_ARCH_$(SRCARCH) -DBPFTUNE_NOBTF -DBPFTUNE_LEGACY -O2 -target bpf \
+ $(CLANG) -g -D__TARGET_ARCH_$(SRCARCH) -DBPFTUNE_NOBTF -DBPFTUNE_LEGACY -O3 -target bpf \
$(INCLUDES) -c $(patsubst %.o,%.c,$(@)) \
-o $(patsubst %.o,%.nobtf.o,$(@));

diff --git a/src/Makefile b/src/Makefile
index 7add159..c33faa0 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -56,7 +56,7 @@ endif
VERSION = 0.1.3
VERSION_SCRIPT := libbpftune.map

-CFLAGS = -fPIC -Wall -Wextra -g -I../include -std=c99
+CFLAGS = -fPIC -Wall -Wextra -O3 -g -I../include -std=c99

CFLAGS += -DBPFTUNE_VERSION='"$(BPFTUNE_VERSION)"' \
-DBPFTUNER_PREFIX_DIR='"$(prefix)"' \
@@ -75,7 +75,7 @@ VMLINUX_BTF_PATH := $(or $(VMLINUX_BTF),$(firstword \

OPATH :=
ifeq ($(SANITIZE),1)
-CFLAGS += -fsanitize=address
+CFLAGS += -fsanitize=address
OPATH := .sanitize/
endif

@@ -174,20 +174,20 @@ $(OPATH)bpftune.o: $(OPATH)libbpftune.so
# check if GCC_BPF flag is set, otherwise use CLANG
ifeq ($(GCC_BPF),)
$(BPF_OBJS): $(patsubst %.o,%.c,$(BPF_OBJS)) ../include/bpftune/bpftune.bpf.h
- $(CLANG) $(BPF_CFLAGS) -D__TARGET_ARCH_$(SRCARCH) -O2 -target bpf \
+ $(CLANG) $(BPF_CFLAGS) -D__TARGET_ARCH_$(SRCARCH) -O3 -target bpf \
$(INCLUDES) -c $(patsubst %.o,%.c,$(@)) -o $(@)

$(LEGACY_BPF_OBJS): $(patsubst %.legacy.o,%.c,$(LEGACY_BPF_OBJS)) ../include/bpftune/bpftune.bpf.h
- $(CLANG) $(BPF_CFLAGS) -D__TARGET_ARCH_$(SRCARCH) -DBPFTUNE_LEGACY -O2 -target bpf \
+ $(CLANG) $(BPF_CFLAGS) -D__TARGET_ARCH_$(SRCARCH) -DBPFTUNE_LEGACY -O3 -target bpf \
$(INCLUDES) -c $(patsubst %.legacy.o,%.c,$(@)) \
-o $(@)

$(NOBTF_BPF_OBJS): $(patsubst %.nobtf.o,%.c,$(NOBTF_BPF_OBJS)) ../include/bpftune/bpftune.bpf.h
- $(CLANG) $(BPF_CFLAGS) -D__TARGET_ARCH_$(SRCARCH) -DBPFTUNE_NOBTF -O2 -target bpf \
+ $(CLANG) $(BPF_CFLAGS) -D__TARGET_ARCH_$(SRCARCH) -DBPFTUNE_NOBTF -O3 -target bpf \
$(INCLUDES) -c $(patsubst %.nobtf.o,%.c,$(@)) \
-o $(@)
else
-GCC_BPF_FLAGS := -g -O2 \
+GCC_BPF_FLAGS := -g -O3 \
$(BPF_CFLAGS) -D__TARGET_ARCH_$(SRCARCH) \
-gbtf -mcpu=v3 -Wno-error=attributes \
-Wno-error=address-of-packed-member \
diff --git a/test/strategy/Makefile b/test/strategy/Makefile
index f4783bb..95c91f6 100644
--- a/test/strategy/Makefile
+++ b/test/strategy/Makefile
@@ -39,7 +39,7 @@ installprefix = $(DESTDIR)/$(prefix)

INSTALLPATH = $(installprefix)

-CFLAGS = -fPIC -Wall -Wextra -march=native -g -I../include -std=c99
+CFLAGS = -fPIC -Wall -Wextra -O3 -g -I../include -std=c99

CFLAGS += -DBPFTUNE_VERSION='"$(BPFTUNE_VERSION)"' $(INCLUDES)

--
2.47.0