halloy icon indicating copy to clipboard operation
halloy copied to clipboard

Unable to build with LTO enabled

Open txtsd opened this issue 10 months ago • 7 comments

When compiling with LTO enabled, the build process fails.

See log: https://bpa.st/V4KQ

(Couldn't paste the log directly because it's longer than GitHub's maximum character limit)

txtsd avatar Apr 06 '24 05:04 txtsd

+1

k1gen avatar Apr 30 '24 13:04 k1gen

I cannot reproduce on Linux with cargo build --release --config profile.release.lto=\"on\"

tarkah avatar Apr 30 '24 22:04 tarkah

cargo build --release --config profile.release.lto=\"on\" also works for me, but this doesn't: https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=halloy

k1gen avatar May 01 '24 00:05 k1gen

@tarkah The AUR packages do not build with the lto option which is enabled for makepkg by default. It has to be explicitly disabled for halloy to build. I tried using your --config suggestion in tandem with the lto build option but that doesn't work either.

txtsd avatar May 02 '24 09:05 txtsd

Seems like an issue in the AUR packaging environment then. What linker is being used? Are other rust flags enabled behind the scenes? Which rust version?

tarkah avatar May 02 '24 12:05 tarkah

Seems like an issue in the AUR packaging environment then. What linker is being used? Are other rust flags enabled behind the scenes? Which rust version?

$ cat .cargo/config.toml
[profile.release]
strip = true
lto = "thin"

[build]
rustc-wrapper = "sccache"
$ rustc --version
rustc 1.77.2 (25ef9e3d8 2024-04-09)

I have no idea what linker is being used, the only one I have installed is the GNU ld

k1gen avatar May 06 '24 16:05 k1gen

There's a known bug that LTO does weird things if you

  1. include some C in your rust code
  2. compile with GCC (not clang)
  3. use lto.

Not doing just one of those three appears to "fix" it

See these: https://github.com/gyscos/zstd-rs/issues?q=is%3Aissue+undefined+reference+to

txtsd avatar May 15 '24 06:05 txtsd