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

Smir demo #74

Merged
merged 2 commits into from
Apr 19, 2024
Merged

Smir demo #74

merged 2 commits into from
Apr 19, 2024

Conversation

celinval
Copy link
Contributor

@celinval celinval commented Apr 6, 2024

Add a little demo that I've been preparing for the Rust Verification Workshop that could be a good example on how to start using StableMIR.

@celinval
Copy link
Contributor Author

@oli-obk let me know if it would make sense to add this demo here. I was thinking we could use it as the base to a little "Get Started" document.

If we decide to move ahead, I will probably change the workflow to also run nightly against the newest rustc version like the other workflows.

Comment on lines +5 to +14
// Add rustup to the rpath in order to properly link with the correct rustc version.
let rustup_home = env::var("RUSTUP_HOME").unwrap();
let toolchain = env::var("RUSTUP_TOOLCHAIN").unwrap();
let rustc_lib: PathBuf = [&rustup_home, "toolchains", &toolchain, "lib"]
.iter()
.collect();
println!(
"cargo:rustc-link-arg-bin=smir-demo=-Wl,-rpath,{}",
rustc_lib.display()
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something all users need to do? Can we do anything on the rustc side to make this simpler?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think users have to do this if they want to be able to invoke their binaries directly. If you run the program under cargo or rustup run, it should configure the environment correctly for you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I.e.: if you remove this build file, the following still works:

$ cargo run -- --help

But if you run the binary directly:

$ ./target/debug/smir-demo --help
./target/debug/smir-demo: error while loading shared libraries: librustc_driver-a03ea465d8e03db1.so: cannot open shared object file: No such file or directory

@oli-obk oli-obk merged commit ea28c92 into rust-lang:main Apr 19, 2024
4 checks passed
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

Successfully merging this pull request may close these issues.

2 participants