Skip to content

Commit a3720e9

Browse files
captain5050acmel
authored andcommitted
perf build: Fix LIBTRACEEVENT_DYNAMIC
The tools/lib includes fixes break LIBTRACEVENT_DYNAMIC as the makefile erroneously had dependencies on building libtraceevent even when not linking with it. This change fixes the issues with LIBTRACEEVENT_DYNAMIC by making the built files optional. Signed-off-by: Ian Rogers <irogers@google.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Masahiro Yamada <masahiroy@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Nick Desaulniers <ndesaulniers@google.com> Cc: Nicolas Schier <nicolas@fjasle.eu> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: bpf@vger.kernel.org Link: http://lore.kernel.org/lkml/20221116224631.207631-1-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 0b77fe4 commit a3720e9

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

tools/perf/Makefile.perf

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,10 @@ sub-make: fixdep
242242
else # force_fixdep
243243

244244
LIBAPI_DIR = $(srctree)/tools/lib/api/
245+
ifndef LIBTRACEEVENT_DYNAMIC
245246
LIBTRACEEVENT_DIR = $(srctree)/tools/lib/traceevent/
246247
LIBTRACEEVENT_PLUGINS_DIR = $(LIBTRACEEVENT_DIR)/plugins
248+
endif
247249
LIBBPF_DIR = $(srctree)/tools/lib/bpf/
248250
LIBSUBCMD_DIR = $(srctree)/tools/lib/subcmd/
249251
LIBSYMBOL_DIR = $(srctree)/tools/lib/symbol/
@@ -293,6 +295,7 @@ SCRIPT_SH += perf-iostat.sh
293295
grep-libs = $(filter -l%,$(1))
294296
strip-libs = $(filter-out -l%,$(1))
295297

298+
ifndef LIBTRACEEVENT_DYNAMIC
296299
ifneq ($(OUTPUT),)
297300
LIBTRACEEVENT_OUTPUT = $(abspath $(OUTPUT))/libtraceevent
298301
else
@@ -306,13 +309,16 @@ LIBTRACEEVENT = $(LIBTRACEEVENT_OUTPUT)/libtraceevent.a
306309
export LIBTRACEEVENT
307310
LIBTRACEEVENT_DYNAMIC_LIST = $(LIBTRACEEVENT_PLUGINS_OUTPUT)/libtraceevent-dynamic-list
308311
CFLAGS += -I$(LIBTRACEEVENT_OUTPUT)/include
309-
310312
#
311313
# The static build has no dynsym table, so this does not work for
312314
# static build. Looks like linker starts to scream about that now
313315
# (in Fedora 26) so we need to switch it off for static build.
314316
DYNAMIC_LIST_LDFLAGS = -Xlinker --dynamic-list=$(LIBTRACEEVENT_DYNAMIC_LIST)
315317
LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS = $(if $(findstring -static,$(LDFLAGS)),,$(DYNAMIC_LIST_LDFLAGS))
318+
else
319+
LIBTRACEEVENT_DYNAMIC_LIST =
320+
LIBTRACEEVENT_DYNAMIC_LIST_LDFLAGS =
321+
endif
316322

317323
ifneq ($(OUTPUT),)
318324
LIBAPI_OUTPUT = $(abspath $(OUTPUT))/libapi
@@ -375,7 +381,11 @@ export PYTHON_EXTBUILD_LIB PYTHON_EXTBUILD_TMP
375381
python-clean := $(call QUIET_CLEAN, python) $(RM) -r $(PYTHON_EXTBUILD) $(OUTPUT)python/perf*.so
376382

377383
PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources)
384+
ifndef LIBTRACEEVENT_DYNAMIC
378385
PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py $(LIBTRACEEVENT) $(LIBAPI)
386+
else
387+
PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py $(LIBAPI)
388+
endif
379389

380390
SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH))
381391

@@ -785,9 +795,12 @@ prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders $(drm_ioc
785795
$(LIBPERF) \
786796
$(LIBSUBCMD) \
787797
$(LIBSYMBOL) \
788-
$(LIBTRACEEVENT) \
789798
bpf-skel
790799

800+
ifndef LIBTRACEEVENT_DYNAMIC
801+
prepare: $(LIBTRACEEVENT)
802+
endif
803+
791804
$(OUTPUT)%.o: %.c prepare FORCE
792805
$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
793806

@@ -843,6 +856,7 @@ endif
843856

844857
$(patsubst perf-%,%.o,$(PROGRAMS)): $(wildcard */*.h)
845858

859+
ifndef LIBTRACEEVENT_DYNAMIC
846860
LIBTRACEEVENT_FLAGS += plugin_dir=$(plugindir_SQ) 'EXTRA_CFLAGS=$(EXTRA_CFLAGS)' 'LDFLAGS=$(filter-out -static,$(LDFLAGS))'
847861

848862
$(LIBTRACEEVENT): FORCE | $(LIBTRACEEVENT_OUTPUT)
@@ -872,6 +886,7 @@ install-traceevent-plugins: libtraceevent_plugins
872886
$(Q)$(MAKE) -C $(LIBTRACEEVENT_PLUGINS_DIR) O=$(LIBTRACEEVENT_PLUGINS_OUTPUT) \
873887
DESTDIR=$(LIBTRACEEVENT_PLUGINS_DESTDIR) prefix= \
874888
$(LIBTRACEEVENT_FLAGS) install
889+
endif
875890

876891
$(LIBAPI): FORCE | $(LIBAPI_OUTPUT)
877892
$(Q)$(MAKE) -C $(LIBAPI_DIR) O=$(LIBAPI_OUTPUT) \
@@ -1152,7 +1167,7 @@ endif # BUILD_BPF_SKEL
11521167
bpf-skel-clean:
11531168
$(call QUIET_CLEAN, bpf-skel) $(RM) -r $(SKEL_TMP_OUT) $(SKELETONS)
11541169

1155-
clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBSYMBOL)-clean $(LIBPERF)-clean fixdep-clean python-clean bpf-skel-clean tests-coresight-targets-clean libtraceevent_plugins-clean
1170+
clean:: $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBSYMBOL)-clean $(LIBPERF)-clean fixdep-clean python-clean bpf-skel-clean tests-coresight-targets-clean
11561171
$(call QUIET_CLEAN, core-objs) $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive $(OUTPUT)perf-iostat $(LANG_BINDINGS)
11571172
$(Q)find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
11581173
$(Q)$(RM) $(OUTPUT).config-detected
@@ -1192,6 +1207,10 @@ clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clea
11921207
$(call QUIET_CLEAN, Documentation) \
11931208
$(MAKE) -C $(DOC_DIR) O=$(OUTPUT) clean >/dev/null
11941209

1210+
ifndef LIBTRACEEVENT_DYNAMIC
1211+
clean:: $(LIBTRACEEVENT)-clean libtraceevent_plugins-clean
1212+
endif
1213+
11951214
#
11961215
# To provide FEATURE-DUMP into $(FEATURE_DUMP_COPY)
11971216
# file if defined, with no further action.

tools/perf/util/setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ def finalize_options(self):
7777
include_dirs = ['util/include'],
7878
libraries = extra_libraries,
7979
extra_compile_args = cflags,
80-
extra_objects = [libtraceevent, libapikfs, libperf],
80+
extra_objects = [ x for x in [libtraceevent, libapikfs, libperf]
81+
if x is not None],
8182
)
8283

8384
setup(name='perf',

0 commit comments

Comments
 (0)