All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] perf tools: Build fixes
@ 2017-11-08 10:27 Jiri Olsa
  2017-11-08 10:27 ` [PATCH 1/3] perf tools: Use shell function for perl cflags retrieval Jiri Olsa
                   ` (2 more replies)
  0 siblings, 3 replies; 26+ messages in thread
From: Jiri Olsa @ 2017-11-08 10:27 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Peter Zijlstra

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(-)

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 1/3] perf tools: Use shell function for perl cflags retrieval
  2017-11-08 10:27 [PATCH 0/3] perf tools: Build fixes Jiri Olsa
@ 2017-11-08 10:27 ` Jiri Olsa
  2017-11-08 16:03   ` Arnaldo Carvalho de Melo
                     ` (2 more replies)
  2017-11-08 10:27 ` [PATCH 2/3] perf tools: Fix build for hardened environments Jiri Olsa
  2017-11-08 10:27 ` [PATCH 3/3] perf tools: Removing FLAGS_PYTHON_EMBED/FLAGS_PERL_EMBED variables Jiri Olsa
  2 siblings, 3 replies; 26+ messages in thread
From: Jiri Olsa @ 2017-11-08 10:27 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Peter Zijlstra

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.

Link: http://lkml.kernel.org/n/tip-ozknr59ye7pohenvlg04eibq@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/Makefile.config | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 63f534a0902f..f6786fa2419f 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -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)
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 2/3] perf tools: Fix build for hardened environments
  2017-11-08 10:27 [PATCH 0/3] perf tools: Build fixes Jiri Olsa
  2017-11-08 10:27 ` [PATCH 1/3] perf tools: Use shell function for perl cflags retrieval Jiri Olsa
@ 2017-11-08 10:27 ` Jiri Olsa
  2017-11-08 16:03   ` Arnaldo Carvalho de Melo
  2017-12-01  2:11   ` Namhyung Kim
  2017-11-08 10:27 ` [PATCH 3/3] perf tools: Removing FLAGS_PYTHON_EMBED/FLAGS_PERL_EMBED variables Jiri Olsa
  2 siblings, 2 replies; 26+ messages in thread
From: Jiri Olsa @ 2017-11-08 10:27 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Peter Zijlstra

From: Jiri Olsa <jolsa@redhat.com>

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.

Link: http://lkml.kernel.org/n/tip-bib4nb5dei0ubk83534efamz@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 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(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index f6786fa2419f..5e3734e4c1e4 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -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
diff --git a/tools/perf/scripts/perl/Perf-Trace-Util/Build b/tools/perf/scripts/perl/Perf-Trace-Util/Build
index 34faecf774ae..ff9a452677fc 100644
--- a/tools/perf/scripts/perl/Perf-Trace-Util/Build
+++ b/tools/perf/scripts/perl/Perf-Trace-Util/Build
@@ -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
diff --git a/tools/perf/scripts/python/Perf-Trace-Util/Build b/tools/perf/scripts/python/Perf-Trace-Util/Build
index aefc15c9444a..cd4da129c017 100644
--- a/tools/perf/scripts/python/Perf-Trace-Util/Build
+++ b/tools/perf/scripts/python/Perf-Trace-Util/Build
@@ -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
diff --git a/tools/perf/util/block-range.c b/tools/perf/util/block-range.c
index f1451c987eec..ff76d5f1d96f 100644
--- a/tools/perf/util/block-range.c
+++ b/tools/perf/util/block-range.c
@@ -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);
diff --git a/tools/perf/util/scripting-engines/Build b/tools/perf/util/scripting-engines/Build
index 82d28c67e0f3..38cd25ce1503 100644
--- a/tools/perf/util/scripting-engines/Build
+++ b/tools/perf/util/scripting-engines/Build
@@ -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
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 3/3] perf tools: Removing FLAGS_PYTHON_EMBED/FLAGS_PERL_EMBED variables
  2017-11-08 10:27 [PATCH 0/3] perf tools: Build fixes Jiri Olsa
  2017-11-08 10:27 ` [PATCH 1/3] perf tools: Use shell function for perl cflags retrieval Jiri Olsa
  2017-11-08 10:27 ` [PATCH 2/3] perf tools: Fix build for hardened environments Jiri Olsa
@ 2017-11-08 10:27 ` Jiri Olsa
  2017-11-08 16:06   ` Arnaldo Carvalho de Melo
  2 siblings, 1 reply; 26+ messages in thread
From: Jiri Olsa @ 2017-11-08 10:27 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Peter Zijlstra

There's no user of those.

Link: http://lkml.kernel.org/n/tip-84jeuwojm21wcjfzvtis636l@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/Makefile.config | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 5e3734e4c1e4..caa7fe26efa9 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -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
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [PATCH 2/3] perf tools: Fix build for hardened environments
  2017-11-08 10:27 ` [PATCH 2/3] perf tools: Fix build for hardened environments Jiri Olsa
@ 2017-11-08 16:03   ` Arnaldo Carvalho de Melo
  2017-11-09  7:36     ` Jiri Olsa
  2017-12-01  2:11   ` Namhyung Kim
  1 sibling, 1 reply; 26+ messages in thread
From: Arnaldo Carvalho de Melo @ 2017-11-08 16:03 UTC (permalink / raw)
  To: Jiri Olsa; +Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Peter Zijlstra

Em Wed, Nov 08, 2017 at 11:27:38AM +0100, Jiri Olsa escreveu:
> From: Jiri Olsa <jolsa@redhat.com>
> 
> 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.

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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 1/3] perf tools: Use shell function for perl cflags retrieval
  2017-11-08 10:27 ` [PATCH 1/3] perf tools: Use shell function for perl cflags retrieval Jiri Olsa
@ 2017-11-08 16:03   ` Arnaldo Carvalho de Melo
  2017-11-18  8:26   ` [tip:perf/core] " tip-bot for Jiri Olsa
  2017-12-18 17:15   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
  2 siblings, 0 replies; 26+ messages in thread
From: Arnaldo Carvalho de Melo @ 2017-11-08 16:03 UTC (permalink / raw)
  To: Jiri Olsa; +Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Peter Zijlstra

Em Wed, Nov 08, 2017 at 11:27:37AM +0100, Jiri Olsa escreveu:
> 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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 3/3] perf tools: Removing FLAGS_PYTHON_EMBED/FLAGS_PERL_EMBED variables
  2017-11-08 10:27 ` [PATCH 3/3] perf tools: Removing FLAGS_PYTHON_EMBED/FLAGS_PERL_EMBED variables Jiri Olsa
@ 2017-11-08 16:06   ` Arnaldo Carvalho de Melo
  2017-11-09  7:27     ` Jiri Olsa
  0 siblings, 1 reply; 26+ messages in thread
From: Arnaldo Carvalho de Melo @ 2017-11-08 16:06 UTC (permalink / raw)
  To: Jiri Olsa; +Cc: lkml, Ingo Molnar, Namhyung Kim, David Ahern, Peter Zijlstra

Em Wed, Nov 08, 2017 at 11:27:39AM +0100, Jiri Olsa escreveu:
> 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 -llzma
tools/build/feature/Makefile:	$(BUILD) $(FLAGS_PYTHON_EMBED)
[acme@jouet linux]$ 

Should we remove these?

- Arnaldo
 
> Link: http://lkml.kernel.org/n/tip-84jeuwojm21wcjfzvtis636l@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  tools/perf/Makefile.config | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index 5e3734e4c1e4..caa7fe26efa9 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -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
> -- 
> 2.13.6

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 3/3] perf tools: Removing FLAGS_PYTHON_EMBED/FLAGS_PERL_EMBED variables
  2017-11-08 16:06   ` Arnaldo Carvalho de Melo
@ 2017-11-09  7:27     ` Jiri Olsa
  2017-11-09 12:48       ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 26+ messages in thread
From: Jiri Olsa @ 2017-11-09  7:27 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, lkml, Ingo Molnar, Namhyung Kim, David Ahern, Peter Zijlstra

On Wed, Nov 08, 2017 at 01:06:40PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Wed, Nov 08, 2017 at 11:27:39AM +0100, Jiri Olsa escreveu:
> > 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 -llzma
> tools/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

> 
> - Arnaldo
>  
> > Link: http://lkml.kernel.org/n/tip-84jeuwojm21wcjfzvtis636l@git.kernel.org
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > ---
> >  tools/perf/Makefile.config | 2 --
> >  1 file changed, 2 deletions(-)
> > 
> > diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> > index 5e3734e4c1e4..caa7fe26efa9 100644
> > --- a/tools/perf/Makefile.config
> > +++ b/tools/perf/Makefile.config
> > @@ -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
> > -- 
> > 2.13.6

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 2/3] perf tools: Fix build for hardened environments
  2017-11-08 16:03   ` Arnaldo Carvalho de Melo
@ 2017-11-09  7:36     ` Jiri Olsa
  2017-11-09 12:52       ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 26+ messages in thread
From: Jiri Olsa @ 2017-11-09  7:36 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, lkml, Ingo Molnar, Namhyung Kim, David Ahern, Peter Zijlstra

On Wed, Nov 08, 2017 at 01:03:21PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Wed, Nov 08, 2017 at 11:27:38AM +0100, Jiri Olsa escreveu:
> > From: Jiri Olsa <jolsa@redhat.com>
> > 
> > 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.
> 
> 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

> 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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 3/3] perf tools: Removing FLAGS_PYTHON_EMBED/FLAGS_PERL_EMBED variables
  2017-11-09  7:27     ` Jiri Olsa
@ 2017-11-09 12:48       ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 26+ messages in thread
From: Arnaldo Carvalho de Melo @ 2017-11-09 12:48 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Jiri Olsa, lkml, Ingo Molnar, Namhyung Kim, David Ahern, Peter Zijlstra

Em Thu, Nov 09, 2017 at 08:27:49AM +0100, Jiri Olsa escreveu:
> On Wed, Nov 08, 2017 at 01:06:40PM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Wed, Nov 08, 2017 at 11:27:39AM +0100, Jiri Olsa escreveu:
> > > 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 -llzma
> > tools/build/feature/Makefile:	$(BUILD) $(FLAGS_PYTHON_EMBED)
> > [acme@jouet linux]$ 
> > 
> > Should we remove these?
> 
> oops, missed that directory.. thos eneed to stay then ;-) sry

np!

- Arnaldo

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 2/3] perf tools: Fix build for hardened environments
  2017-11-09  7:36     ` Jiri Olsa
@ 2017-11-09 12:52       ` Arnaldo Carvalho de Melo
  2017-11-10  9:43         ` Jiri Olsa
  0 siblings, 1 reply; 26+ messages in thread
From: Arnaldo Carvalho de Melo @ 2017-11-09 12:52 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Jiri Olsa, lkml, Ingo Molnar, Namhyung Kim, David Ahern, Peter Zijlstra

Em Thu, Nov 09, 2017 at 08:36:22AM +0100, Jiri Olsa escreveu:
> On Wed, Nov 08, 2017 at 01:03:21PM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Wed, Nov 08, 2017 at 11:27:38AM +0100, Jiri Olsa escreveu:
> > > From: Jiri Olsa <jolsa@redhat.com>
> > > 
> > > 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.
> > 
> > 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.
 
> > 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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 2/3] perf tools: Fix build for hardened environments
  2017-11-09 12:52       ` Arnaldo Carvalho de Melo
@ 2017-11-10  9:43         ` Jiri Olsa
  2017-11-23 14:15           ` Arnaldo Carvalho de Melo
  2017-11-29 19:54           ` Arnaldo Carvalho de Melo
  0 siblings, 2 replies; 26+ messages in thread
From: Jiri Olsa @ 2017-11-10  9:43 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, lkml, Ingo Molnar, Namhyung Kim, David Ahern, Peter Zijlstra

On Thu, Nov 09, 2017 at 09:52:12AM -0300, Arnaldo Carvalho de Melo wrote:
> Em Thu, Nov 09, 2017 at 08:36:22AM +0100, Jiri Olsa escreveu:
> > On Wed, Nov 08, 2017 at 01:03:21PM -0300, Arnaldo Carvalho de Melo wrote:
> > > Em Wed, Nov 08, 2017 at 11:27:38AM +0100, Jiri Olsa escreveu:
> > > > From: Jiri Olsa <jolsa@redhat.com>
> > > > 
> > > > 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.
> > > 
> > > 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?
> 

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

> 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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [tip:perf/core] perf tools: Use shell function for perl cflags retrieval
  2017-11-08 10:27 ` [PATCH 1/3] perf tools: Use shell function for perl cflags retrieval Jiri Olsa
  2017-11-08 16:03   ` Arnaldo Carvalho de Melo
@ 2017-11-18  8:26   ` tip-bot for Jiri Olsa
  2017-12-18 17:15   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
  2 siblings, 0 replies; 26+ messages in thread
From: tip-bot for Jiri Olsa @ 2017-11-18  8:26 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, acme, dsahern, tglx, hpa, peterz, namhyung, linux-kernel, jolsa

Commit-ID:  86f5fe01cf3ad42e99e7655dec93e0e36ef65614
Gitweb:     https://git.kernel.org/tip/86f5fe01cf3ad42e99e7655dec93e0e36ef65614
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 8 Nov 2017 11:27:37 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20171108102739.30338-2-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Makefile.config | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 63f534a..f6786fa 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -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)

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [PATCH 2/3] perf tools: Fix build for hardened environments
  2017-11-10  9:43         ` Jiri Olsa
@ 2017-11-23 14:15           ` Arnaldo Carvalho de Melo
  2017-11-23 14:38             ` Jiri Olsa
  2017-11-29 19:54           ` Arnaldo Carvalho de Melo
  1 sibling, 1 reply; 26+ messages in thread
From: Arnaldo Carvalho de Melo @ 2017-11-23 14:15 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Jiri Olsa, lkml, Ingo Molnar, Namhyung Kim, David Ahern, Peter Zijlstra

Em Fri, Nov 10, 2017 at 10:43:25AM +0100, Jiri Olsa escreveu:
> On Thu, Nov 09, 2017 at 09:52:12AM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Thu, Nov 09, 2017 at 08:36:22AM +0100, Jiri Olsa escreveu:
> > > On Wed, Nov 08, 2017 at 01:03:21PM -0300, Arnaldo Carvalho de Melo wrote:
> > > > Em Wed, Nov 08, 2017 at 11:27:38AM +0100, Jiri Olsa escreveu:
> > > > > 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.

> > > > 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?
 
> 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

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  Speed

make: 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'

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 2/3] perf tools: Fix build for hardened environments
  2017-11-23 14:15           ` Arnaldo Carvalho de Melo
@ 2017-11-23 14:38             ` Jiri Olsa
  0 siblings, 0 replies; 26+ messages in thread
From: Jiri Olsa @ 2017-11-23 14:38 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, lkml, Ingo Molnar, Namhyung Kim, David Ahern, Peter Zijlstra

On Thu, Nov 23, 2017 at 11:15:32AM -0300, Arnaldo Carvalho de Melo wrote:

SNIP

> 
> 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  Speed
> 
> make: 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'

yep, thats the one ;-) I'll try to repost shortly

jirka

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 2/3] perf tools: Fix build for hardened environments
  2017-11-10  9:43         ` Jiri Olsa
  2017-11-23 14:15           ` Arnaldo Carvalho de Melo
@ 2017-11-29 19:54           ` Arnaldo Carvalho de Melo
  2017-11-29 20:00             ` Arnaldo Carvalho de Melo
  1 sibling, 1 reply; 26+ messages in thread
From: Arnaldo Carvalho de Melo @ 2017-11-29 19:54 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Jiri Olsa, lkml, Ingo Molnar, Namhyung Kim, David Ahern, Peter Zijlstra

Em Fri, Nov 10, 2017 at 10:43:25AM +0100, Jiri Olsa escreveu:
> On Thu, Nov 09, 2017 at 09:52:12AM -0300, Arnaldo Carvalho de Melo wrote:
> > 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
 
> > 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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 2/3] perf tools: Fix build for hardened environments
  2017-11-29 19:54           ` Arnaldo Carvalho de Melo
@ 2017-11-29 20:00             ` Arnaldo Carvalho de Melo
  2017-11-30 10:08               ` Jiri Olsa
  0 siblings, 1 reply; 26+ messages in thread
From: Arnaldo Carvalho de Melo @ 2017-11-29 20:00 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Jiri Olsa, lkml, Ingo Molnar, Namhyung Kim, David Ahern, Peter Zijlstra

Em Wed, Nov 29, 2017 at 04:54:46PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Fri, Nov 10, 2017 at 10:43:25AM +0100, Jiri Olsa escreveu:
> > On Thu, Nov 09, 2017 at 09:52:12AM -0300, Arnaldo Carvalho de Melo wrote:
> > > 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
>  
> > > 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...

Nevermind, I did a full rebuild and this is not there anymore, some
build artifact with that file :-\

- Arnaldo

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 2/3] perf tools: Fix build for hardened environments
  2017-11-29 20:00             ` Arnaldo Carvalho de Melo
@ 2017-11-30 10:08               ` Jiri Olsa
  0 siblings, 0 replies; 26+ messages in thread
