Bug 1163333 - LTO: binutils build fails
LTO: binutils build fails
Status: RESOLVED FIXED
Classification: openSUSE
Product: openSUSE Tumbleweed
Classification: openSUSE
Component: Basesystem
Current
Other Other
: P5 - None : Normal (vote)
: ---
Assigned To: Martin Liška
E-mail List
:
Depends on:
Blocks: 1133084
  Show dependency treegraph
 
Reported: 2020-02-11 08:16 UTC by Martin Liška
Modified: 2022-04-13 10:05 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Liška 2020-02-11 08:16:53 UTC
I'm working on binutils 2.34 package update and I noticed quite suspicious thing.
We build the package with LTO (and -ffat-lto-objects due to some .a libs), and
the built package crashes. More precisely, one needs to built binutils with already
built version 2.34. Doing that I end up with:

$ LD_LIBRARY_PATH=../bfd/.libs/ .libs/ar r /tmp/x.a /tmp/y
Segmentation fault (core dumped)

(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x00007ffff7afe7dd in make_relative_prefix_1 (progname=0x7fffffffeb09 "/home/abuild/rpmbuild/BUILD/binutils-2.34/build-dir/binutils/.libs/ar", bin_prefix=0x7ffff7ce326b "/usr/bin", prefix=0x7ffff7ce3254 "/usr/lib64/bfd-plugins", resolve_links=1)
    at ../../libiberty/make-relative-prefix.c:317
#2  0x00007ffff7b1026e in load_plugin (abfd=0x5555555667e0) at ../../bfd/plugin.c:397
#3  bfd_plugin_object_p (abfd=0x5555555667e0) at ../../bfd/plugin.c:451
#4  0x00007ffff7cda4c6 in bfd_check_format_matches (abfd=abfd@entry=0x5555555667e0, format=format@entry=bfd_object, matching=matching@entry=0x0) at ../../bfd/format.c:261
#5  0x00007ffff7cda917 in bfd_check_format (abfd=abfd@entry=0x5555555667e0, format=format@entry=bfd_object) at ../../bfd/format.c:94
#6  0x00007ffff7cdb248 in _bfd_write_archive_contents (arch=0x555555573a90) at ../../bfd/archive.c:2127
#7  0x00007ffff7cd2c4a in bfd_close (abfd=0x555555573a90) at ../../bfd/opncls.c:755
#8  0x000055555555a718 in write_archive (iarch=0x5555555640c0) at ../../binutils/ar.c:1240
#9  0x000055555555a9ea in replace_members (arch=0x5555555640c0, files_to_move=0x555555564080, quick=0) at ../../binutils/ar.c:1482
#10 0x000055555555842e in main (argc=<optimized out>, argv=<optimized out>) at ../../binutils/ar.c:887

Dump of assembler code for function make_relative_prefix_1:
   0x00007ffff7afe620 <+0>:    push   %rbp
   0x00007ffff7afe621 <+1>:    mov    %rsp,%rbp
   0x00007ffff7afe624 <+4>:    push   %r15
   0x00007ffff7afe626 <+6>:    push   %r14
...
   0x00007ffff7afe7d8 <+440>:    callq  0x7ffff7af6990 <lrealpath@plt>
=> 0x00007ffff7afe7dd <+445>:    mov    %rax,%r15

So it crashes in call to lrealpath (via plt entry). What's maybe problematic is that the link command line:

gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -g -Wno-error -ffat-lto-objects -o .libs/ar arparse.o arlex.o ar.o not-ranlib.o arsup.o rename.o binemul.o emul_vanilla.o bucomm.o version.o filemode.o  ../bfd/.libs/libbfd.so -L/home/abuild/rpmbuild/BUILD/binutils-2.34/build-dir/bfd/../libiberty/pic -liberty -lz ../libiberty/libiberty.a -lfl -ldl -Wl,-rpath -Wl,/usr/lib64

contains:
$ nm ../bfd/.libs/libbfd.so | grep lrealpath
00000000000fc510 T lrealpath

and LTO resolution file looks like:

/home/abuild/rpmbuild/BUILD/binutils-2.34/build-dir/bfd/../libiberty/pic/libiberty.a@0x20eab2 7
...
269 5c0e5e41e2575a62 RESOLVED_IR lrealpath
/home/abuild/rpmbuild/BUILD/binutils-2.34/build-dir/bfd/../libiberty/pic/libiberty.a@0x26afce 2
212 69eadc5b8b30099f PREVAILING_DEF_IRONLY lrealpath
...

and the symbol is seen by GCC in LTO as:

lrealpath/2736 (lrealpath) @0x7ffff77639d8
  Type: function definition analyzed
  Visibility: externally_visible prevailing_def_ironly public
  References:
  Referring:
  Read from file: /home/abuild/rpmbuild/BUILD/binutils-2.34/build-dir/bfd/../libiberty/pic/libiberty.a
  Availability: available
  Function flags: count:1073741824 (estimated locally)
  Called by: canonical_filename_eq/2611 (1073741824 (estimated locally),1.00 per call) canonical_filename_eq/2611 (1073741824 (estimated locally),1.00 per call)
  Calls: strdup/2737 (1073741824 (estimated locally),1.00 per call) __realpath_chk/2740 (1073741824 (estimated locally),1.00 per call)

But I can't see the symbol being emitted in final executable (nor .s file):

$ nm .libs/ar | grep lrealpath
0000000000047e87 W lrealpath.c.60931cf1

Note that adding -fno-lto to the command line helps and the ar is not crashing.

The issue seems to me similar to what I've already seen few time for e.g. Inkscape:
https://gitlab.com/inkscape/inkscape/issues/235

So it's basically about linking against x.a file and y.so (where y.so contains x.a).
Comment 1 Swamp Workflow Management 2020-02-27 10:10:16 UTC
This is an autogenerated message for OBS integration:
This bug (1163333) was mentioned in
https://build.opensuse.org/request/show/779849 Factory / binutils
Comment 2 Swamp Workflow Management 2020-03-26 16:30:09 UTC
This is an autogenerated message for OBS integration:
This bug (1163333) was mentioned in
https://build.opensuse.org/request/show/788599 Factory / binutils
Comment 4 Swamp Workflow Management 2020-10-28 11:19:32 UTC
SUSE-SU-2020:3060-1: An update that solves 8 vulnerabilities, contains three features and has 5 fixes is now available.

Category: security (moderate)
Bug References: 1126826,1126829,1126831,1140126,1142649,1143609,1153768,1153770,1157755,1160254,1160590,1163333,1163744
CVE References: CVE-2019-12972,CVE-2019-14250,CVE-2019-14444,CVE-2019-17450,CVE-2019-17451,CVE-2019-9074,CVE-2019-9075,CVE-2019-9077
JIRA References: ECO-2373,SLE-7464,SLE-7903
Sources used:
SUSE Linux Enterprise Module for Packagehub Subpackages 15-SP2 (src):    binutils-2.35-7.11.1
SUSE Linux Enterprise Module for Packagehub Subpackages 15-SP1 (src):    binutils-2.35-7.11.1
SUSE Linux Enterprise Module for Development Tools 15-SP2 (src):    binutils-2.35-7.11.1
SUSE Linux Enterprise Module for Development Tools 15-SP1 (src):    binutils-2.35-7.11.1
SUSE Linux Enterprise Module for Basesystem 15-SP2 (src):    binutils-2.35-7.11.1
SUSE Linux Enterprise Module for Basesystem 15-SP1 (src):    binutils-2.35-7.11.1

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.
Comment 5 Swamp Workflow Management 2020-10-31 17:16:57 UTC
openSUSE-SU-2020:1790-1: An update that solves 8 vulnerabilities and has 5 fixes is now available.

Category: security (moderate)
Bug References: 1126826,1126829,1126831,1140126,1142649,1143609,1153768,1153770,1157755,1160254,1160590,1163333,1163744
CVE References: CVE-2019-12972,CVE-2019-14250,CVE-2019-14444,CVE-2019-17450,CVE-2019-17451,CVE-2019-9074,CVE-2019-9075,CVE-2019-9077
JIRA References: 
Sources used:
openSUSE Leap 15.1 (src):    binutils-2.35-lp151.3.9.1, cross-aarch64-binutils-2.35-lp151.3.9.1, cross-arm-binutils-2.35-lp151.3.9.1, cross-avr-binutils-2.35-lp151.3.9.1, cross-epiphany-binutils-2.35-lp151.3.9.1, cross-hppa-binutils-2.35-lp151.3.9.1, cross-hppa64-binutils-2.35-lp151.3.9.1, cross-i386-binutils-2.35-lp151.3.9.1, cross-ia64-binutils-2.35-lp151.3.9.1, cross-m68k-binutils-2.35-lp151.3.9.1, cross-mips-binutils-2.35-lp151.3.9.1, cross-ppc-binutils-2.35-lp151.3.9.1, cross-ppc64-binutils-2.35-lp151.3.9.1, cross-ppc64le-binutils-2.35-lp151.3.9.1, cross-riscv64-binutils-2.35-lp151.3.9.1, cross-rx-binutils-2.35-lp151.3.9.1, cross-s390-binutils-2.35-lp151.3.9.1, cross-s390x-binutils-2.35-lp151.3.9.1, cross-sparc-binutils-2.35-lp151.3.9.1, cross-sparc64-binutils-2.35-lp151.3.9.1, cross-spu-binutils-2.35-lp151.3.9.1
Comment 6 Swamp Workflow Management 2020-11-01 14:15:20 UTC
openSUSE-SU-2020:1804-1: An update that solves 8 vulnerabilities and has 5 fixes is now available.

Category: security (moderate)
Bug References: 1126826,1126829,1126831,1140126,1142649,1143609,1153768,1153770,1157755,1160254,1160590,1163333,1163744
CVE References: CVE-2019-12972,CVE-2019-14250,CVE-2019-14444,CVE-2019-17450,CVE-2019-17451,CVE-2019-9074,CVE-2019-9075,CVE-2019-9077
JIRA References: 
Sources used:
openSUSE Leap 15.2 (src):    binutils-2.35-lp152.4.3.1, cross-aarch64-binutils-2.35-lp152.4.3.1, cross-arm-binutils-2.35-lp152.4.3.1, cross-avr-binutils-2.35-lp152.4.3.1, cross-epiphany-binutils-2.35-lp152.4.3.1, cross-hppa-binutils-2.35-lp152.4.3.1, cross-hppa64-binutils-2.35-lp152.4.3.1, cross-i386-binutils-2.35-lp152.4.3.1, cross-ia64-binutils-2.35-lp152.4.3.1, cross-m68k-binutils-2.35-lp152.4.3.1, cross-mips-binutils-2.35-lp152.4.3.1, cross-ppc-binutils-2.35-lp152.4.3.1, cross-ppc64-binutils-2.35-lp152.4.3.1, cross-ppc64le-binutils-2.35-lp152.4.3.1, cross-riscv64-binutils-2.35-lp152.4.3.1, cross-rx-binutils-2.35-lp152.4.3.1, cross-s390-binutils-2.35-lp152.4.3.1, cross-s390x-binutils-2.35-lp152.4.3.1, cross-sparc-binutils-2.35-lp152.4.3.1, cross-sparc64-binutils-2.35-lp152.4.3.1, cross-spu-binutils-2.35-lp152.4.3.1, cross-xtensa-binutils-2.35-lp152.4.3.1
Comment 8 Swamp Workflow Management 2020-11-27 20:16:51 UTC
SUSE-SU-2020:3552-1: An update that solves 8 vulnerabilities, contains three features and has 6 fixes is now available.

Category: security (moderate)
Bug References: 1126826,1126829,1126831,1140126,1142649,1143609,1153768,1153770,1157755,1160254,1160590,1163333,1163744,1179036
CVE References: CVE-2019-12972,CVE-2019-14250,CVE-2019-14444,CVE-2019-17450,CVE-2019-17451,CVE-2019-9074,CVE-2019-9075,CVE-2019-9077
JIRA References: ECO-2373,SLE-7464,SLE-7903
Sources used:
SUSE Linux Enterprise Server for SAP 15 (src):    binutils-2.35.1-6.15.1
SUSE Linux Enterprise Server 15-LTSS (src):    binutils-2.35.1-6.15.1
SUSE Linux Enterprise High Performance Computing 15-LTSS (src):    binutils-2.35.1-6.15.1
SUSE Linux Enterprise High Performance Computing 15-ESPOS (src):    binutils-2.35.1-6.15.1

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.
Comment 9 Martin Liška 2021-01-20 12:05:22 UTC
Will be fixed in the upcoming binutils release.
Comment 10 Martin Liška 2021-01-28 13:07:27 UTC
Let's wait for --enable-pgo-build[=lto] which will be added in 2.37 release.
Comment 12 Swamp Workflow Management 2021-11-02 14:27:32 UTC
SUSE-SU-2021:3593-1: An update that solves 21 vulnerabilities, contains 7 features and has 8 fixes is now available.

Category: security (moderate)
Bug References: 1126826,1126829,1126831,1140126,1142649,1143609,1153768,1153770,1157755,1160254,1160590,1163333,1163744,1179036,1179341,1179898,1179899,1179900,1179901,1179902,1179903,1180451,1180454,1180461,1181452,1182252,1183511,1184620,1184794
CVE References: CVE-2019-12972,CVE-2019-14250,CVE-2019-14444,CVE-2019-17450,CVE-2019-17451,CVE-2019-9074,CVE-2019-9075,CVE-2019-9077,CVE-2020-16590,CVE-2020-16591,CVE-2020-16592,CVE-2020-16593,CVE-2020-16598,CVE-2020-16599,CVE-2020-35448,CVE-2020-35493,CVE-2020-35496,CVE-2020-35507,CVE-2021-20197,CVE-2021-20284,CVE-2021-3487
JIRA References: ECO-2373,PM-2767,SLE-18637,SLE-19618,SLE-21561,SLE-7464,SLE-7903
Sources used:
SUSE OpenStack Cloud Crowbar 9 (src):    binutils-2.37-9.39.1
SUSE OpenStack Cloud Crowbar 8 (src):    binutils-2.37-9.39.1
SUSE OpenStack Cloud 9 (src):    binutils-2.37-9.39.1
SUSE OpenStack Cloud 8 (src):    binutils-2.37-9.39.1
SUSE Linux Enterprise Software Development Kit 12-SP5 (src):    binutils-2.37-9.39.1, cross-ppc-binutils-2.37-9.39.1, cross-spu-binutils-2.37-9.39.1
SUSE Linux Enterprise Server for SAP 12-SP4 (src):    binutils-2.37-9.39.1
SUSE Linux Enterprise Server for SAP 12-SP3 (src):    binutils-2.37-9.39.1
SUSE Linux Enterprise Server 12-SP5 (src):    binutils-2.37-9.39.1
SUSE Linux Enterprise Server 12-SP4-LTSS (src):    binutils-2.37-9.39.1
SUSE Linux Enterprise Server 12-SP3-LTSS (src):    binutils-2.37-9.39.1
SUSE Linux Enterprise Server 12-SP3-BCL (src):    binutils-2.37-9.39.1
SUSE Linux Enterprise Server 12-SP2-BCL (src):    binutils-2.37-9.39.1
HPE Helion Openstack 8 (src):    binutils-2.37-9.39.1

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.
Comment 13 Martin Liška 2022-04-13 10:05:34 UTC
Binutils now do support LTO.