Re: [PATCH 2/3] perf tools: Fix build for hardened environments

From: Jiri Olsa
Date: Tue Dec 05 2017 - 11:19:37 EST


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@xxxxxxxxxx>
> > > > >
> > > > > 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