FS#73467 - [freebasic] Error: "plugin needed to handle lto object"

Attached to Project: Community Packages
Opened by Martin Schnitkemper (Martin-MS) - Sunday, 23 January 2022, 11:53 GMT
Last edited by Felix Yan (felixonmars) - Tuesday, 15 February 2022, 23:52 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Felix Yan (felixonmars)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description: After update to version 1.09.0 I got on every project the error

| /usr/bin/../bin/ld: /usr/bin/../lib/freebasic/linux-x86_64/fbrt0.o: plugin needed to handle lto object.

After downgrade to version 1.08.1 all works well for me.

I tried then to build the package again in a clean chroot from the official PKGBUILD and got the same error during the build process (lines before and after the problem occurs):

| LINK bin/fbc
| AR lib/freebasic/linux-x86_64/libfb.a
| AR lib/freebasic/linux-x86_64/libfbpic.a
| /usr/bin/../bin/ld: /usr/bin/../lib/freebasic/linux-x86_64/fbrt0.o: plugin needed to handle lto object
| /usr/bin/../bin/ld: /usr/bin/../lib/freebasic/linux-x86_64/fbrt0.o: plugin needed to handle lto object
| /usr/bin/../bin/ld: src/compiler/obj/linux-x86_64/ast-gosub.o: in function `TSTRSETITEM::operator=(TSTRSETITEM const&)'

* package version(s): 1.09.0-1
* link to upstream bug report, if any: https://github.com/freebasic/fbc/issues/354

Steps to reproduce: Create a simple file "example.bas" with a line "? Hello World" and feed the compiler with it, and it result in the error. The same happen if you try to build the package from official sources.

Might be some missing dependencies installed on the packagers system but not in a clean environment.
This task depends upon

Closed by  Felix Yan (felixonmars)
Tuesday, 15 February 2022, 23:52 GMT
Reason for closing:  Fixed
Additional comments about closing:  1.09.0-2
Comment by Martin Schnitkemper (Martin-MS) - Monday, 24 January 2022, 12:26 GMT
At least I found the reason why the packge currently can't built: "freebasic" itself is as a dependency, and on the first built the previous version 1.08.1-1 has been used; seen in the packagers BUILDINFO. Since now 1.09.0-1 has been released, this version will now be used, and since it is corrupt, all following builts fail. If I force the installation of version 1.08.1-1 using

| sudo makechrootpkg -cnr $CHROOT -I /var/cache/pacman/pkg/freebasic-1.08.1-1-x86_64.pkg.tar.zst

I was able to build the package. After all, namcap report these warnings:

| freebasic W: ELF file ('usr/bin/fbc') lacks FULL RELRO, check LDFLAGS.
| freebasic W: ELF file ('usr/lib/freebasic/linux-x86_64/fbrt0.o') lacks FULL RELRO, check LDFLAGS.
| freebasic W: ELF file ('usr/lib/freebasic/linux-x86_64/fbrt0pic.o') lacks FULL RELRO, check LDFLAGS.
| freebasic W: ELF file ('usr/lib/freebasic/linux-x86_64/fbrt0.o') is unstripped.
| freebasic W: ELF file ('usr/lib/freebasic/linux-x86_64/fbrt0pic.o') is unstripped.
| freebasic W: ELF file ('usr/bin/fbc') lacks PIE.
| freebasic W: ELF file ('usr/lib/freebasic/linux-x86_64/fbrt0.o') lacks PIE.
| freebasic W: ELF file ('usr/lib/freebasic/linux-x86_64/fbrt0pic.o') lacks PIE.
| freebasic W: Unused shared library '/usr/lib/libdl.so.2' by file ('usr/bin/fbc')

Not sure if it helps, but the warnings belong to the 'fbrt0.o' mentioned in the error while compiling.
Comment by Martin Schnitkemper (Martin-MS) - Tuesday, 25 January 2022, 09:35 GMT
The reason for the problem is that the package has been built with the LTO option, and FreeBasic does not support LTO. For details see the discussion with a FreeBasic contributor at my bugreport on https://github.com/freebasic/fbc/issues/354#issuecomment-1020138372

I could solve the problem while adding

| options=('!lto')

to PKGBUILD and rebuild the package using the last working version 1.08.1-1. After all, I got a working version 1.09.0 now.

I agree with the FreeBasic contributors since they advice to use the bootstrap concept instead of setting a dependency on itself. As we have seen in this case, builds are no longer possible if the previous package is corrupt.
Comment by Martin Schnitkemper (Martin-MS) - Wednesday, 02 February 2022, 10:16 GMT
I attached a modified PKGBUILD as a proposal with the following changes:

* set "options=('!lto')" to prevent the LTO error
* removed the dependency of "freebasic"
* changed the source to the archive that contents the bootstrap and sources
* build the target "bootstrap" as adviced from the FreeBasic developers; it's plain C so there is no more need to have an existing fbc
* compile & install fbc from sources

Feel free to try it out, mandatory is only the first change for a working fbc.
   PKGBUILD (0.9 KiB)
Comment by Felix Yan (felixonmars) - Tuesday, 15 February 2022, 23:52 GMT
Thanks. I have adopted the recommended bootstrap ideas to comments, but we're keeping the old way for now.

Loading...