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

What's the right way to install/build with lto? #7539

Closed
elichai opened this issue Oct 24, 2019 · 3 comments
Closed

What's the right way to install/build with lto? #7539

elichai opened this issue Oct 24, 2019 · 3 comments

Comments

@elichai
Copy link

elichai commented Oct 24, 2019

Hi,
I want to use LTO when i'm installing crates but doing the naive RUSTFLAGS=-Clto cargo install something doesn't quite work, it seems to fail on proc-macros

Example:

$ RUSTFLAGS=-Clto cargo install ripgrep
    Updating crates.io index
  Installing ripgrep v11.0.2
   Compiling byteorder v1.3.2
   Compiling proc-macro2 v1.0.6
   Compiling memchr v2.2.1
   Compiling encoding_rs v0.8.20
   Compiling libc v0.2.65
   Compiling unicode-xid v0.2.0
   Compiling lazy_static v1.4.0
   Compiling ryu v1.0.2
   Compiling serde v1.0.101
   Compiling syn v1.0.5
   Compiling bitflags v1.2.1
   Compiling log v0.4.8
   Compiling cfg-if v0.1.10
   Compiling unicode-width v0.1.6
   Compiling regex-syntax v0.6.12
   Compiling bytecount v0.5.1
   Compiling itoa v0.4.4
   Compiling strsim v0.8.0
   Compiling fnv v1.0.6
   Compiling termcolor v1.0.5
   Compiling same-file v1.0.5
   Compiling thread_local v0.3.6
   Compiling textwrap v0.11.0
   Compiling crossbeam-utils v0.6.6
   Compiling walkdir v2.2.9
   Compiling crossbeam-channel v0.3.9
   Compiling encoding_rs_io v0.1.6
   Compiling memmap v0.7.0
   Compiling atty v0.2.13
   Compiling num_cpus v1.10.1
   Compiling quote v1.0.2
   Compiling clap v2.33.0
   Compiling aho-corasick v0.7.6
   Compiling grep-matcher v0.1.3
   Compiling serde_json v1.0.41
   Compiling ripgrep v11.0.2
   Compiling regex v1.3.1
   Compiling grep-regex v0.1.5
   Compiling regex-automata v0.1.8
   Compiling base64 v0.10.1
   Compiling bstr v0.2.8
   Compiling serde_derive v1.0.101
   Compiling grep-searcher v0.1.6
   Compiling globset v0.4.4
   Compiling grep-cli v0.1.3
   Compiling ignore v0.4.10
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 `serde_derive`.
warning: build failed, waiting for other jobs to finish...
error: failed to compile `ripgrep v11.0.2`, intermediate artifacts can be found at `/tmp/cargo-installKaYQ3b`

Caused by:
  build failed
@ehuss
Copy link
Contributor

ehuss commented Oct 24, 2019

This is supported with the config profile feature:

CARGO_PROFILE_RELEASE_LTO=true cargo +nightly install ripgrep -Zconfig-profile

@ehuss
Copy link
Contributor

ehuss commented Nov 8, 2019

I'm going to close this in favor of issues like #6375 and rust-lang/rust#48683.

@ehuss ehuss closed this as completed Nov 8, 2019
@elichai
Copy link
Author

elichai commented Nov 21, 2019

For future searchers this is the easiest method I've found on stable: RUSTFLAGS=-Clto cargo install ripgrep --target x86_64-unknown-linux-gnu

Thanks: #6375 (comment)

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

No branches or pull requests

2 participants