rust-lang / rust-lang/rust-playground

Add option for LTO

Open
#273 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Rust
Stars
1.4k
Forks
267
Avg merge
3h 2m
Merged PRs (30d)
6

Description

Sometimes it is interesting to see and discuss the generated assembly for code with LTO turned on. For example, this code:

extern crate itertools;
use itertools::Itertools;

pub fn foo(x: u32, y: u32) -> bool {
    vec![x, y].into_iter().dedup().count() == 1
}

gets compiled down to just x == y when compiled with --release and lto = true, which is pretty wild. But there's no way to share or discuss that easily online, since this site doesn't allow for LTO and godbolt's site doesn't allow for external crate imports. So, it would be nice if this site allowed the users to turn on LTO.

If the top bar is getting too crowded, maybe it makes sense to have a drop-down box where one can specify additional, less-used compiler options? I'm not sure how best to go about this from a UI standpoint but it would be nice to have.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named. Start by locating the Playground's compiler-option controls and the path that handles release settings; trace how an LTO setting could be passed through the UI and compilation flow. Done means users can enable LTO and discuss or reproduce the resulting Rust assembly.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.