Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 2060611

Summary: [LLNL DTS BUG] elfutils library in dts10 built without -fPIC
Product: Red Hat Developer Toolset Reporter: Ben Woodard <woodard>
Component: elfutilsAssignee: Mark Wielaard <mjw>
Status: CLOSED ERRATA QA Contact: Martin Cermak <mcermak>
Severity: medium Docs Contact:
Priority: unspecified    
Version: DTS 10.1 RHEL 7CC: bmikulov, dsmith, fche, ionut, jakub, mcermak, mjw, mnewsome, ohudlick, prd-servers, tdhooge, tgummels, woodard
Target Milestone: alphaKeywords: Regression, Triaged
Target Release: 12.0Flags: pm-rhel: mirror+
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: devtoolset-11-elfutils-0.185-2.el7, devtoolset-11-elfutils-0.185-2.el6 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-24 14:57:17 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Ben Woodard 2022-03-03 20:53:01 UTC
Description of problem:
The ar's for elfutils 0.182 in DTS10 are not built with -fPIC. Consequently when trying to build libabigail with them they you run into errors like this:

 CXXLD    libabigail.la
 /opt/rh/devtoolset-10/root/usr/libexec/gcc/x86_64-redhat-linux/10/ld: /opt/rh/devtoolset-10/root/usr/lib/gcc/x86_64-redhat-linux/10/../../../../lib64/libdw.ar(i386_disasm.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC

This does work on DTS8. Also if you are careful to set your LDFLAGS=-L/usr/lib64 before running configure then it will work because it will pickup the system version of elfutils rather than the one included in DTS.

Version-Release number of selected component (if applicable):
182


How reproducible:
Always

Steps to Reproduce:
1. install DTS10 on RHEL7
2. set PATH and LD_LIBRARY_PATH to the correct values for the install (don't use the standard software collections tool)
2.5. Also depending on your environment you may need to also set CXXFLAGS to include -I the directory to the DTS install's include dir and LDFLAGS to include -L to DTS10's lib64 dir.
3. clone libabigail's git
4. configure it
5. make


Actual results:
linking problems

Expected results:
builds properly

Additional info:
We can leave this unfixed in DTS10 but it would be great if it worked properly in DTS11 even if elfutils is removed from DTS12.

Comment 1 Mark Wielaard 2022-03-04 11:23:48 UTC
(In reply to Ben Woodard from comment #0)
> Description of problem:
> The ar's for elfutils 0.182 in DTS10 are not built with -fPIC. Consequently
> when trying to build libabigail with them they you run into errors like this:
> 
>  CXXLD    libabigail.la
>  /opt/rh/devtoolset-10/root/usr/libexec/gcc/x86_64-redhat-linux/10/ld:
> /opt/rh/devtoolset-10/root/usr/lib/gcc/x86_64-redhat-linux/10/../../../../
> lib64/libdw.ar(i386_disasm.o): relocation R_X86_64_32S against
> `.rodata.str1.1' can not be used when making a shared object; recompile with
> -fPIC

Replicated. With make V=1 you get a bit more output:

libtool: link: g++  -fPIC -DPIC -shared -nostdlib /lib/../lib64/crti.o /opt/rh/devtoolset-10/root/usr/lib/gcc/x86_64-redhat-linux/10/crtbeginS.o  .libs/abg-traverse.o .libs/abg-ir.o .libs/abg-corpus.o .libs/abg-diff-utils.o .libs/abg-comparison.o .libs/abg-reporter-priv.o .libs/abg-default-reporter.o .libs/abg-leaf-reporter.o .libs/abg-suppression.o .libs/abg-comp-filter.o .libs/abg-reader.o .libs/abg-elf-reader-common.o .libs/abg-dwarf-reader.o .libs/abg-libxml-utils.o .libs/abg-hash.o .libs/abg-writer.o .libs/abg-config.o .libs/abg-ini.o .libs/abg-workers.o .libs/abg-tools-utils.o .libs/abg-elf-helpers.o .libs/abg-regex.o .libs/abg-symtab-reader.o .libs/abg-viz-common.o .libs/abg-viz-dot.o .libs/abg-viz-svg.o   -lpthread -lxml2 -lelf -ldw -L/opt/rh/devtoolset-10/root/usr/lib/gcc/x86_64-redhat-linux/10 -L/opt/rh/devtoolset-10/root/usr/lib/gcc/x86_64-redhat-linux/10/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/opt/rh/devtoolset-10/root/usr/lib/gcc/x86_64-redhat-linux/10/../../.. -lstdc++ -lm -lc -lgcc_s /opt/rh/devtoolset-10/root/usr/lib/gcc/x86_64-redhat-linux/10/crtendS.o /lib/../lib64/crtn.o  -O2 -Wl,--as-needed   -Wl,-soname -Wl,libabigail.so.0 -o .libs/libabigail.so.0.0.0
/opt/rh/devtoolset-10/root/usr/libexec/gcc/x86_64-redhat-linux/10/ld: /opt/rh/devtoolset-10/root/usr/lib/gcc/x86_64-redhat-linux/10/../../../../lib64/libdw.ar(i386_disasm.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/opt/rh/devtoolset-10/root/usr/libexec/gcc/x86_64-redhat-linux/10/ld: /opt/rh/devtoolset-10/root/usr/lib/gcc/x86_64-redhat-linux/10/../../../../lib64/libdw.ar(x86_64_disasm.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/opt/rh/devtoolset-10/root/usr/libexec/gcc/x86_64-redhat-linux/10/ld: /opt/rh/devtoolset-10/root/usr/lib/gcc/x86_64-redhat-linux/10/../../../../lib64/libdw.ar(bpf_disasm.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:501: libabigail.la] Error 1
make[1]: *** [Makefile:566: all-recursive] Error 1
make: *** [Makefile:432: all] Error 2


> This does work on DTS8. Also if you are careful to set your
> LDFLAGS=-L/usr/lib64 before running configure then it will work because it
> will pickup the system version of elfutils rather than the one included in
> DTS.
> 
> Version-Release number of selected component (if applicable):
> 182
> 
> 
> How reproducible:
> Always
> 
> Steps to Reproduce:
> 1. install DTS10 on RHEL7
> 2. set PATH and LD_LIBRARY_PATH to the correct values for the install (don't
> use the standard software collections tool)
> 2.5. Also depending on your environment you may need to also set CXXFLAGS to
> include -I the directory to the DTS install's include dir and LDFLAGS to
> include -L to DTS10's lib64 dir.

I highly recommend against this. Please just use scl enable devtoolset-10. That sets up everything correctly.
In particular it sets up the right pkgconfig path which the libabigail configure uses to get the correct build flags.

> 3. clone libabigail's git
> 4. configure it
> 5. make 
> 
> Actual results:
> linking problems
> 
> Expected results:
> builds properly
> 
> Additional info:
> We can leave this unfixed in DTS10 but it would be great if it worked
> properly in DTS11 even if elfutils is removed from DTS12.

BTW. Note that devtoolset-11 for RHEL7 should already available.
I'll look into where/when the -fPIC flag disappeared.
But this might be too late for DTS 11.1 because we are already past development phase.

Comment 2 Mark Wielaard 2022-03-04 11:29:02 UTC
(In reply to Mark Wielaard from comment #1)
> BTW. Note that devtoolset-11 for RHEL7 should already available.
> I'll look into where/when the -fPIC flag disappeared.
> But this might be too late for DTS 11.1 because we are already past
> development phase.

It is also an issue with DTS11 devtoolset-11-elfutils-devel-0.185-1.el7.x86_64

libtool: link: g++  -fPIC -DPIC -shared -nostdlib /lib/../lib64/crti.o /opt/rh/devtoolset-11/root/usr/lib/gcc/x86_64-redhat-linux/11/crtbeginS.o  .libs/abg-traverse.o .libs/abg-ir.o .libs/abg-corpus.o .libs/abg-diff-utils.o .libs/abg-comparison.o .libs/abg-reporter-priv.o .libs/abg-default-reporter.o .libs/abg-leaf-reporter.o .libs/abg-suppression.o .libs/abg-comp-filter.o .libs/abg-reader.o .libs/abg-elf-reader-common.o .libs/abg-dwarf-reader.o .libs/abg-libxml-utils.o .libs/abg-hash.o .libs/abg-writer.o .libs/abg-config.o .libs/abg-ini.o .libs/abg-workers.o .libs/abg-tools-utils.o .libs/abg-elf-helpers.o .libs/abg-regex.o .libs/abg-symtab-reader.o .libs/abg-viz-common.o .libs/abg-viz-dot.o .libs/abg-viz-svg.o   -lpthread -lxml2 -lelf -ldw -L/opt/rh/devtoolset-11/root/usr/lib/gcc/x86_64-redhat-linux/11 -L/opt/rh/devtoolset-11/root/usr/lib/gcc/x86_64-redhat-linux/11/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/opt/rh/devtoolset-11/root/usr/lib/gcc/x86_64-redhat-linux/11/../../.. -lstdc++ -lm -lc -lgcc_s /opt/rh/devtoolset-11/root/usr/lib/gcc/x86_64-redhat-linux/11/crtendS.o /lib/../lib64/crtn.o  -O2 -Wl,--as-needed   -Wl,-soname -Wl,libabigail.so.0 -o .libs/libabigail.so.0.0.0
/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/ld: /opt/rh/devtoolset-11/root/usr/lib/gcc/x86_64-redhat-linux/11/../../../../lib64/libdw.ar(i386_disasm.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/ld: /opt/rh/devtoolset-11/root/usr/lib/gcc/x86_64-redhat-linux/11/../../../../lib64/libdw.ar(x86_64_disasm.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/ld: /opt/rh/devtoolset-11/root/usr/lib/gcc/x86_64-redhat-linux/11/../../../../lib64/libdw.ar(bpf_disasm.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:501: libabigail.la] Error 1
make[1]: *** [Makefile:566: all-recursive] Error 1
make: *** [Makefile:432: all] Error 2

Comment 3 Mark Wielaard 2022-03-07 17:13:07 UTC
*** Bug 2061010 has been marked as a duplicate of this bug. ***

Comment 7 Frank Ch. Eigler 2022-03-07 19:11:13 UTC
I'm looking into dts 11.1 & gccts 11.1, and was pleased to find the elfutils-0.NNN-dts.patch already there, which adds -fPIC to a bunch of libFOO_a_CFLAGS.  Then I was surprised at finding the same patch already there in dts8 and dts10.  So in theory it should already just work, but apparently doesn't.  Investigating further.

Comment 9 Frank Ch. Eigler 2022-03-07 19:33:41 UTC
The problem appears to be simply that the libcpu/ subdirectory was omitted in the *-dts.patch.  Appending the following appears to fix a random hand build:

--- a/libcpu/Makefile.am        2021-05-22 14:25:24.000000000 -0400
+++ b/libcpu/Makefile.am        2022-03-07 14:28:51.079852845 -0500
@@ -33,7 +33,7 @@
 if BUILD_STATIC
 AM_CFLAGS += $(fpic_CFLAGS)
 endif
-AM_CFLAGS += -fdollars-in-identifiers
+AM_CFLAGS += -fPIC -fdollars-in-identifiers
 LEXCOMPILE = $(LEX) $(LFLAGS) $(AM_LFLAGS) -P$(<F:lex.l=)
 LEX_OUTPUT_ROOT = lex.$(<F:lex.l=)
 AM_YFLAGS = -p$(<F:parse.y=)

Comment 21 errata-xmlrpc 2022-05-24 14:57:17 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (devtoolset-11-elfutils bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:4728