[PATCH v2 2/2] perf build: Add libtraceevent lib64 to -L directory & rpath on 64-bit

From: Yang Jihong
Date: Mon May 13 2024 - 03:49:54 EST


For 64-bit system, libtraceevent will install these libraries into
lib64 directory, so add it to the -L directory and rpath as well.

build libtraceevent:
$ make EXTRA_CFLAGS="-O0 -g -fsanitize=address" DESTDIR=~/libtrace install

Before:
$ rm -rf /tmp/perf; mkdir /tmp/perf; make -C tools/perf O=/tmp/perf DEBUG=1 EXTRA_CFLAGS="-O0 -g -fno-omit-frame-pointer -fsanitize=address -Wno-error=unused-function" LIBTRACEEVENT_DIR=~/libtrace/usr/local 1>/dev/null
Makefile.config:1146: No alternatives command found, you need to set JDIR= to point to the root of your Java directory
Makefile.config:1196: *** ERROR: libtraceevent is missing. Please install libtraceevent-dev/libtraceevent-devel and/or set LIBTRACEEVENT_DIR or build with NO_LIBTRACEEVENT=1. Stop.
make[1]: *** [Makefile.perf:264: sub-make] Error 2
make: *** [Makefile:70: all] Error 2

After:
$ rm -rf /tmp/perf; mkdir /tmp/perf; make -C tools/perf O=/tmp/perf DEBUG=1 EXTRA_CFLAGS="-O0 -g -fno-omit-frame-pointer -fsanitize=address -Wno-error=unused-function" LIBTRACEEVENT_DIR=~/libtrace/usr/local 1>/dev/null
Makefile.config:1154: No alternatives command found, you need to set JDIR= to point to the root of your Java directory
PERF_VERSION = 6.9.0-rc5
$ echo $?
0
$ ldd /tmp/perf/perf
<SINP>
libtraceevent.so.1 => /home/yangjihong/libtrace/usr/local/lib64/libtraceevent.so.1 (0x00007f08983d5000)
<SINP>

Signed-off-by: Yang Jihong <yangjihong@xxxxxxxxxxxxx>
---
tools/perf/Makefile.config | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index a9a923358604..d632c85e6c4d 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -188,9 +188,17 @@ TRACEEVENTLIBS := -ltraceevent
ifdef LIBTRACEEVENT_DIR
LIBTRACEEVENT_CFLAGS := -I$(LIBTRACEEVENT_DIR)/include
LIBTRACEEVENT_LDFLAGS := -L$(LIBTRACEEVENT_DIR)/lib
+ # libtraceevent install libraries into lib64 on 64-bit, so add it to -L directory as well
+ ifeq (${IS_64_BIT}, 1)
+ LIBTRACEEVENT_LDFLAGS += -L$(LIBTRACEEVENT_DIR)/lib64
+ endif
# Specify rpath for asan/msan build. Generally, cross-compilation will not enable sanitizers.
ifeq ($(findstring -fsanitize=,${EXTRA_CFLAGS}),-fsanitize=)
LIBTRACEEVENT_LDFLAGS += -Wl,-rpath,$(LIBTRACEEVENT_DIR)/lib
+ # libtraceevent install libraries into lib64 on 64-bit, so add it to rpath as well
+ ifeq (${IS_64_BIT}, 1)
+ LIBTRACEEVENT_LDFLAGS += -Wl,-rpath,$(LIBTRACEEVENT_DIR)/lib64
+ endif
endif
endif
FEATURE_CHECK_CFLAGS-libtraceevent := $(LIBTRACEEVENT_CFLAGS)
--
2.25.1