FS#74403 - [gcc] 11.2.0-4 lot1 errors when linking w/ static library, built with LTO 11.2, and requests 11.0

Attached to Project: Arch Linux
Opened by Adel KARA SLIMANE (adelks) - Friday, 08 April 2022, 12:57 GMT
Last edited by freswa (frederik) - Wednesday, 27 April 2022, 20:42 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Giancarlo Razzolini (grazzolini)
freswa (frederik)
Architecture x86_64
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

while linking my executable with a static library that is built with LTO (and GCC 11.2 on Ubuntu). I get this error:

```
lto1: fatal error: bytecode stream in file ‘../[...]/my_library.a’ generated with LTO version 11.2 instead of the expected 11.0
```

Even though I am running gcc 11.2, I do not know if this error message is actually accurate or the error is happening here but the real issue is elsewhere.

I thought of making a dummy static library built with my system's GCC and test, but of course it won't reproduce this issue since LTO would write it's allegedly wrong (11.0) version in it ? Of course, if this is the real issue.

I could not find online how to check the LTO version of GCC that was used in any given static library.

Some help would be appreciated, thanks!

Adel
This task depends upon

Closed by  freswa (frederik)
Wednesday, 27 April 2022, 20:42 GMT
Reason for closing:  Won't fix
Additional comments about closing:  Compilation processes on Ubuntu are out of our scope.
Comment by loqs (loqs) - Friday, 08 April 2022, 22:20 GMT
The different compilers are using incompatible LTO versions as in the error. The Ubuntu compiler contains [1] and [2] as part of a patch called git-update.diff.
Arch does not contain that patch its most recent update to the LTO constants is [3]. Which explains why gcc 11.2 from Arch has 11.0 while Ubuntu has 11.2.
As the versions changes indicate binary incompatibilities you can not link those files together with LTO enabled.

[1] https://github.com/gcc-mirror/gcc/commit/dce5367eecfb0729cad0325240d614721afb39e3
[2] https://github.com/gcc-mirror/gcc/commit/8621acaa879610c967f75a48313e2973f29c78d1
[3] https://github.com/gcc-mirror/gcc/commit/432a5b8744bc89f1975cba37cefd9f545f8abe86
Comment by Adel KARA SLIMANE (adelks) - Saturday, 09 April 2022, 12:27 GMT
Thanks for your input and this precious information. I will try to recompile GCC with these patches added in then. Do you know of there are plans to backport these patches in an upcoming release ?
Comment by loqs (loqs) - Saturday, 09 April 2022, 20:24 GMT
Arch may not update gcc before it moves to gcc 12 [1]. (which will then use LTO version 12.0). I would suggest taking all commits from the releases/gcc-11 branch since the 11.2 tag if you are going to rebuild gcc.

[1] https://bugs.archlinux.org/task/74177#comment207301

Loading...