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

Unexpected behavior: cargo rustc -- --emit=llvm-ir #7765

Closed
JOE1994 opened this issue Jan 4, 2020 · 2 comments
Closed

Unexpected behavior: cargo rustc -- --emit=llvm-ir #7765

JOE1994 opened this issue Jan 4, 2020 · 2 comments
Labels
C-bug Category: bug

Comments

@JOE1994
Copy link

JOE1994 commented Jan 4, 2020

Problem

  • Description of bug
    Running cargo rustc -- --emit=llvm-ir does not produce output IR. Instead, a warning message "warning: ignoring emit path because multiple .ll files were produced" is printed out.
    I expected that running cargo rustc -- --emit=llvm-ir would produce an llvm-ir output file.
  • Environments that I tested to reproduce problem
    • Windows 10 OS, rustc 1.42.0-nightly (0de96d37f 2019-12-19), cargo 1.41.0-nightly (626f0f4 2019-12-03)
    • Ubuntu WSL, rustc 1.42.0-nightly (0de96d37f 2019-12-19), cargo 1.41.0-nightly (626f0f4 2019-12-03)

image

Steps

  1. Set up a minimal Rust project as the image above.
  2. Run cargo rustc -- --emit=llvm-ir

Possible Solution(s)
This is not a solution, but running rustc src/main.rs --emit=llvm-ir worked as I expected in both the environments that I tested; llvm-ir output was generated as a file.

Notes

Output of cargo version: cargo 1.41.0-nightly (626f0f4 2019-12-03)

@JOE1994 JOE1994 added the C-bug Category: bug label Jan 4, 2020
@ehuss
Copy link
Contributor

ehuss commented Jan 4, 2020

The .ll files should be in the target\debug\deps directory. (That's where all output goes.)

You may want to turn off incremental compilation (in the profile, or env var), since that changes how rustc splits the code generation (causing multiple files). It is a known issue that incremental causes this: rust-lang/rust#48147

The warning is a false-positive (rust-lang/rust#49801), rustc just seems to be confused when there are multiple .ll files.

@JOE1994
Copy link
Author

JOE1994 commented Jan 4, 2020

@ehuss Thank you for the clarification! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants