perf tools: Build fixes
Jiri Olsa
reviewercover perf tools: Build fixes
hi,
got a build error on latest Fedora 27, sending fix.
Also available in:
https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/fixes
thanks,
jirka
---
Jiri Olsa (3):
perf tools: Use shell function for perl cflags retrieval perf tools: Fix build for hardened environments
perf tools: Removing FLAGS_PYTHON_EMBED/FLAGS_PERL_EMBED variables
tools/perf/Makefile.config | 6 +++--- tools/perf/scripts/perl/Perf-Trace-Util/Build | 2 +- tools/perf/scripts/python/Perf-Trace-Util/Build | 2 +- tools/perf/util/block-range.c | 2 +- tools/perf/util/scripting-engines/Build | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-)
Jiri Olsa
reviewerPATCH 1/3 perf tools: Use shell function for perl cflags retrieval
Using the shell function for perl cflags retrieval instead of back quotes (``). Both execute shell with the command, but the latter is more explicit and seems to be the preferred way.
Also we don't have any other use of the back quotes in perf Makefiles.
--- tools/perf/Makefile.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/Makefile.config +1 -1
@@ -579,7 +579,7 @@ else PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null) PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS)) PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS)) - PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null` + PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null) FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) ifneq ($(feature-libperl), 1)
Signature · 1 line
2.13.6
Re: [PATCH 1/3] perf tools: Use shell function for perl cflags retrieval
Em Wed, Nov 08, 2017 at 11:27:37AM +0100, Jiri Olsa escreveu:
Quoted 6 lines
Using the shell function for perl cflags retrieval instead of back quotes (``). Both execute shell with the command, but the latter is more explicit and seems to be the preferred way.
Also we don't have any other use of the back quotes in perf Makefiles.
Applied
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf tools: Use shell function for perl cflags retrieval
In reply to Jiri Olsaperf tools: Use shell function for perl cflags retrieval
Commit-ID: 86f5fe01cf3ad42e99e7655dec93e0e36ef65614 Gitweb: https://git.kernel.org/tip/86f5fe01cf3ad42e99e7655dec93e0e36ef65614 Author: Jiri Olsa <[email protected]> AuthorDate: Wed, 8 Nov 2017 11:27:37 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 16 Nov 2017 14:49:52 -0300
perf tools: Use shell function for perl cflags retrieval
Using the shell function for perl CFLAGS retrieval instead of back quotes (``). Both execute shell with the command, but the latter is more explicit and seems to be the preferred way.
Also we don't have any other use of the back quotes in perf Makefiles.
--- tools/perf/Makefile.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/Makefile.config +1 -1
@@ -579,7 +579,7 @@ else PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null) PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS)) PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS)) - PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null` + PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null) FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) ifneq ($(feature-libperl), 1)
tip-bot for Jiri Olsa
merge bot[tip:perf/urgent] perf tools: Use shell function for perl cflags retrieval
In reply to Jiri Olsaperf tools: Use shell function for perl cflags retrieval
Commit-ID: 5cfee7a357f60675cae32b494bb2096d7203efd3 Gitweb: https://git.kernel.org/tip/5cfee7a357f60675cae32b494bb2096d7203efd3 Author: Jiri Olsa <[email protected]> AuthorDate: Wed, 8 Nov 2017 11:27:37 +0100 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 18 Dec 2017 11:54:08 -0300
perf tools: Use shell function for perl cflags retrieval
Using the shell function for perl CFLAGS retrieval instead of back quotes (``). Both execute shell with the command, but the latter is more explicit and seems to be the preferred way.
Also we don't have any other use of the back quotes in perf Makefiles.
--- tools/perf/Makefile.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/Makefile.config +1 -1
@@ -583,7 +583,7 @@ else PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null) PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS)) PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS)) - PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null` + PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null) FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) ifneq ($(feature-libperl), 1)
Jiri Olsa
reviewerPATCH 2/3 perf tools: Fix build for hardened environments
In reply to Jiri OlsaFrom: Jiri Olsa <[email protected]>
On Fedora systems the perl and python CFLAGS/LDFLAGS include the hardened specs from redhat-rpm-config package. We apply them only for perl/python objects, which makes them not compatible with the rest of the objects and the build fails with:
/usr/bin/ld: perf-in.o: relocation R_X86_64_32 against .rodata.str1.1' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: libperf.a(libperf-in.o): relocation R_X86_64_32S against .text' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile.perf:507: perf] Error 1
make[1]: *** [Makefile.perf:210: sub-make] Error 2
make: *** [Makefile:69: all] Error 2
Mainly it's caused by perl/python objects being compiled with:
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
which prevent the final link impossible, because it will check for 'proper' objects with following option:
-specs=/usr/lib/rpm/redhat/redhat-hardened-ld
Fixing this by using the perl/python CFLAGS/LDFLAGS options for all the objects.
--- tools/perf/Makefile.config | 2 ++ tools/perf/scripts/perl/Perf-Trace-Util/Build | 2 +- tools/perf/scripts/python/Perf-Trace-Util/Build | 2 +- tools/perf/util/block-range.c | 2 +- tools/perf/util/scripting-engines/Build | 4 ++-- 5 files changed, 7 insertions(+), 5 deletions(-)
tools/perf/Makefile.config +2 -0
@@ -587,6 +587,7 @@ else NO_LIBPERL := 1 msg := $(warning Missing perl devel files. Disabling perl scripting support, please install perl-ExtUtils-Embed/libperl-dev); else + CFLAGS += $(PERL_EMBED_CCOPTS) LDFLAGS += $(PERL_EMBED_LDFLAGS) EXTLIBS += $(PERL_EMBED_LIBADD) $(call detected,CONFIG_LIBPERL)
@@ -636,6 +637,7 @@ else $(warning $(and ,)) $(error $(and ,)) else + CFLAGS += $(PYTHON_EMBED_CCOPTS) LDFLAGS += $(PYTHON_EMBED_LDFLAGS) EXTLIBS += $(PYTHON_EMBED_LIBADD) LANG_BINDINGS += $(obj-perf)python/perf.so
tools/perf/scripts/perl/Perf-Trace-Util/Build +1 -1
@@ -1,5 +1,5 @@ libperf-y += Context.o -CFLAGS_Context.o += $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes +CFLAGS_Context.o += -Wno-redundant-decls -Wno-strict-prototypes CFLAGS_Context.o += -Wno-unused-parameter -Wno-nested-externs -Wno-undef CFLAGS_Context.o += -Wno-switch-default -Wno-shadow
tools/perf/scripts/python/Perf-Trace-Util/Build +1 -1
@@ -1,3 +1,3 @@ libperf-y += Context.o -CFLAGS_Context.o += $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs +CFLAGS_Context.o += -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs
tools/perf/util/block-range.c +1 -1
@@ -15,7 +15,7 @@ static void block_range__debug(void)*/ #if 1 struct rb_node *rb; -u64 old =0 ;/* NULL isn't executable */ +u64 old__maybe_unused =0 ;/* NULL isn't executable */ for (rb =rb_first (&block_ranges.root); rb; rb =rb_next (rb)) { struct block_range *entry = rb_entry(rb, struct block_range, node);
tools/perf/util/scripting-engines/Build +2 -2
@@ -1,6 +1,6 @@ libperf-$(CONFIG_LIBPERL) += trace-event-perl.o libperf-$(CONFIG_LIBPYTHON) += trace-event-python.o -CFLAGS_trace-event-perl.o += $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow -Wno-nested-externs -Wno-undef -Wno-switch-default +CFLAGS_trace-event-perl.o += -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow -Wno-nested-externs -Wno-undef -Wno-switch-default -CFLAGS_trace-event-python.o += $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow +CFLAGS_trace-event-python.o += -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow
Signature · 1 line
2.13.6
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 2/3] perf tools: Fix build for hardened environments
Em Wed, Nov 08, 2017 at 11:27:38AM +0100, Jiri Olsa escreveu:
Quoted 19 lines
From: Jiri Olsa <[email protected]>
On Fedora systems the perl and python CFLAGS/LDFLAGS include the hardened specs from redhat-rpm-config package. We apply them only for perl/python objects, which makes them not compatible with the rest of the objects and the build fails with:
/usr/bin/ld: perf-in.o: relocationR_X86_64_32against.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: libperf.a(libperf-in.o): relocation R_X86_64_32S against.text' can not be used when making a shared object; recompile with -fPIC/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile.perf:507: perf] Error 1
make[1]: *** [Makefile.perf:210: sub-make] Error 2
make: *** [Makefile:69: all] Error 2Mainly it's caused by perl/python objects being compiled with:
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
Quoted 7 lines
which prevent the final link impossible, because it will check for 'proper' objects with following option:
-specs=/usr/lib/rpm/redhat/redhat-hardened-ld
Fixing this by using the perl/python CFLAGS/LDFLAGS options for all the objects.
Humm, so we're basically using the hardened config only we build with PERL or PYTHON, should we use that always, i.e. ask the distro what set of flags we should use?
What other impacts this may have on using this for all of the tools? I.e. we could conceivably just remove that part from the perl/python builds and make them use what has been used for the rest of the tools instead?
- Arnaldo
Re: [PATCH 2/3] perf tools: Fix build for hardened environments
Quoted 23 lines · Arnaldo Carvalho de Melo
Em Wed, Nov 08, 2017 at 11:27:38AM +0100, Jiri Olsa escreveu:
Quoted 22 lines
From: Jiri Olsa <[email protected]>
On Fedora systems the perl and python CFLAGS/LDFLAGS include the hardened specs from redhat-rpm-config package. We apply them only for perl/python objects, which makes them not compatible with the rest of the objects and the build fails with:
/usr/bin/ld: perf-in.o: relocationR_X86_64_32against.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: libperf.a(libperf-in.o): relocation R_X86_64_32S against.text' can not be used when making a shared object; recompile with -fPIC/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile.perf:507: perf] Error 1
make[1]: *** [Makefile.perf:210: sub-make] Error 2
make: *** [Makefile:69: all] Error 2Mainly it's caused by perl/python objects being compiled with:
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
which prevent the final link impossible, because it will check for 'proper' objects with following option:
Quoted 8 lines
Quoted 4 lines
-specs=/usr/lib/rpm/redhat/redhat-hardened-ld
Fixing this by using the perl/python CFLAGS/LDFLAGS options for all the objects.
Humm, so we're basically using the hardened config only we build with PERL or PYTHON, should we use that always, i.e. ask the distro what set of flags we should use?
right, I think this needs to be detected like we do for features, since there maybe some supported gcc versions to detect
Quoted 4 lines
What other impacts this may have on using this for all of the tools? I.e. we could conceivably just remove that part from the perl/python builds and make them use what has been used for the rest of the tools instead?
hum, so those are the flags the perl/python extensions are built with
we have both perl/python extensions built in the perf for the script cmd, which creates dependencies:
[jolsa@krava perf]$ ldd ./perf |grep perl
libperl.so.5.24 => /lib64/libperl.so.5.24 (0x00007f72b33b3000)
[jolsa@krava perf]$ ldd ./perf |grep python
libpython2.7.so.1.0 => /lib64/libpython2.7.so.1.0 (0x00007f927cfe7000)
not sure we could be affected here if we remove that hardened spec option
and then we have the python module extension which is used separately of perf binary, which should be fine
jirka
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 2/3] perf tools: Fix build for hardened environments
Em Thu, Nov 09, 2017 at 08:36:22AM +0100, Jiri Olsa escreveu:
Quoted 29 lines · Arnaldo Carvalho de Melo
Quoted 28 lines
Em Wed, Nov 08, 2017 at 11:27:38AM +0100, Jiri Olsa escreveu:
Quoted 26 lines
From: Jiri Olsa <[email protected]>
On Fedora systems the perl and python CFLAGS/LDFLAGS include the hardened specs from redhat-rpm-config package. We apply them only for perl/python objects, which makes them not compatible with the rest of the objects and the build fails with:
/usr/bin/ld: perf-in.o: relocationR_X86_64_32against.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: libperf.a(libperf-in.o): relocation R_X86_64_32S against.text' can not be used when making a shared object; recompile with -fPIC/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile.perf:507: perf] Error 1
make[1]: *** [Makefile.perf:210: sub-make] Error 2
make: *** [Makefile:69: all] Error 2Mainly it's caused by perl/python objects being compiled with:
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
which prevent the final link impossible, because it will check for 'proper' objects with following option:
-specs=/usr/lib/rpm/redhat/redhat-hardened-ld
Fixing this by using the perl/python CFLAGS/LDFLAGS options for all the objects.
Quoted 6 lines
Quoted 3 lines
Humm, so we're basically using the hardened config only we build with PERL or PYTHON, should we use that always, i.e. ask the distro what set of flags we should use?
right, I think this needs to be detected like we do for features, since there maybe some supported gcc versions to detect
Right, since we want to honour what the distro makers decided was the best set for them, and to be able to link with other libraries, etc.
But then I think this should be done more explicitely, right? Do you envision some way to do that without having to try to build perl or python, that may not be installed, etc?
Of course users wanting to use something different may just set CFLAGS and be done with it, in which case I think this should also affect the perl and python CFLAGS, removing that distro specific stuff since the user is changing something different.
Quoted 21 lines
Quoted 4 lines
What other impacts this may have on using this for all of the tools? I.e. we could conceivably just remove that part from the perl/python builds and make them use what has been used for the rest of the tools instead?
hum, so those are the flags the perl/python extensions are built with
we have both perl/python extensions built in the perf for the script cmd, which creates dependencies:
[jolsa@krava perf]$ ldd ./perf |grep perl
libperl.so.5.24 =>/lib64/libperl.so.5.24(0x00007f72b33b3000)
[jolsa@krava perf]$ ldd ./perf |grep python
libpython2.7.so.1.0 =>/lib64/libpython2.7.so.1.0(0x00007f927cfe7000)not sure we could be affected here if we remove that hardened spec option
and then we have the python module extension which is used separately of perf binary, which should be fine
jirka
Re: [PATCH 2/3] perf tools: Fix build for hardened environments
Quoted 37 lines · Arnaldo Carvalho de Melo
Em Thu, Nov 09, 2017 at 08:36:22AM +0100, Jiri Olsa escreveu:
Quoted 29 lines · Arnaldo Carvalho de Melo
Quoted 28 lines
Em Wed, Nov 08, 2017 at 11:27:38AM +0100, Jiri Olsa escreveu:
Quoted 26 lines
From: Jiri Olsa <[email protected]>
On Fedora systems the perl and python CFLAGS/LDFLAGS include the hardened specs from redhat-rpm-config package. We apply them only for perl/python objects, which makes them not compatible with the rest of the objects and the build fails with:
/usr/bin/ld: perf-in.o: relocationR_X86_64_32against.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: libperf.a(libperf-in.o): relocation R_X86_64_32S against.text' can not be used when making a shared object; recompile with -fPIC/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile.perf:507: perf] Error 1
make[1]: *** [Makefile.perf:210: sub-make] Error 2
make: *** [Makefile:69: all] Error 2Mainly it's caused by perl/python objects being compiled with:
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
which prevent the final link impossible, because it will check for 'proper' objects with following option:
-specs=/usr/lib/rpm/redhat/redhat-hardened-ld
Fixing this by using the perl/python CFLAGS/LDFLAGS options for all the objects.
Quoted 6 lines
Quoted 3 lines
Humm, so we're basically using the hardened config only we build with PERL or PYTHON, should we use that always, i.e. ask the distro what set of flags we should use?
right, I think this needs to be detected like we do for features, since there maybe some supported gcc versions to detect
Quoted 7 lines
Right, since we want to honour what the distro makers decided was the best set for them, and to be able to link with other libraries, etc.
But then I think this should be done more explicitely, right? Do you envision some way to do that without having to try to build perl or python, that may not be installed, etc?
I'll check on it.. I think we could use feature detection and enable that by default and add NO_HARDENED_BUILD variable as we do for features.. and detect that python/perl or whatever else is using that and warn
Quoted 4 lines
Of course users wanting to use something different may just set CFLAGS and be done with it, in which case I think this should also affect the perl and python CFLAGS, removing that distro specific stuff since the user is changing something different.
yep
jirka
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 2/3] perf tools: Fix build for hardened environments
Em Fri, Nov 10, 2017 at 10:43:25AM +0100, Jiri Olsa escreveu:
Quoted 26 lines · Arnaldo Carvalho de Melo
Quoted 24 lines
Em Thu, Nov 09, 2017 at 08:36:22AM +0100, Jiri Olsa escreveu:
Quoted 14 lines · Arnaldo Carvalho de Melo
Quoted 12 lines
Em Wed, Nov 08, 2017 at 11:27:38AM +0100, Jiri Olsa escreveu:
Quoted 11 lines
Mainly it's caused by perl/python objects being compiled with:
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
which prevent the final link impossible, because it will check for 'proper' objects with following option:
-specs=/usr/lib/rpm/redhat/redhat-hardened-ld
Fixing this by using the perl/python CFLAGS/LDFLAGS options for all the objects.
Quoted 6 lines
Quoted 3 lines
Humm, so we're basically using the hardened config only we build with PERL or PYTHON, should we use that always, i.e. ask the distro what set of flags we should use?
right, I think this needs to be detected like we do for features, since there maybe some supported gcc versions to detect
Right, since we want to honour what the distro makers decided was the best set for them, and to be able to link with other libraries, etc.
Quoted 8 lines
Quoted 3 lines
But then I think this should be done more explicitely, right? Do you envision some way to do that without having to try to build perl or python, that may not be installed, etc?
I'll check on it.. I think we could use feature detection and enable that by default and add
NO_HARDENED_BUILDvariable as we do for features.. and detect that python/perl or whatever else is using that and warn
I stumbled it on a recently created perf build container for fedora 27:
fedora:27
Downloading http://192.168.124.1/perf/perf-4.14.0.tar.xz...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speedmake: Entering directory '/git/linux/tools/perf'
BUILD: Doing 'make -j4 parallel build HOSTCC /tmp/build/perf/fixdep.o HOSTLD /tmp/build/perf/fixdep-in.o LINK /tmp/build/perf/fixdep
Auto-detecting system features:
... dwarf: [ on ]
... dwarf_getlocations: [ on ]
... glibc: [ on ]
... gtk2: [ on ]
... libaudit: [ on ]
... libbfd: [ on ]
... libelf: [ on ]
... libnuma: [ on ]
... numa_num_possible_cpus: [ on ]
... libperl: [ on ]
... libpython: [ on ]
... libslang: [ on ]
... libcrypto: [ on ]
... libunwind: [ on ]
... libdw-dwarf-unwind: [ on ]
... zlib: [ on ]
... lzma: [ on ]
... get_cpuid: [ on ]
... bpf: [ on ]
Makefile.config:813: No openjdk development package found, please install JDK package
GEN /tmp/build/perf/common-cmds.h
PERF_VERSION = 4.14.geae86e
MKDIR /tmp/build/perf/fd/ CC /tmp/build/perf/fd/array.o CC /tmp/build/perf/exec-cmd.o CC /tmp/build/perf/util/parse-events-flex.o <SNIP> LD /tmp/build/perf/util/libperf-in.o LD /tmp/build/perf/libperf-in.o AR /tmp/build/perf/libperf.a LINK /tmp/build/perf/perf LINK /tmp/build/perf/libperf-gtk.so
/usr/bin/ld: /tmp/build/perf/perf-in.o: relocation R_X86_64_32 against .rodata.str1.1' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /tmp/build/perf/libperf.a(libperf-in.o): relocation R_X86_64_32S against .text' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile.perf:507: /tmp/build/perf/perf] Error 1
make[1]: *** [Makefile.perf:210: sub-make] Error 2
make: *** [Makefile:70: all] Error 2
make: Leaving directory '/git/linux/tools/perf'
Re: [PATCH 2/3] perf tools: Fix build for hardened environments
On Thu, Nov 23, 2017 at 11:15:32AM -0300, Arnaldo Carvalho de Melo wrote:
SNIP
Quoted 48 lines
I stumbled it on a recently created perf build container for fedora 27:
fedora:27
Downloading http://192.168.124.1/perf/perf-4.14.0.tar.xz...% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speedmake: Entering directory '/git/linux/tools/perf'
BUILD: Doing 'make -j4 parallel build HOSTCC /tmp/build/perf/fixdep.o HOSTLD /tmp/build/perf/fixdep-in.o LINK /tmp/build/perf/fixdepAuto-detecting system features:
... dwarf: [ on ]
...dwarf_getlocations: [ on ]
... glibc: [ on ]
... gtk2: [ on ]
... libaudit: [ on ]
... libbfd: [ on ]
... libelf: [ on ]
... libnuma: [ on ]
...numa_num_possible_cpus: [ on ]
... libperl: [ on ]
... libpython: [ on ]
... libslang: [ on ]
... libcrypto: [ on ]
... libunwind: [ on ]
... libdw-dwarf-unwind: [ on ]
... zlib: [ on ]
... lzma: [ on ]
...get_cpuid: [ on ]
... bpf: [ on ]Makefile.config:813: No openjdk development package found, please install JDK package
GEN/tmp/build/perf/common-cmds.h
PERF_VERSION= 4.14.geae86eMKDIR /tmp/build/perf/fd/ CC /tmp/build/perf/fd/array.o CC /tmp/build/perf/exec-cmd.o CC /tmp/build/perf/util/parse-events-flex.o <SNIP> LD /tmp/build/perf/util/libperf-in.o LD /tmp/build/perf/libperf-in.o AR /tmp/build/perf/libperf.a LINK /tmp/build/perf/perf LINK /tmp/build/perf/libperf-gtk.so
Quoted 8 lines
/usr/bin/ld:/tmp/build/perf/perf-in.o: relocationR_X86_64_32against.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: /tmp/build/perf/libperf.a(libperf-in.o): relocation R_X86_64_32S against.text' can not be used when making a shared object; recompile with -fPIC/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile.perf:507:/tmp/build/perf/perf] Error 1
make[1]: *** [Makefile.perf:210: sub-make] Error 2
make: *** [Makefile:70: all] Error 2
make: Leaving directory '/git/linux/tools/perf'
yep, thats the one ;-) I'll try to repost shortly
jirka
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 2/3] perf tools: Fix build for hardened environments
In reply to Jiri OlsaEm Fri, Nov 10, 2017 at 10:43:25AM +0100, Jiri Olsa escreveu:
Quoted 13 lines · Arnaldo Carvalho de Melo
Quoted 6 lines
Right, since we want to honour what the distro makers decided was the best set for them, and to be able to link with other libraries, etc.
But then I think this should be done more explicitely, right? Do you envision some way to do that without having to try to build perl or python, that may not be installed, etc?
I'll check on it.. I think we could use feature detection and enable that by default and add
NO_HARDENED_BUILDvariable as we do for features.. and detect that python/perl or whatever else is using that and warn
Quoted 6 lines
Quoted 4 lines
Of course users wanting to use something different may just set CFLAGS and be done with it, in which case I think this should also affect the perl and python CFLAGS, removing that distro specific stuff since the user is changing something different.
yep
Even with this patch applied, as a stopgap solution to allow me to build a full featured tool on f27, I get this leftover:
LINK /tmp/build/perf/perf/usr/bin/ld: /tmp/build/perf/libperf.a(libperf-in.o): relocation R_X86_64_32S against symbol `inat_primary_table' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
Looking at the Intel PT bits now...
- Arnaldo
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 2/3] perf tools: Fix build for hardened environments
Em Wed, Nov 29, 2017 at 04:54:46PM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 24 lines
Em Fri, Nov 10, 2017 at 10:43:25AM +0100, Jiri Olsa escreveu:
Quoted 13 lines · Arnaldo Carvalho de Melo
Quoted 6 lines
Right, since we want to honour what the distro makers decided was the best set for them, and to be able to link with other libraries, etc.
But then I think this should be done more explicitely, right? Do you envision some way to do that without having to try to build perl or python, that may not be installed, etc?
I'll check on it.. I think we could use feature detection and enable that by default and add
NO_HARDENED_BUILDvariable as we do for features.. and detect that python/perl or whatever else is using that and warnQuoted 6 lines
Quoted 4 lines
Of course users wanting to use something different may just set CFLAGS and be done with it, in which case I think this should also affect the perl and python CFLAGS, removing that distro specific stuff since the user is changing something different.
yep
Even with this patch applied, as a stopgap solution to allow me to build a full featured tool on f27, I get this leftover:
Quoted 7 lines
LINK
/tmp/build/perf/perf/usr/bin/ld: /tmp/build/perf/libperf.a(libperf-in.o): relocationR_X86_64_32Sagainst symbol `inat_primary_table' can not be used when making a shared object; recompile with -fPIC/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit statusLooking at the Intel PT bits now...
Nevermind, I did a full rebuild and this is not there anymore, some build artifact with that file :-\
- Arnaldo
Re: [PATCH 2/3] perf tools: Fix build for hardened environments
Quoted 31 lines · Arnaldo Carvalho de Melo
Em Wed, Nov 29, 2017 at 04:54:46PM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 30 lines
Em Fri, Nov 10, 2017 at 10:43:25AM +0100, Jiri Olsa escreveu:
Quoted 13 lines · Arnaldo Carvalho de Melo
Quoted 6 lines
Right, since we want to honour what the distro makers decided was the best set for them, and to be able to link with other libraries, etc.
But then I think this should be done more explicitely, right? Do you envision some way to do that without having to try to build perl or python, that may not be installed, etc?
I'll check on it.. I think we could use feature detection and enable that by default and add
NO_HARDENED_BUILDvariable as we do for features.. and detect that python/perl or whatever else is using that and warnQuoted 6 lines
Quoted 4 lines
Of course users wanting to use something different may just set CFLAGS and be done with it, in which case I think this should also affect the perl and python CFLAGS, removing that distro specific stuff since the user is changing something different.
yep
Even with this patch applied, as a stopgap solution to allow me to build a full featured tool on f27, I get this leftover:
LINK
/tmp/build/perf/perf/usr/bin/ld: /tmp/build/perf/libperf.a(libperf-in.o): relocationR_X86_64_32Sagainst symbol `inat_primary_table' can not be used when making a shared object; recompile with -fPIC/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
Quoted 4 lines
Quoted 1 line
Looking at the Intel PT bits now...
Nevermind, I did a full rebuild and this is not there anymore, some build artifact with that file :-\
I keep posponing this fix.. maybe I should update to F27 ;-)
I'll send new version soon
jirka
Namhyung Kim
maintainerRe: [PATCH 2/3] perf tools: Fix build for hardened environments
In reply to Jiri OlsaHi Jiri,
Quoted 15 lines · Jiri Olsa
From: Jiri Olsa <[email protected]>
On Fedora systems the perl and python CFLAGS/LDFLAGS include the hardened specs from redhat-rpm-config package. We apply them only for perl/python objects, which makes them not compatible with the rest of the objects and the build fails with:
/usr/bin/ld: perf-in.o: relocationR_X86_64_32against.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: libperf.a(libperf-in.o): relocation R_X86_64_32S against.text' can not be used when making a shared object; recompile with -fPIC/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile.perf:507: perf] Error 1
make[1]: *** [Makefile.perf:210: sub-make] Error 2
make: *** [Makefile:69: all] Error 2
Quoted 8 lines
Mainly it's caused by perl/python objects being compiled with:
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
which prevent the final link impossible, because it will check for 'proper' objects with following option:
-specs=/usr/lib/rpm/redhat/redhat-hardened-ld
Just for curiousity, could you please show me the contents of the two files? (Are they big?)
Thanks,
Namhyung
Quoted 83 lines
Fixing this by using the perl/python CFLAGS/LDFLAGS options for all the objects.
Signed-off-by Jiri Olsa <[email protected]>--- tools/perf/Makefile.config | 2 ++ tools/perf/scripts/perl/Perf-Trace-Util/Build | 2 +- tools/perf/scripts/python/Perf-Trace-Util/Build | 2 +- tools/perf/util/block-range.c | 2 +- tools/perf/util/scripting-engines/Build | 4 ++-- 5 files changed, 7 insertions(+), 5 deletions(-)tools/perf/Makefile.config +2
-0@@ -587,6 +587,7 @@ else NO_LIBPERL := 1 msg := $(warning Missing perl devel files. Disabling perl scripting support, please install perl-ExtUtils-Embed/libperl-dev); else + CFLAGS += $(PERL_EMBED_CCOPTS) LDFLAGS += $(PERL_EMBED_LDFLAGS) EXTLIBS += $(PERL_EMBED_LIBADD) $(call detected,CONFIG_LIBPERL)@@ -636,6 +637,7 @@ else $(warning $(and ,)) $(error $(and ,)) else + CFLAGS += $(PYTHON_EMBED_CCOPTS) LDFLAGS += $(PYTHON_EMBED_LDFLAGS) EXTLIBS += $(PYTHON_EMBED_LIBADD) LANG_BINDINGS += $(obj-perf)python/perf.sotools/perf/scripts/perl/Perf-Trace-Util/Build +1
-1@@ -1,5 +1,5 @@ libperf-y += Context.o -CFLAGS_Context.o += $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes +CFLAGS_Context.o += -Wno-redundant-decls -Wno-strict-prototypes CFLAGS_Context.o += -Wno-unused-parameter -Wno-nested-externs -Wno-undef CFLAGS_Context.o += -Wno-switch-default -Wno-shadowtools/perf/scripts/python/Perf-Trace-Util/Build +1
-1@@ -1,3 +1,3 @@ libperf-y += Context.o -CFLAGS_Context.o += $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs +CFLAGS_Context.o += -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externstools/perf/util/block-range.c +1
-1@@ -15,7 +15,7 @@ static void block_range__debug(void)*/ #if 1 struct rb_node *rb; -u64 old =0 ;/* NULL isn't executable */ +u64 old__maybe_unused =0 ;/* NULL isn't executable */ for (rb =rb_first (&block_ranges.root); rb; rb =rb_next (rb)) { struct block_range *entry = rb_entry(rb, struct block_range, node);tools/perf/util/scripting-engines/Build +2
-2@@ -1,6 +1,6 @@ libperf-$(CONFIG_LIBPERL) += trace-event-perl.o libperf-$(CONFIG_LIBPYTHON) += trace-event-python.o -CFLAGS_trace-event-perl.o += $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow -Wno-nested-externs -Wno-undef -Wno-switch-default +CFLAGS_trace-event-perl.o += -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow -Wno-nested-externs -Wno-undef -Wno-switch-default -CFLAGS_trace-event-python.o += $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow +CFLAGS_trace-event-python.o += -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadowSignature · 1 line
2.13.6
Re: [PATCH 2/3] perf tools: Fix build for hardened environments
Quoted 22 lines · Namhyung Kim
Hi Jiri,
Quoted 19 lines · Jiri Olsa
From: Jiri Olsa <[email protected]>
On Fedora systems the perl and python CFLAGS/LDFLAGS include the hardened specs from redhat-rpm-config package. We apply them only for perl/python objects, which makes them not compatible with the rest of the objects and the build fails with:
/usr/bin/ld: perf-in.o: relocationR_X86_64_32against.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: libperf.a(libperf-in.o): relocation R_X86_64_32S against.text' can not be used when making a shared object; recompile with -fPIC/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile.perf:507: perf] Error 1
make[1]: *** [Makefile.perf:210: sub-make] Error 2
make: *** [Makefile:69: all] Error 2Mainly it's caused by perl/python objects being compiled with:
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
Quoted 7 lines
Quoted 4 lines
which prevent the final link impossible, because it will check for 'proper' objects with following option:
-specs=/usr/lib/rpm/redhat/redhat-hardened-ld
Just for curiousity, could you please show me the contents of the two files? (Are they big?)
# cat /usr/lib/rpm/redhat/redhat-hardened-ld
*self_spec:
+ %{!static:%{!shared:%{!r:-pie}}}*link:
+ -z now
# cat /usr/lib/rpm/redhat/redhat-hardened-cc1
*cc1_options:
+ %{!r:%{!fpie:%{!fPIE:%{!fpic:%{!fPIC:%{!fno-pic:-fPIE}}}}}}jirka
Re: [PATCH 2/3] perf tools: Fix build for hardened environments
Quoted 35 lines · Jiri Olsa
Quoted 22 lines · Namhyung Kim
Hi Jiri,
Quoted 19 lines · Jiri Olsa
From: Jiri Olsa <[email protected]>
On Fedora systems the perl and python CFLAGS/LDFLAGS include the hardened specs from redhat-rpm-config package. We apply them only for perl/python objects, which makes them not compatible with the rest of the objects and the build fails with:
/usr/bin/ld: perf-in.o: relocationR_X86_64_32against.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: libperf.a(libperf-in.o): relocation R_X86_64_32S against.text' can not be used when making a shared object; recompile with -fPIC/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile.perf:507: perf] Error 1
make[1]: *** [Makefile.perf:210: sub-make] Error 2
make: *** [Makefile:69: all] Error 2Mainly it's caused by perl/python objects being compiled with:
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
Quoted 7 lines
Quoted 4 lines
which prevent the final link impossible, because it will check for 'proper' objects with following option:
-specs=/usr/lib/rpm/redhat/redhat-hardened-ld
Just for curiousity, could you please show me the contents of the two files? (Are they big?)
# cat /usr/lib/rpm/redhat/redhat-hardened-ld *self_spec: + %{!static:%{!shared:%{!r:-pie}}}
Quoted 7 lines
*link:
+ -z now# cat /usr/lib/rpm/redhat/redhat-hardened-cc1 *cc1_options: + %{!r:%{!fpie:%{!fPIE:%{!fpic:%{!fPIC:%{!fno-pic:-fPIE}}}}}}
looks like we could remove that spec totaly and get things working we already do that for CC_NO_CLANG
could you guys test patch below? works on my setup
thanks,
jirka
--- tools/perf/Makefile.config | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
tools/perf/Makefile.config +3 -4
@@ -184,9 +184,7 @@ ifdef PYTHON_CONFIG PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS)) PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null) - ifeq ($(CC_NO_CLANG), 1) - PYTHON_EMBED_CCOPTS := $(filter-out -specs=%,$(PYTHON_EMBED_CCOPTS)) - endif + PYTHON_EMBED_CCOPTS := $(filter-out -specs=%,$(PYTHON_EMBED_CCOPTS)) FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS) endif
@@ -572,7 +570,6 @@ ifndef NO_GTK2 endif endif - ifdef NO_LIBPERL CFLAGS += -DNO_LIBPERL else
@@ -580,6 +577,8 @@ else PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS)) PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS)) PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null) + PERL_EMBED_CCOPTS := $(filter-out -specs=%,$(PERL_EMBED_CCOPTS)) + PERL_EMBED_LDOPTS := $(filter-out -specs=%,$(PERL_EMBED_LDOPTS)) FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) ifneq ($(feature-libperl), 1)
Signature · 1 line
2.14.3
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 2/3] perf tools: Fix build for hardened environments
Em Mon, Dec 04, 2017 at 09:24:37AM +0100, Jiri Olsa escreveu:
Quoted 45 lines · Jiri Olsa
Quoted 35 lines · Namhyung Kim
Quoted 22 lines
Hi Jiri,
Quoted 19 lines · Jiri Olsa
From: Jiri Olsa <[email protected]>
On Fedora systems the perl and python CFLAGS/LDFLAGS include the hardened specs from redhat-rpm-config package. We apply them only for perl/python objects, which makes them not compatible with the rest of the objects and the build fails with:
/usr/bin/ld: perf-in.o: relocationR_X86_64_32against.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: libperf.a(libperf-in.o): relocation R_X86_64_32S against.text' can not be used when making a shared object; recompile with -fPIC/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile.perf:507: perf] Error 1
make[1]: *** [Makefile.perf:210: sub-make] Error 2
make: *** [Makefile:69: all] Error 2Mainly it's caused by perl/python objects being compiled with:
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
Quoted 7 lines
Quoted 4 lines
which prevent the final link impossible, because it will check for 'proper' objects with following option:
-specs=/usr/lib/rpm/redhat/redhat-hardened-ld
Just for curiousity, could you please show me the contents of the two files? (Are they big?)
# cat /usr/lib/rpm/redhat/redhat-hardened-ld *self_spec: + %{!static:%{!shared:%{!r:-pie}}}Quoted 7 lines
*link:
+ -z now# cat /usr/lib/rpm/redhat/redhat-hardened-cc1 *cc1_options: + %{!r:%{!fpie:%{!fPIE:%{!fpic:%{!fPIC:%{!fno-pic:-fPIE}}}}}}
Quoted 4 lines
looks like we could remove that spec totaly and get things working we already do that for
CC_NO_CLANGcould you guys test patch below? works on my setup
Works for me as well, builds in f27 with gcc and with clang, I've added it to my perf/core branch with the original commig message modulo the description of the original fix.
If you want to have a different message, feel free to send it to me and I'll make the adjustments if this takes place before my next pull req to Ingo :-)
Thanks,
- Arnaldo
Re: [PATCH 2/3] perf tools: Fix build for hardened environments
Quoted 51 lines · Arnaldo Carvalho de Melo
Em Mon, Dec 04, 2017 at 09:24:37AM +0100, Jiri Olsa escreveu:
Quoted 45 lines · Jiri Olsa
Quoted 35 lines · Namhyung Kim
Quoted 22 lines
Hi Jiri,
Quoted 19 lines · Jiri Olsa
From: Jiri Olsa <[email protected]>
On Fedora systems the perl and python CFLAGS/LDFLAGS include the hardened specs from redhat-rpm-config package. We apply them only for perl/python objects, which makes them not compatible with the rest of the objects and the build fails with:
/usr/bin/ld: perf-in.o: relocationR_X86_64_32against.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: libperf.a(libperf-in.o): relocation R_X86_64_32S against.text' can not be used when making a shared object; recompile with -fPIC/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile.perf:507: perf] Error 1
make[1]: *** [Makefile.perf:210: sub-make] Error 2
make: *** [Makefile:69: all] Error 2Mainly it's caused by perl/python objects being compiled with:
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
Quoted 7 lines
Quoted 4 lines
which prevent the final link impossible, because it will check for 'proper' objects with following option:
-specs=/usr/lib/rpm/redhat/redhat-hardened-ld
Just for curiousity, could you please show me the contents of the two files? (Are they big?)
# cat /usr/lib/rpm/redhat/redhat-hardened-ld *self_spec: + %{!static:%{!shared:%{!r:-pie}}}Quoted 7 lines
*link:
+ -z now# cat /usr/lib/rpm/redhat/redhat-hardened-cc1 *cc1_options: + %{!r:%{!fpie:%{!fPIE:%{!fpic:%{!fPIC:%{!fno-pic:-fPIE}}}}}}Quoted 4 lines
looks like we could remove that spec totaly and get things working we already do that for
CC_NO_CLANGcould you guys test patch below? works on my setup
Quoted 7 lines
Works for me as well, builds in f27 with gcc and with clang, I've added it to my perf/core branch with the original commig message modulo the description of the original fix.
If you want to have a different message, feel free to send it to me and I'll make the adjustments if this takes place before my next pull req to Ingo :-)
saw it, looks good, thanks
jirka
tip-bot for Jiri Olsa
merge bot[tip:perf/core] perf tools: Fix up build in hardnened environments
In reply to Jiri Olsaperf tools: Fix up build in hardnened environments
Commit-ID: c6707fdef7e2c1eb5458988b49c33497affdebbf Gitweb: https://git.kernel.org/tip/c6707fdef7e2c1eb5458988b49c33497affdebbf Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 4 Dec 2017 12:23:08 -0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 5 Dec 2017 15:43:52 -0300
perf tools: Fix up build in hardnened environments
On Fedora systems the perl and python CFLAGS/LDFLAGS include the hardened specs from redhat-rpm-config package. We apply them only for perl/python objects, which makes them not compatible with the rest of the objects and the build fails with:
/usr/bin/ld: perf-in.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -f
+PIC
/usr/bin/ld: libperf.a(libperf-in.o): relocation R_X86_64_32S against `.text' can not be used when making a shared object; recompile w
+ith -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile.perf:507: perf] Error 1
make[1]: *** [Makefile.perf:210: sub-make] Error 2
make: *** [Makefile:69: all] Error 2
Mainly it's caused by perl/python objects being compiled with:
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
which prevent the final link impossible, because it will check for 'proper' objects with following option:
-specs=/usr/lib/rpm/redhat/redhat-hardened-ld
--- tools/perf/Makefile.config | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
tools/perf/Makefile.config +3 -4
@@ -185,9 +185,7 @@ ifdef PYTHON_CONFIG PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS)) PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null) - ifeq ($(CC_NO_CLANG), 1) - PYTHON_EMBED_CCOPTS := $(filter-out -specs=%,$(PYTHON_EMBED_CCOPTS)) - endif + PYTHON_EMBED_CCOPTS := $(filter-out -specs=%,$(PYTHON_EMBED_CCOPTS)) FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS) endif
@@ -577,7 +575,6 @@ ifndef NO_GTK2 endif endif - ifdef NO_LIBPERL CFLAGS += -DNO_LIBPERL else
@@ -585,6 +582,8 @@ else PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS)) PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS)) PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null) + PERL_EMBED_CCOPTS := $(filter-out -specs=%,$(PERL_EMBED_CCOPTS)) + PERL_EMBED_LDOPTS := $(filter-out -specs=%,$(PERL_EMBED_LDOPTS)) FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) ifneq ($(feature-libperl), 1)
tip-bot for Jiri Olsa
merge bot[tip:perf/urgent] perf tools: Fix up build in hardened environments
In reply to Jiri Olsaperf tools: Fix up build in hardened environments
Commit-ID: 61fb26a6a23c0f1a07a0f8a11b54bafb1ac2398b Gitweb: https://git.kernel.org/tip/61fb26a6a23c0f1a07a0f8a11b54bafb1ac2398b Author: Jiri Olsa <[email protected]> AuthorDate: Mon, 4 Dec 2017 12:23:08 -0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 18 Dec 2017 11:54:08 -0300
perf tools: Fix up build in hardened environments
On Fedora systems the perl and python CFLAGS/LDFLAGS include the hardened specs from redhat-rpm-config package. We apply them only for perl/python objects, which makes them not compatible with the rest of the objects and the build fails with:
/usr/bin/ld: perf-in.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -f
+PIC
/usr/bin/ld: libperf.a(libperf-in.o): relocation R_X86_64_32S against `.text' can not be used when making a shared object; recompile w
+ith -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile.perf:507: perf] Error 1
make[1]: *** [Makefile.perf:210: sub-make] Error 2
make: *** [Makefile:69: all] Error 2
Mainly it's caused by perl/python objects being compiled with:
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
which prevent the final link impossible, because it will check for 'proper' objects with following option:
-specs=/usr/lib/rpm/redhat/redhat-hardened-ld
--- tools/perf/Makefile.config | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
tools/perf/Makefile.config +3 -4
@@ -188,9 +188,7 @@ ifdef PYTHON_CONFIG PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS)) PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null) - ifeq ($(CC_NO_CLANG), 1) - PYTHON_EMBED_CCOPTS := $(filter-out -specs=%,$(PYTHON_EMBED_CCOPTS)) - endif + PYTHON_EMBED_CCOPTS := $(filter-out -specs=%,$(PYTHON_EMBED_CCOPTS)) FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS) endif
@@ -576,7 +574,6 @@ ifndef NO_GTK2 endif endif - ifdef NO_LIBPERL CFLAGS += -DNO_LIBPERL else
@@ -584,6 +581,8 @@ else PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS)) PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS)) PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null) + PERL_EMBED_CCOPTS := $(filter-out -specs=%,$(PERL_EMBED_CCOPTS)) + PERL_EMBED_LDOPTS := $(filter-out -specs=%,$(PERL_EMBED_LDOPTS)) FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) ifneq ($(feature-libperl), 1)
Jiri Olsa
reviewerPATCH 3/3 perf tools: Removing FLAGS_PYTHON_EMBED/FLAGS_PERL_EMBED variables
In reply to Jiri OlsaThere's no user of those.
--- tools/perf/Makefile.config | 2 -- 1 file changed, 2 deletions(-)
tools/perf/Makefile.config +0 -2
@@ -187,7 +187,6 @@ ifdef PYTHON_CONFIG ifeq ($(CC_NO_CLANG), 1) PYTHON_EMBED_CCOPTS := $(filter-out -specs=%,$(PYTHON_EMBED_CCOPTS)) endif - FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS) endif FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)
@@ -580,7 +579,6 @@ else PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS)) PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS)) PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null) - FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) ifneq ($(feature-libperl), 1) CFLAGS += -DNO_LIBPERL
Signature · 1 line
2.13.6
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 3/3] perf tools: Removing FLAGS_PYTHON_EMBED/FLAGS_PERL_EMBED variables
Em Wed, Nov 08, 2017 at 11:27:39AM +0100, Jiri Olsa escreveu:
Quoted 1 line
There's no user of those.
[acme@jouet linux]$ find tools/ -type f | xargs grep FLAGS_PYTHON_EMBED tools/perf/Makefile.config: FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)tools/build/feature/Makefile: $(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -laudit -I/usr/include/slang -lslang $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl -lz -llzmatools/build/feature/Makefile: $(BUILD) $(FLAGS_PYTHON_EMBED)
[acme@jouet linux]$
Should we remove these?
- Arnaldo
Quoted 28 lines
Signed-off-by Jiri Olsa <[email protected]>--- tools/perf/Makefile.config | 2 -- 1 file changed, 2 deletions(-)tools/perf/Makefile.config +0
-2@@ -187,7 +187,6 @@ ifdef PYTHON_CONFIG ifeq ($(CC_NO_CLANG), 1) PYTHON_EMBED_CCOPTS := $(filter-out -specs=%,$(PYTHON_EMBED_CCOPTS)) endif - FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS) endif FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)@@ -580,7 +579,6 @@ else PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS)) PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS)) PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null) - FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) ifneq ($(feature-libperl), 1) CFLAGS += -DNO_LIBPERLSignature · 1 line
2.13.6
Re: [PATCH 3/3] perf tools: Removing FLAGS_PYTHON_EMBED/FLAGS_PERL_EMBED variables
Quoted 10 lines · Arnaldo Carvalho de Melo
Em Wed, Nov 08, 2017 at 11:27:39AM +0100, Jiri Olsa escreveu:
Quoted 1 line
There's no user of those.
[acme@jouet linux]$ find
tools/-type f | xargs grepFLAGS_PYTHON_EMBEDtools/perf/Makefile.config:FLAGS_PYTHON_EMBED:= $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)tools/build/feature/Makefile: $(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -laudit -I/usr/include/slang -lslang $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl -lz -llzmatools/build/feature/Makefile: $(BUILD) $(FLAGS_PYTHON_EMBED)
[acme@jouet linux]$Should we remove these?
oops, missed that directory.. thos eneed to stay then ;-) sry
thanks,
jirka
Quoted 31 lines
- Arnaldo
Quoted 28 lines
Signed-off-by Jiri Olsa <[email protected]>--- tools/perf/Makefile.config | 2 -- 1 file changed, 2 deletions(-)tools/perf/Makefile.config +0
-2@@ -187,7 +187,6 @@ ifdef PYTHON_CONFIG ifeq ($(CC_NO_CLANG), 1) PYTHON_EMBED_CCOPTS := $(filter-out -specs=%,$(PYTHON_EMBED_CCOPTS)) endif - FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS) endif FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)@@ -580,7 +579,6 @@ else PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS)) PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS)) PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null) - FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) ifneq ($(feature-libperl), 1) CFLAGS += -DNO_LIBPERLSignature · 1 line
2.13.6
Arnaldo Carvalho de Melo
maintainerRe: [PATCH 3/3] perf tools: Removing FLAGS_PYTHON_EMBED/FLAGS_PERL_EMBED variables
Em Thu, Nov 09, 2017 at 08:27:49AM +0100, Jiri Olsa escreveu:
Quoted 10 lines · Arnaldo Carvalho de Melo
Quoted 9 lines
Em Wed, Nov 08, 2017 at 11:27:39AM +0100, Jiri Olsa escreveu:
Quoted 1 line
There's no user of those.
[acme@jouet linux]$ find
tools/-type f | xargs grepFLAGS_PYTHON_EMBEDtools/perf/Makefile.config:FLAGS_PYTHON_EMBED:= $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)tools/build/feature/Makefile: $(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -laudit -I/usr/include/slang -lslang $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl -lz -llzmatools/build/feature/Makefile: $(BUILD) $(FLAGS_PYTHON_EMBED)
[acme@jouet linux]$
Quoted 3 lines
Quoted 1 line
Should we remove these?
oops, missed that directory.. thos eneed to stay then ;-) sry
np!
- Arnaldo