Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions codegen/masm/src/artifact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,6 @@ impl fmt::Display for MasmComponent {
use crate::intrinsics::INTRINSICS_MODULE_NAMES;

for module in self.modules.iter() {
// Don't print empty modules
//
// NOTE(pauls): This is a temporary workaround for the fact that component init
// functions require a module, and we are not yet emitting component init functions,
// so the generated module is empty.
if module.exported_procedures().next().is_none() {
continue;
}

// Skip printing the standard library modules and intrinsics
// modules to focus on the user-defined modules and avoid the
// stack overflow error when printing large programs
Expand Down
2 changes: 1 addition & 1 deletion codegen/masm/src/lower/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ impl MasmComponentBuilder<'_> {
let init_body = core::mem::take(&mut self.init_body);
let init = masm::Procedure::new(
Default::default(),
masm::Visibility::Public,
Copy link
Collaborator

Choose a reason for hiding this comment

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

The init procedure needs to be public, so that it can be called from any callable procedure in the component that needs to initialize a fresh context in its prologue.

Copy link
Contributor Author

@greenhat greenhat Sep 17, 2025

Choose a reason for hiding this comment

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

I'm not sure that I understand why init needs to be public. We only invoke the init in our lifted exports functions (see an example at

export.move-asset-to-note
exec.::miden:basic-wallet/[email protected]::init
trace.240
nop
exec.::miden:basic-wallet/[email protected]::basic_wallet::miden:basic-wallet/[email protected]#move-asset-to-note
trace.252
nop
exec.::std::sys::truncate_stack
end
) which we place in the same module. The lifted export function is then called without any prologue and epilogue at the call site. So the lifted export functions are the only public procedures in the component.

See also the discussion that led to making init private at 0xMiden/miden-base#1877

Copy link
Collaborator

Choose a reason for hiding this comment

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

It should be noted that the fact we're emitting a single module for a given Wasm binary is incidental here, it isn't an inherent structural thing, just an artifact of how Rust compiles to Wasm.

In any case, if we can guarantee that all exports from a component (including a program entrypoint, if present), are emitted to the same underlying MASM module, sure, the init procedure can be private in that case. I didn't think that was something we guaranteed, so much as it was a happy accident of how things get compiled from Rust.

I'm fine with making this private until there is an actual issue in practice, but wanted to raise the chance of it being an issue during review to make sure the change is actually well-motivated.

masm::Visibility::Private,
init_name,
0,
masm::Block::new(component.span(), init_body),
Expand Down
1 change: 1 addition & 0 deletions examples/auth-component-no-auth/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
Loading