From: Jiri Olsa @ 2017-11-30 10:08 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, lkml, Ingo Molnar, Namhyung Kim, David Ahern, Peter Zijlstra

On Wed, Nov 29, 2017 at 05:00:19PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Wed, Nov 29, 2017 at 04:54:46PM -0300, Arnaldo Carvalho de Melo escreveu:
> > Em Fri, Nov 10, 2017 at 10:43:25AM +0100, Jiri Olsa escreveu:
> > > On Thu, Nov 09, 2017 at 09:52:12AM -0300, Arnaldo Carvalho de Melo wrote:
> > > > 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
> >  
> > > > 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...
> 
> 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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 2/3] perf tools: Fix build for hardened environments
  2017-11-08 10:27 ` [PATCH 2/3] perf tools: Fix build for hardened environments Jiri Olsa
  2017-11-08 16:03   ` Arnaldo Carvalho de Melo
@ 2017-12-01  2:11   ` Namhyung Kim
  2017-12-04  7:34     ` Jiri Olsa
  1 sibling, 1 reply; 26+ messages in thread
From: Namhyung Kim @ 2017-12-01  2:11 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Arnaldo Carvalho de Melo, lkml, Ingo Molnar, David Ahern,
	Peter Zijlstra, kernel-team

Hi Jiri,

On Wed, Nov 08, 2017 at 11:27:38AM +0100, Jiri Olsa wrote:
> From: Jiri Olsa <jolsa@redhat.com>
> 
> 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

Just for curiousity, could you please show me the contents of the two
files?  (Are they big?)

Thanks,
Namhyung


> 
> Fixing this by using the perl/python CFLAGS/LDFLAGS options
> for all the objects.
> 
> Link: http://lkml.kernel.org/n/tip-bib4nb5dei0ubk83534efamz@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  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(-)
> 
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index f6786fa2419f..5e3734e4c1e4 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -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
> diff --git a/tools/perf/scripts/perl/Perf-Trace-Util/Build b/tools/perf/scripts/perl/Perf-Trace-Util/Build
> index 34faecf774ae..ff9a452677fc 100644
> --- a/tools/perf/scripts/perl/Perf-Trace-Util/Build
> +++ b/tools/perf/scripts/perl/Perf-Trace-Util/Build
> @@ -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
> diff --git a/tools/perf/scripts/python/Perf-Trace-Util/Build b/tools/perf/scripts/python/Perf-Trace-Util/Build
> index aefc15c9444a..cd4da129c017 100644
> --- a/tools/perf/scripts/python/Perf-Trace-Util/Build
> +++ b/tools/perf/scripts/python/Perf-Trace-Util/Build
> @@ -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
> diff --git a/tools/perf/util/block-range.c b/tools/perf/util/block-range.c
> index f1451c987eec..ff76d5f1d96f 100644
> --- a/tools/perf/util/block-range.c
> +++ b/tools/perf/util/block-range.c
> @@ -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);
> diff --git a/tools/perf/util/scripting-engines/Build b/tools/perf/util/scripting-engines/Build
> index 82d28c67e0f3..38cd25ce1503 100644
> --- a/tools/perf/util/scripting-engines/Build
> +++ b/tools/perf/util/scripting-engines/Build
> @@ -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
> -- 
> 2.13.6
> 

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 2/3] perf tools: Fix build for hardened environments
  2017-12-01  2:11   ` Namhyung Kim
@ 2017-12-04  7:34     ` Jiri Olsa
  2017-12-04  8:24       ` Jiri Olsa
  0 siblings, 1 reply; 26+ messages in thread
From: Jiri Olsa @ 2017-12-04  7:34 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, lkml, Ingo Molnar,
	David Ahern, Peter Zijlstra, kernel-team

On Fri, Dec 01, 2017 at 11:11:37AM +0900, Namhyung Kim wrote:
> Hi Jiri,
> 
> On Wed, Nov 08, 2017 at 11:27:38AM +0100, Jiri Olsa wrote:
> > From: Jiri Olsa <jolsa@redhat.com>
> > 
> > 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
> 
> 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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 2/3] perf tools: Fix build for hardened environments
  2017-12-04  7:34     ` Jiri Olsa
@ 2017-12-04  8:24       ` Jiri Olsa
  2017-12-04 15:35         ` Arnaldo Carvalho de Melo
                           ` (2 more replies)
  0 siblings, 3 replies; 26+ messages in thread
From: Jiri Olsa @ 2017-12-04  8:24 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Jiri Olsa, Arnaldo Carvalho de Melo, lkml, Ingo Molnar,
	David Ahern, Peter Zijlstra, kernel-team

On Mon, Dec 04, 2017 at 08:34:31AM +0100, Jiri Olsa wrote:
> On Fri, Dec 01, 2017 at 11:11:37AM +0900, Namhyung Kim wrote:
> > Hi Jiri,
> > 
> > On Wed, Nov 08, 2017 at 11:27:38AM +0100, Jiri Olsa wrote:
> > > From: Jiri Olsa <jolsa@redhat.com>
> > > 
> > > 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
> > 
> > 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}}}}}}


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(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index c17472cb50f5..d702d21eacf6 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -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)
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [PATCH 2/3] perf tools: Fix build for hardened environments
  2017-12-04  8:24       ` Jiri Olsa
@ 2017-12-04 15:35         ` Arnaldo Carvalho de Melo
  2017-12-05 16:19           ` Jiri Olsa
  2017-12-06 16:40         ` [tip:perf/core] perf tools: Fix up build in hardnened environments tip-bot for Jiri Olsa
  2017-12-18 17:16         ` [tip:perf/urgent] perf tools: Fix up build in hardened environments tip-bot for Jiri Olsa
  2 siblings, 1 reply; 26+ messages in thread
From: Arnaldo Carvalho de Melo @ 2017-12-04 15:35 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Namhyung Kim, Jiri Olsa, lkml, Ingo Molnar, David Ahern,
	Peter Zijlstra, kernel-team

Em Mon, Dec 04, 2017 at 09:24:37AM +0100, Jiri Olsa escreveu:
> On Mon, Dec 04, 2017 at 08:34:31AM +0100, Jiri Olsa wrote:
> > On Fri, Dec 01, 2017 at 11:11:37AM +0900, Namhyung Kim wrote:
> > > Hi Jiri,
> > > 
> > > On Wed, Nov 08, 2017 at 11:27:38AM +0100, Jiri Olsa wrote:
> > > > From: Jiri Olsa <jolsa@redhat.com>
> > > > 
> > > > 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
> > > 
> > > 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}}}}}}
> 
> 
> 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

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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 2/3] perf tools: Fix build for hardened environments
  2017-12-04 15:35         ` Arnaldo Carvalho de Melo
@ 2017-12-05 16:19           ` Jiri Olsa
  0 siblings, 0 replies; 26+ messages in thread
From: Jiri Olsa @ 2017-12-05 16:19 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Namhyung Kim, Jiri Olsa, lkml, Ingo Molnar, David Ahern,
	Peter Zijlstra, kernel-team

On Mon, Dec 04, 2017 at 12:35:14PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Mon, Dec 04, 2017 at 09:24:37AM +0100, Jiri Olsa escreveu:
> > On Mon, Dec 04, 2017 at 08:34:31AM +0100, Jiri Olsa wrote:
> > > On Fri, Dec 01, 2017 at 11:11:37AM +0900, Namhyung Kim wrote:
> > > > Hi Jiri,
> > > > 
> > > > On Wed, Nov 08, 2017 at 11:27:38AM +0100, Jiri Olsa wrote:
> > > > > From: Jiri Olsa <jolsa@redhat.com>
> > > > > 
> > > > > 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
> > > > 
> > > > 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}}}}}}
> > 
> > 
> > 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
> 
> 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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [tip:perf/core] perf tools: Fix up build in hardnened environments
  2017-12-04  8:24       ` Jiri Olsa
  2017-12-04 15:35         ` Arnaldo Carvalho de Melo
@ 2017-12-06 16:40         ` tip-bot for Jiri Olsa
  2017-12-18 17:16         ` [tip:perf/urgent] perf tools: Fix up build in hardened environments tip-bot for Jiri Olsa
  2 siblings, 0 replies; 26+ messages in thread
From: tip-bot for Jiri Olsa @ 2017-12-06 16:40 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: namhyung, tglx, hpa, dsahern, mingo, acme, peterz, jolsa, linux-kernel

Commit-ID:  c6707fdef7e2c1eb5458988b49c33497affdebbf
Gitweb:     https://git.kernel.org/tip/c6707fdef7e2c1eb5458988b49c33497affdebbf
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 4 Dec 2017 12:23:08 -0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20171204082437.GC30564@krava
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Makefile.config | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index bf86c09..808066c 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -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)

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [tip:perf/urgent] perf tools: Use shell function for perl cflags retrieval
  2017-11-08 10:27 ` [PATCH 1/3] perf tools: Use shell function for perl cflags retrieval Jiri Olsa
  2017-11-08 16:03   ` Arnaldo Carvalho de Melo
  2017-11-18  8:26   ` [tip:perf/core] " tip-bot for Jiri Olsa
@ 2017-12-18 17:15   ` tip-bot for Jiri Olsa
  2 siblings, 0 replies; 26+ messages in thread
From: tip-bot for Jiri Olsa @ 2017-12-18 17:15 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: tglx, namhyung, linux-kernel, dsahern, jolsa, hpa, acme, mingo, peterz

Commit-ID:  5cfee7a357f60675cae32b494bb2096d7203efd3
Gitweb:     https://git.kernel.org/tip/5cfee7a357f60675cae32b494bb2096d7203efd3
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 8 Nov 2017 11:27:37 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20171108102739.30338-2-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Makefile.config | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index ed65e82..710623d 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -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)

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [tip:perf/urgent] perf tools: Fix up build in hardened environments
  2017-12-04  8:24       ` Jiri Olsa
  2017-12-04 15:35         ` Arnaldo Carvalho de Melo
  2017-12-06 16:40         ` [tip:perf/core] perf tools: Fix up build in hardnened environments tip-bot for Jiri Olsa
@ 2017-12-18 17:16         ` tip-bot for Jiri Olsa
  2 siblings, 0 replies; 26+ messages in thread
From: tip-bot for Jiri Olsa @ 2017-12-18 17:16 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, jolsa, mingo, tglx, namhyung, dsahern, peterz, linux-kernel, acme

Commit-ID:  61fb26a6a23c0f1a07a0f8a11b54bafb1ac2398b
Gitweb:     https://git.kernel.org/tip/61fb26a6a23c0f1a07a0f8a11b54bafb1ac2398b
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 4 Dec 2017 12:23:08 -0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20171204082437.GC30564@krava
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Makefile.config | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 710623d..0294bfb 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -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)

^ permalink raw reply related	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2017-12-18 17:21 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-08 10:27 [PATCH 0/3] perf tools: Build fixes Jiri Olsa
2017-11-08 10:27 ` [PATCH 1/3] perf tools: Use shell function for perl cflags retrieval Jiri Olsa
2017-11-08 16:03   ` Arnaldo Carvalho de Melo
2017-11-18  8:26   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-12-18 17:15   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2017-11-08 10:27 ` [PATCH 2/3] perf tools: Fix build for hardened environments Jiri Olsa
2017-11-08 16:03   ` Arnaldo Carvalho de Melo
2017-11-09  7:36     ` Jiri Olsa
2017-11-09 12:52       ` Arnaldo Carvalho de Melo
2017-11-10  9:43         ` Jiri Olsa
2017-11-23 14:15           ` Arnaldo Carvalho de Melo
2017-11-23 14:38             ` Jiri Olsa
2017-11-29 19:54           ` Arnaldo Carvalho de Melo
2017-11-29 20:00             ` Arnaldo Carvalho de Melo
2017-11-30 10:08               ` Jiri Olsa
2017-12-01  2:11   ` Namhyung Kim
2017-12-04  7:34     ` Jiri Olsa
2017-12-04  8:24       ` Jiri Olsa
2017-12-04 15:35         ` Arnaldo Carvalho de Melo
2017-12-05 16:19           ` Jiri Olsa
2017-12-06 16:40         ` [tip:perf/core] perf tools: Fix up build in hardnened environments tip-bot for Jiri Olsa
2017-12-18 17:16         ` [tip:perf/urgent] perf tools: Fix up build in hardened environments tip-bot for Jiri Olsa
2017-11-08 10:27 ` [PATCH 3/3] perf tools: Removing FLAGS_PYTHON_EMBED/FLAGS_PERL_EMBED variables Jiri Olsa
2017-11-08 16:06   ` Arnaldo Carvalho de Melo
2017-11-09  7:27     ` Jiri Olsa
2017-11-09 12:48       ` Arnaldo Carvalho de Melo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.