Compiler-explorer: Compiling Rust with optimizations leads to no assembly code generated

Created on 25 May 2017  路  3Comments  路  Source: compiler-explorer/compiler-explorer

No matter what sort of Rust code you use, if you add the flags -C opt-level=2, then no assembly will be generated. It still works if you do -C opt-level=0, but not with anything else.

bug lang-rust

Most helpful comment

Hi @Slabity - are you making your function pub ? https://godbolt.org/g/hlWEAy shows you can view code with -C opt-level=2 if the function is public. If it's not public and it is unused, the llvm optimizer removes the function completely.

All 3 comments

Hi @Slabity - are you making your function pub ? https://godbolt.org/g/hlWEAy shows you can view code with -C opt-level=2 if the function is public. If it's not public and it is unused, the llvm optimizer removes the function completely.

Looks like that was probably it. I didn't realize it was compiling as a library and used fn main() without pub.

Thanks for following up. Perhaps I need to make it clearer somehow what's going on!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adiba picture adiba  路  4Comments

mattgodbolt picture mattgodbolt  路  4Comments

yesudeep picture yesudeep  路  4Comments

mattgodbolt picture mattgodbolt  路  4Comments

VivekChugh picture VivekChugh  路  3Comments