Skip to content

Support and enable LTO by default #1978

Closed

Description

@Keithcat1

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.

Activity

  1. coolreader18 commented on Jul 4, 2020

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

  2. Keithcat1 commented on Aug 6, 2022

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions