question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rust compiler-explorer produce error with -g or no output with -O

See original GitHub issue

When I use the below valid code written in Rust, I see assembly generated - it’s all good. I use the default GUI options of compiler-explorer and no compiler options. However, if I use the compiler option:

  • -g, the result is <Compilation failed>.
  • -O, the result is 7 empty lines.

In both cases, I expect to see assembly code.

fn main() {
    let mut sum: u32 = 0;
    let (from, to) = (0, 500);

    for i in from..to {
        sum += i;
    }

    println!("{}", sum) // 124750
}

https://godbolt.org/g/QgcCMQ

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ludwigpacificicommented, Feb 20, 2017

I agree. To save place on screen, these hard coded options required for compiler-explorer could be toggled between a “…” and the hidden options.

An ASCII drawing of the compiler and its options. Default view will hide the required options. Example with rust:

|------------------------------------------|
| rustc 1.15.1 | ... | compiler options... |
|------------------------------------------|
|                 <asm code>               |
|------------------------------------------|

If I clic on “…”, the compiler bar would become for example a read only text showing hidden options:

|------------------------------------------------------------------------------------|
| rustc 1.15.1 | -g --emit=asm --crate-type rlib -o <filename> | compiler options... |
|------------------------------------------------------------------------------------|
|                                     <asm code>                                     |
|------------------------------------------------------------------------------------|

Tell me if my ASCII drawings are not clear enough.

0reactions
mattgodboltcommented, Oct 26, 2019

It’s not quite what you wanted but if you click on the compilation results indicator (between the compiler selection dropdown and the flags) you see all the options we pass. I hope this is good enough: If you feel strongly that this doesn’t quite cover your idea then please reply and we’ll consider alternatives. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rust compiler-explorer produce error with -g or no output with -O
I use the default GUI options of compiler-explorer and no compiler options. However, if I use the compiler option: -g , the result...
Read more >
Rust @godbolt - Compiler Explorer
Compiler Explorer is an interactive online compiler which shows the assembly output of compiled C++, Rust, Go (and many more) code.
Read more >
Why doesn't the Godbolt compiler explorer show any output ...
When I compile in release mode by passing -O to the compiler, there is no output at all! What am I doing wrong?...
Read more >
Optimizations in C++ Compilers - ACM Queue
The golden rule for helping the compiler optimize is to ensure it has as much information as possible to make the right optimization...
Read more >
Compiler... hanging? - help
Hey, I'm fairly new to rust, but using Advent of Code to go deeper into the language. I wrote this solution to today's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found