Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build with LTO enabled #325

Open
txtsd opened this issue Apr 6, 2024 · 7 comments
Open

Unable to build with LTO enabled #325

txtsd opened this issue Apr 6, 2024 · 7 comments
Labels

Comments

@txtsd
Copy link

txtsd commented Apr 6, 2024

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)

@k1gen
Copy link

k1gen commented Apr 30, 2024

+1

@tarkah
Copy link
Member

tarkah commented Apr 30, 2024

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

@k1gen
Copy link

k1gen commented May 1, 2024

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

@txtsd
Copy link
Author

txtsd commented May 2, 2024

@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.

@tarkah
Copy link
Member

tarkah commented May 2, 2024

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?

@k1gen
Copy link

k1gen commented May 6, 2024

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

@txtsd
Copy link
Author

txtsd commented May 15, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants