Skip to content

Support and enable LTO by default #1978

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

Closed
Keithcat1 opened this issue Jul 4, 2020 · 2 comments · Fixed by #3470
Closed

Support and enable LTO by default #1978

Keithcat1 opened this issue Jul 4, 2020 · 2 comments · Fixed by #3470

Comments

@Keithcat1
Copy link

In order to reduce size and maybe increase performance, link-time-optimization could be enabled.
I tried these commands:
set RUSTFLAGS=-Clto
cargo install rustpython

I got this error:
error: cannot prefer dynamic linking when performing LTO

note: only 'staticlib', 'bin', and 'cdylib' outputs are supported with LTO

error: aborting due to previous error

error: could not compile proc-macro-hack.

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: failed to compile rustpython v0.1.2, intermediate artifacts can be found at C:\Users\Keith\AppData\Local\Temp\cargo-installbvSdKc

Caused by:
build failed
I'm on windows. This problem seems to be with both theh Mingw and MSVC toolchains.

@coolreader18
Copy link
Member

Try just adding the following to Cargo.toml:

[profile.release]
lto = true

That's how you generally add lto to a cargo project, I think.

@Keithcat1
Copy link
Author

Forgot about this one. I n the meantime I elarned that you can also set the environment variable "CARGO_PROFILE_RELEASE_LTO" to "on" and that also enables LTO. Doing it with RUSTFLAGS as I did above is probably not a good idea.

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

Successfully merging a pull request may close this issue.

2 participants