Commit 14541b1e authored by Stanislav Fomichev's avatar Stanislav Fomichev Committed by Arnaldo Carvalho de Melo

perf build: Don't unconditionally link the libbfd feature test to -liberty and -lz

Current libbfd feature test unconditionally links against -liberty and -lz.
While it's required on some systems (e.g. opensuse), it's completely
unnecessary on the others, where only -lbdf is sufficient (debian).
This patch streamlines (and renames) the following feature checks:

feature-libbfd           - only link against -lbfd (debian),
                           see commit 2cf90407 ("perf tools: Fix bfd
			   dependency libraries detection")
feature-libbfd-liberty   - link against -lbfd and -liberty
feature-libbfd-liberty-z - link against -lbfd, -liberty and -lz (opensuse),
                           see commit 280e7c48 ("perf tools: fix BFD
			   detection on opensuse")

(feature-liberty{,-z} were renamed to feature-libbfd-liberty{,z}
for clarity)

The main motivation is to fix this feature test for bpftool which is
currently broken on debian (libbfd feature shows OFF, but we still
unconditionally link against -lbfd and it works).

Tested on debian with only -lbfd installed (without -liberty); I'd
appreciate if somebody on the other systems can test this new detection
method.
Signed-off-by: default avatarStanislav Fomichev <sdf@google.com>
Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/4dfc634cfcfb236883971b5107cf3c28ec8a31be.1542328222.git.sdf@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 5ce29d52
...@@ -82,8 +82,8 @@ FEATURE_TESTS_EXTRA := \ ...@@ -82,8 +82,8 @@ FEATURE_TESTS_EXTRA := \
cplus-demangle \ cplus-demangle \
hello \ hello \
libbabeltrace \ libbabeltrace \
liberty \ libbfd-liberty \
liberty-z \ libbfd-liberty-z \
libunwind-debug-frame \ libunwind-debug-frame \
libunwind-debug-frame-arm \ libunwind-debug-frame-arm \
libunwind-debug-frame-aarch64 \ libunwind-debug-frame-aarch64 \
......
...@@ -17,8 +17,8 @@ FILES= \ ...@@ -17,8 +17,8 @@ FILES= \
test-libbfd.bin \ test-libbfd.bin \
test-disassembler-four-args.bin \ test-disassembler-four-args.bin \
test-reallocarray.bin \ test-reallocarray.bin \
test-liberty.bin \ test-libbfd-liberty.bin \
test-liberty-z.bin \ test-libbfd-liberty-z.bin \
test-cplus-demangle.bin \ test-cplus-demangle.bin \
test-libelf.bin \ test-libelf.bin \
test-libelf-getphdrnum.bin \ test-libelf-getphdrnum.bin \
...@@ -210,7 +210,7 @@ $(OUTPUT)test-libpython-version.bin: ...@@ -210,7 +210,7 @@ $(OUTPUT)test-libpython-version.bin:
$(BUILD) $(BUILD)
$(OUTPUT)test-libbfd.bin: $(OUTPUT)test-libbfd.bin:
$(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl $(BUILD) -DPACKAGE='"perf"' -lbfd -ldl
$(OUTPUT)test-disassembler-four-args.bin: $(OUTPUT)test-disassembler-four-args.bin:
$(BUILD) -DPACKAGE='"perf"' -lbfd -lopcodes $(BUILD) -DPACKAGE='"perf"' -lbfd -lopcodes
...@@ -218,10 +218,10 @@ $(OUTPUT)test-disassembler-four-args.bin: ...@@ -218,10 +218,10 @@ $(OUTPUT)test-disassembler-four-args.bin:
$(OUTPUT)test-reallocarray.bin: $(OUTPUT)test-reallocarray.bin:
$(BUILD) $(BUILD)
$(OUTPUT)test-liberty.bin: $(OUTPUT)test-libbfd-liberty.bin:
$(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty
$(OUTPUT)test-liberty-z.bin: $(OUTPUT)test-libbfd-liberty-z.bin:
$(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz $(CC) $(CFLAGS) -Wall -Werror -o $@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz
$(OUTPUT)test-cplus-demangle.bin: $(OUTPUT)test-cplus-demangle.bin:
......
...@@ -702,18 +702,20 @@ endif ...@@ -702,18 +702,20 @@ endif
ifeq ($(feature-libbfd), 1) ifeq ($(feature-libbfd), 1)
EXTLIBS += -lbfd EXTLIBS += -lbfd
else
# we are on a system that requires -liberty and (maybe) -lz
# to link against -lbfd; test each case individually here
# call all detections now so we get correct # call all detections now so we get correct
# status in VF output # status in VF output
$(call feature_check,liberty) $(call feature_check,libbfd-liberty)
$(call feature_check,liberty-z) $(call feature_check,libbfd-liberty-z)
$(call feature_check,cplus-demangle)
ifeq ($(feature-liberty), 1) ifeq ($(feature-libbfd-liberty), 1)
EXTLIBS += -liberty EXTLIBS += -lbfd -liberty
else else
ifeq ($(feature-liberty-z), 1) ifeq ($(feature-libbfd-liberty-z), 1)
EXTLIBS += -liberty -lz EXTLIBS += -lbfd -liberty -lz
endif endif
endif endif
endif endif
...@@ -723,24 +725,24 @@ ifdef NO_DEMANGLE ...@@ -723,24 +725,24 @@ ifdef NO_DEMANGLE
else else
ifdef HAVE_CPLUS_DEMANGLE_SUPPORT ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
EXTLIBS += -liberty EXTLIBS += -liberty
CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
else else
ifneq ($(feature-libbfd), 1) ifeq ($(filter -liberty,$(EXTLIBS)),)
ifneq ($(feature-liberty), 1) $(call feature_check,cplus-demangle)
ifneq ($(feature-liberty-z), 1)
# we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT # we dont have neither HAVE_CPLUS_DEMANGLE_SUPPORT
# or any of 'bfd iberty z' trinity # or any of 'bfd iberty z' trinity
ifeq ($(feature-cplus-demangle), 1) ifeq ($(feature-cplus-demangle), 1)
EXTLIBS += -liberty EXTLIBS += -liberty
CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT else
else msg := $(warning No bfd.h/libbfd found, please install binutils-dev[el]/zlib-static/libiberty-dev to gain symbol demangling)
msg := $(warning No bfd.h/libbfd found, please install binutils-dev[el]/zlib-static/libiberty-dev to gain symbol demangling) CFLAGS += -DNO_DEMANGLE
CFLAGS += -DNO_DEMANGLE
endif
endif
endif endif
endif endif
endif endif
ifneq ($(filter -liberty,$(EXTLIBS)),)
CFLAGS += -DHAVE_CPLUS_DEMANGLE_SUPPORT
endif
endif endif
ifneq ($(filter -lbfd,$(EXTLIBS)),) ifneq ($(filter -lbfd,$(EXTLIBS)),)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment