You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rust toolchains come with a pre-built shared object file for the standard library, so it seems likely that what we need to do is ship a pre-built goto-c object file for the standard library.
We need a way to build this object file.
We need to ensure we have sufficient and sound program-slicing to cull it down to size, so that unused functions do not blow up verification times.
We can think about pre-linking more things (like "rmc c lib") into it. However if we want to support no_std then maybe not?
It sounds like MIRI does "normal" compilation (to rlib) every step of the way until the very end, where it also pulls in the standard library rlib and then does a final translation to (in our case) goto-c at the end. Needs investigation.
Convert symbol table json files to goto binaries using
cd target/x86_64-unknown-linux-gnu/debug/deps && ls *.symtab.json | parallel -j 16 symtab2gb {} --out {.}.out
but ran into a bunch of issue:
In step 3, got many errors of the form:
error: duplicate lang item in crate `std` (which `kani` depends on): `panic_impl`.
|
= note: the lang item is first defined in crate `std` (which `lstd` depends on)
= note: first definition in `std` loaded from /home/ubuntu/examples/lstd/target/x86_64-unknown-linux-gnu/debug/deps/libstd-9f9e8af9b2102e2a.rmeta
= note: second definition in `std` loaded from /home/ubuntu/.rustup/toolchains/nightly-2022-05-17-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-977ece543e1e3d2f.rlib
error: duplicate lang item in crate `std` (which `kani` depends on): `begin_panic`.
|
= note: the lang item is first defined in crate `std` (which `lstd` depends on)
= note: first definition in `std` loaded from /home/ubuntu/examples/lstd/target/x86_64-unknown-linux-gnu/debug/deps/libstd-9f9e8af9b2102e2a.rmeta
= note: second definition in `std` loaded from /home/ubuntu/.rustup/toolchains/nightly-2022-05-17-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-977ece543e1e3d2f.rlib
error: duplicate lang item in crate `std` (which `kani` depends on): `oom`.
|
= note: the lang item is first defined in crate `std` (which `lstd` depends on)
= note: first definition in `std` loaded from /home/ubuntu/examples/lstd/target/x86_64-unknown-linux-gnu/debug/deps/libstd-9f9e8af9b2102e2a.rmeta
= note: second definition in `std` loaded from /home/ubuntu/.rustup/toolchains/nightly-2022-05-17-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-977ece543e1e3d2f.rlib
error: duplicate lang item in crate `std` (which `kani` depends on): `start`.
|
= note: the lang item is first defined in crate `std` (which `lstd` depends on)
= note: first definition in `std` loaded from /home/ubuntu/examples/lstd/target/x86_64-unknown-linux-gnu/debug/deps/libstd-9f9e8af9b2102e2a.rmeta
= note: second definition in `std` loaded from /home/ubuntu/.rustup/toolchains/nightly-2022-05-17-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-977ece543e1e3d2f.rlib
error: duplicate lang item in crate `std` (which `kani` depends on): `termination`.
|
= note: the lang item is first defined in crate `std` (which `lstd` depends on)
= note: first definition in `std` loaded from /home/ubuntu/examples/lstd/target/x86_64-unknown-linux-gnu/debug/deps/libstd-9f9e8af9b2102e2a.rmeta
= note: second definition in `std` loaded from /home/ubuntu/.rustup/toolchains/nightly-2022-05-17-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-977ece543e1e3d2f.rlib
error: duplicate lang item in crate `core` (which `std` depends on): `sized`.
|
= note: the lang item is first defined in crate `core` (which `std` depends on)
= note: first definition in `core` loaded from /home/ubuntu/examples/lstd/target/x86_64-unknown-linux-gnu/debug/deps/libcore-6d9d14315cbfc8dc.rmeta
= note: second definition in `core` loaded from /home/ubuntu/.rustup/toolchains/nightly-2022-05-17-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-0e3656b1fda5fd7b.rlib
error[E0034]: multiple applicable items in scope
--> src/lib.rs:3:20
|
3 | assert!("2021".parse::<u32>().unwrap() == 2021);
| ^^^^^ multiple `parse` found
|
= note: candidate #1 is defined in an impl for the type `str`
= note: candidate #2 is defined in an impl for the type `str`
For more information about this error, try `rustc --explain E0034`.
Error: "Failed to compile crate."
error: could not compile `lstd` due to 113 previous errors
If I ignore those errors and proceed with step 4, I got some CBMC invariant violations:
I'm closing this issue since users can use --mir-linker to properly link against the standard library. I added all the related issues to the linker stabilization milestone so we don't forget to clean them up.
Activity
tedinski commentedon May 24, 2022
ALTERNATIVELY!
It sounds like MIRI does "normal" compilation (to rlib) every step of the way until the very end, where it also pulls in the standard library rlib and then does a final translation to (in our case) goto-c at the end. Needs investigation.
zhassan-aws commentedon Jun 1, 2022
Attempted to re-do the std library linking experiment using the following steps:
cargo new --lib lstdsrc/lib.rs:but ran into a bunch of issue:
celinval commentedon Oct 11, 2022
I'm closing this issue since users can use
--mir-linkerto properly link against the standard library. I added all the related issues to the linker stabilization milestone so we don't forget to clean them up.