Bug 2225130

Summary: bytecode stream in file ‘/opt/rh/gcc-toolset-13/root/usr/lib64/libbfd.a’ generated with LTO version 11.3 instead of the expected 13.0
Product: Red Hat Enterprise Linux 9 Reporter: Miloš Prchlík <mprchlik>
Component: gcc-toolset-13-binutilsAssignee: Nick Clifton <nickc>
Status: MODIFIED --- QA Contact: Miloš Prchlík <mprchlik>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 9.3Keywords: Bugfix, Triaged
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: gcc-toolset-13-binutils-2.40-13.el9 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 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 Miloš Prchlík 2023-07-24 11:10:27 UTC
Description of problem:

I'm not sure whether this is a serious issue or not, reporting it anyway, just in case:


[root@vm-10-0-186-49 ~]# cat libbfdtest.h 
extern int libbfdtest (void);
[root@vm-10-0-186-49 ~]# cat libbfdtest.c
#include <bfd.h>

#include "libbfdtest.h"

int
libbfdtest (void)
{
  bfd_set_error (bfd_error_no_error);
  return bfd_get_error () == bfd_error_no_error;
}

[root@vm-10-0-186-49 ~]# gcc -g -Wall -shared -o libbfdtest.so -fPIC libbfdtest.c -lbfd -liberty
lto1: fatal error: bytecode stream in file ‘/opt/rh/gcc-toolset-13/root/usr/lib64/libbfd.a’ generated with LTO version 11.3 instead of the expected 13.0
compilation terminated.
lto-wrapper: fatal error: gcc returned 1 exit status
compilation terminated.
/opt/rh/gcc-toolset-13/root/usr/libexec/gcc/x86_64-redhat-linux/13/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
[root@vm-10-0-186-49 ~]# 


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

gcc-toolset-13-binutils-2.40-9.el9.x86_64
gcc-toolset-13-gcc-13.1.1-4.2.el9.x86_64
gcc-toolset-13-runtime-13.0-1.el9.x86_64


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 1 Nick Clifton 2023-07-24 13:23:02 UTC
Fixed by: gcc-toolset-13-binutils-2.40-12.el9

This is a known issue with the first builds of gcc-toolset-13-binutils.

Until gcc-toolset-13-gcc was available the GTS-13 binutils had be built 
with the system compiler, which meant that the static libraries (libbfd.a,
libibetry.a, libopcodes.a) used the system compiler's version of the LTO
format.

The newer GTS-13 binutils builds were created using the GTS-13 gcc and
so should not have this problem.

Comment 2 Miloš Prchlík 2023-08-02 14:48:20 UTC
I'm afraid gcc-toolset-13-binutils-2.40-12.el9 keeps complaining about the LTO format version:

[root@mprchlik-1mt-rhel-9 ~]# gcc -g -Wall -shared -o libbfdtest.so -fPIC libbfdtest.c -lbfd -liberty
lto1: fatal error: bytecode stream in file ‘/opt/rh/gcc-toolset-13/root/usr/lib64/libbfd.a’ generated with LTO version 11.3 instead of the expected 13.0
compilation terminated.
lto-wrapper: fatal error: gcc returned 1 exit status
compilation terminated.
/opt/rh/gcc-toolset-13/root/usr/libexec/gcc/x86_64-redhat-linux/13/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
[root@mprchlik-1mt-rhel-9 ~]# rpm -qf /opt/rh/gcc-toolset-13/root/usr/lib64/libbfd.a
gcc-toolset-13-binutils-devel-2.40-12.el9.x86_64
[root@mprchlik-1mt-rhel-9 ~]# rpm -qa | grep gcc-toolset | sort
gcc-toolset-13-binutils-2.40-12.el9.x86_64
gcc-toolset-13-binutils-devel-2.40-12.el9.x86_64
gcc-toolset-13-binutils-gold-2.40-12.el9.x86_64
gcc-toolset-13-gcc-13.1.1-4.2.el9.x86_64
gcc-toolset-13-runtime-13.0-1.el9.x86_64
[root@mprchlik-1mt-rhel-9 ~]#

Comment 3 Nick Clifton 2023-08-03 08:28:22 UTC
*sigh*

This was due to a silly typo in the binutils.spec file.  Before the -12 update the spec file contained:

  BuildRequires: gcc
  %define gcc_for_libraries /usr/bin/gcc

After the update it contained:

  BuildRequires: %{?scl_prefix}gcc
  %define gcc_for_libraries %{?_scl_root}/usr/bin/gcc

  BuildRequires: gcc
  %define gcc_for_libraries /usr/bin/gcc

So I had copied and pasted the original lines, changed them to what they should be, and then totally forgot to delete the original lines.  Doh.

Comment 4 Nick Clifton 2023-08-03 13:12:16 UTC
Right - gcc-toolset-13-binutils-2.40-13.el9 - should actually fix the problem.

I looked in the root.log for the build and confirmed that the GTS-13 gcc was loaded and that the system gcc was not loaded, so I am confident that this build should work.