Skip to content

Remove std from libziskos.a#1

Merged
marcinbugaj merged 5 commits into
feature/no-std-compatibilityfrom
feature/no-std-compatibility-1
May 12, 2026
Merged

Remove std from libziskos.a#1
marcinbugaj merged 5 commits into
feature/no-std-compatibilityfrom
feature/no-std-compatibility-1

Conversation

@marcinbugaj
Copy link
Copy Markdown
Collaborator

@marcinbugaj marcinbugaj commented May 12, 2026

Motivation

libziskos.a is a C static archive. As a staticlib crate, the Rust toolchain bundles all transitive object files into it — including those from any dependency that pulls in std. Before this change, zkvm-interface caused 16+ std CGU object files to be included, because its bindgen-generated bindings referenced ::std::os::raw::c_int.

Changes

zkvm-interface: Adding .use_core() to the bindgen builder switches the generated C types from ::std::os::raw to ::core::ffi, after which the crate compiles without std and #![no_std] can be added.

zisk-definitions: Contains only const declarations with no std usage; #![no_std] is added trivially.

ziskos — panic handler: Making zkvm-interface no_std removed the last dependency that implicitly linked the Zisk custom std, which had been providing the #[panic_handler] lang item that the compiler requires for every no_std static library. A panic handler is added to ziskos inside the existing zkvm-gated module. It writes the panic message to UART then calls core::intrinsics::abort(), which the Zisk LLVM backend lowers to the RISC-V unimp instruction — matching the abort_internal() implementation in the Zisk standard library. This handler serves both consumers of ziskos: Rust crate dependents (via the rlib) and C programs linking the archive (where rust_begin_unwind must be resolvable from within the archive itself).

CI check

A step is added to the test-x86_64 job that builds ziskos for the zkvm target and inspects libziskos.a with ar t. Since Rust embeds the crate name in codegen unit filenames, any bundled std object file is immediately identifiable by name. The check fails the build and prints the offending filenames if any are found.

@marcinbugaj marcinbugaj merged commit 9852354 into feature/no-std-compatibility May 12, 2026
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.

1 participant