Re: [PATCH v2] tools lib traceevent: Robustify do_generate_dynamic_list_file
From: Arnaldo Carvalho de Melo
Date: Wed Feb 08 2017 - 07:45:10 EST
Em Tue, Feb 07, 2017 at 09:28:40PM -0800, David Carrillo-Cisneros escreveu:
> v2: Accept "W" and "w" symbol options.
>
> The dynamic-list-file used to export dynamic symbols introduced in
>
> commit e3d09ec8126f ("tools lib traceevent: Export dynamic symbols
> used by traceevent plugins")
>
> is generated without any sort of error checking.
>
> I experienced problems due to an old version of nm (v 0.158) that outputs
> in a format distinct from the assumed by the script.
>
> Robustify the built of dynamic symbol list by enforcing that the second
> column of $(NM) -u <files> is either "U" (Undefined), "W" or "w" (undefined
> weak), which are the possible outputs from non-ancient $(NM) versions.
> Print an error if format is unexpected.
The problem persists, now with a slightly different message, including
your latest effort at weak symbols, that looked unrelated at first:
GEN /tmp/build/perf/pmu-events/pmu-events.c
/bin/sh: 1: [: U W w: unexpected operator
Either missing one of [ /tmp/build/perf/plugin_jbd2.so /tmp/build/perf/plugin_hrtimer.so /tmp/build/perf/plugin_kmem.so /tmp/build/perf/plugin_kvm.so /tmp/build/perf/plugin_mac80211.so /tmp/build/perf/plugin_sched_switch.so /tmp/build/perf/plugin_function.so /tmp/build/perf/plugin_xen.so /tmp/build/perf/plugin_scsi.so /tmp/build/perf/plugin_cfg80211.so] or bad version of nm
CC /tmp/build/perf/ui/gtk/hists.o
CC /tmp/build/perf/util/symbol.o
/usr/bin/ld: cannot open linker script file /tmp/build/perf/libtraceevent-dynamic-list: No such file or directory
collect2: error: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
cp: cannot stat '/tmp/build/perf/python_ext_build/lib/perf.so': No such file or directory
Makefile.perf:381: recipe for target '/tmp/build/perf/python/perf.so' failed
make[2]: *** [/tmp/build/perf/python/perf.so] Error 1
make[2]: *** Waiting for unfinished jobs....
CC /tmp/build/perf/arch/common.o
perfbuilder@341e71da5019:/git/linux$ cat /etc/os-release
NAME="Ubuntu"
VERSION="16.10 (Yakkety Yak)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.10"
VERSION_ID="16.10"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="http://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=yakkety
UBUNTU_CODENAME=yakkety
perfbuilder@341e71da5019:/git/linux$ apt-cache show binutils
Package: binutils
Priority: optional
Section: devel
Installed-Size: 13828
Maintainer: Ubuntu Core developers <ubuntu-devel-discuss@xxxxxxxxxxxxxxxx>
Original-Maintainer: Matthias Klose <doko@xxxxxxxxxx>
Architecture: amd64
Version: 2.27-8ubuntu2
Replaces: binutils-gold (<< 2.20.51.20100415), binutils-mingw-w64-i686 (<< 2.23.52.20130612-1+3), binutils-mingw-w64-x86-64 (<< 2.23.52.20130612-1+3)
Provides: binutils-gold, elf-binutils
Depends: libc6 (>= 2.14), zlib1g (>= 1:1.2.0)
Suggests: binutils-doc (>= 2.27-8ubuntu2)
Conflicts: binutils-gold (<< 2.20.51.20100415), binutils-mingw-w64-i686 (<< 2.23.52.20130612-1+3), binutils-mingw-w64-x86-64 (<< 2.23.52.20130612-1+3), binutils-multiarch (<< 2.27-8), elf-binutils, gas, modutils (<< 2.4.19-1)
Breaks: binutils-mingw-w64-i686 (<< 2.23.52.20130612-1+3), binutils-mingw-w64-x86-64 (<< 2.23.52.20130612-1+3), hardening-wrapper (<< 2.8+nmu3)
Filename: pool/main/b/binutils/binutils_2.27-8ubuntu2_amd64.deb
Size: 2416388
MD5sum: c90cc5eef9d5bf00d1de0f1c8cf98a06
SHA1: 9b7a3cb2b140f0d6903888724efe93427382fdb0
SHA256: b7bbbadfebc615e74bf2d332a581f059a453038685548919d6db230b9732febd
Description: GNU assembler, linker and binary utilities
Description-md5: fde49b4cfeaad346a6e094f973da28d7
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Build-Essential: yes
Origin: Ubuntu
Supported: 9m
Task: ubuntu-desktop, ubuntu-usb, kubuntu-desktop, kubuntu-full, edubuntu-desktop, edubuntu-usb, xubuntu-core, xubuntu-desktop, mythbuntu-frontend, mythbuntu-desktop, mythbuntu-backend-slave, mythbuntu-backend-master, mythbuntu-backend-master, ubuntustudio-desktop-core, ubuntustudio-desktop, ubuntu-gnome-desktop, ubuntu-touch, ubuntukylin-desktop, ubuntu-mate-core, ubuntu-mate-desktop
perfbuilder@341e71da5019:/git/linux$
> Signed-off-by: David Carrillo-Cisneros <davidcc@xxxxxxxxxx>
> ---
> tools/lib/traceevent/Makefile | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile
> index 2616c66e10c1..a7046ec01a5b 100644
> --- a/tools/lib/traceevent/Makefile
> +++ b/tools/lib/traceevent/Makefile
> @@ -257,10 +257,16 @@ define do_install_plugins
> endef
>
> define do_generate_dynamic_list_file
> - (echo '{'; \
> - $(NM) -u -D $1 | awk 'NF>1 {print "\t"$$2";"}' | sort -u; \
> - echo '};'; \
> - ) > $2
> + symbol_type=`$(NM) -u -D $1 | awk 'NF>1 {print $$1}' | \
> + xargs echo "U W w" | tr ' ' '\n' | sort -u | xargs echo`;\
> + if [ "$$symbol_type" == "U W w" ];then \
> + (echo '{'; \
> + $(NM) -u -D $1 | awk 'NF>1 {print "\t"$$2";"}' | sort -u;\
> + echo '};'; \
> + ) > $2; \
> + else \
> + (echo Either missing one of [$1] or bad version of $(NM)) 1>&2;\
> + fi
> endef
>
> install_lib: all_cmd install_plugins
> --
> 2.11.0.483.g087da7b7c-goog