Skip to content

Smir linker in python, cargo integration to get all SMIR JSON #608

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

Merged
merged 28 commits into from
Jun 10, 2025

Conversation

jberthold
Copy link
Member

@jberthold jberthold commented Jun 6, 2025

  • code to link together several SMIR JSON files
  • new command kmir link SMIR_JSON1 [SMIR_JSON2 ...] --output OUTPUT_SMIR_JSON
  • Support for getting SMIR JSON from multi-crate projects in CargoProject object
  • small integration test executing a linked program from two crates

Also in this PR:

  • move prove_rs and prove_pinocchio tests up in test-integration for better load distribution

jberthold added 24 commits June 4, 2025 15:52
* Do not use `--release`, as it may introduce constants we cannot currently decode
* cater for the case when a SMIR JSON file does not have types  nor functions
Comment on lines 123 to 161
MULTI_CRATE_DIR = (Path(__file__).parent / 'data' / 'multi-crate').resolve(strict=True)
MULTI_CRATE_TESTS = list(MULTI_CRATE_DIR.glob('*/main-crate'))


@pytest.mark.parametrize(
'main_crate',
MULTI_CRATE_TESTS,
ids=[spec.parent.stem for spec in MULTI_CRATE_TESTS],
)
def test_multi_crate_exec(main_crate: Path, kmir: KMIR, update_expected_output: bool) -> None:
cargo = CargoProject(main_crate)

smirs = cargo.smir_files_for_project(clean=True)

if len(smirs) == 0:
raise Exception('empty smirs')

linked = link([SMIRInfo.from_file(f) for f in smirs])

# results for `run` have unstable IDs so run a termination proof for testing
_, linked_file_str = tempfile.mkstemp()
linked_file = Path(linked_file_str)
linked.dump(linked_file)
opts = ProveRSOpts(linked_file, smir=True)
proof = kmir.prove_rs(opts)

printer = PrettyPrinter(kmir.definition)
cterm_show = CTermShow(printer.print)
display_opts = ShowOpts(linked_file.parent, proof.id, full_printer=False, smir_info=None, omit_current_body=False)
shower = APRProofShow(kmir.definition, node_printer=KMIRAPRNodePrinter(cterm_show, proof, display_opts))
show_res = '\n'.join(shower.show(proof))

os.unlink(linked_file)

assert_or_update_show_output(
show_res,
main_crate.parent / 'output.expected',
update=update_expected_output,
)
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the new test, other changes in this file are just moving existing code.

@jberthold jberthold marked this pull request as ready for review June 9, 2025 08:56
@jberthold jberthold requested review from ehildenb and dkcumming June 9, 2025 08:56
@jberthold
Copy link
Member Author

Tested in kompass on branch [integrate-multi-crate-operations](https://github.com/runtimeverification/kompass/compare/master...integrate-multi-crate-operations) (kompass build, kompass prove`)

@automergerpr-permission-manager automergerpr-permission-manager bot merged commit b1779e1 into master Jun 10, 2025
5 checks passed
@automergerpr-permission-manager automergerpr-permission-manager bot deleted the smir-linker-python branch June 10, 2025 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants