History log of /wasmtime-44.0.1/crates/wizer/examples/cpp/main.cpp (Results 1 – 2 of 2)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: dev, v36.0.9, v44.0.1, v43.0.2, v36.0.8, v24.0.8, v44.0.0, v43.0.1, v42.0.2, v36.0.7, v24.0.7, v43.0.0, v42.0.1, v41.0.4, v42.0.0, v40.0.4, v36.0.6, v24.0.6, v41.0.3, v41.0.2, v41.0.1, v36.0.5, v40.0.3, v41.0.0, v36.0.4, v39.0.2, v40.0.2, v40.0.1, v40.0.0, v39.0.1, v39.0.0, v38.0.4, v37.0.3, v36.0.3, v24.0.5, v38.0.3, v38.0.2, v38.0.1
# 19c3380b 08-Oct-2025 Alex Crichton <[email protected]>

Ignore wizer subdirectory for now

prtest:full


Revision tags: v37.0.2, v37.0.1, v37.0.0, v36.0.2, v36.0.1, v36.0.0, v35.0.0, v24.0.4, v33.0.2, v34.0.2, v34.0.1, v33.0.1, v24.0.3, v32.0.1, v34.0.0, v33.0.0, v32.0.0, v31.0.0, v30.0.2, v30.0.1, v30.0.0, v29.0.1, v29.0.0, v28.0.1, v28.0.0, v27.0.0, v26.0.1, v25.0.3, v24.0.2, v26.0.0, v21.0.2, v22.0.1, v23.0.3, v25.0.2, v24.0.1, v25.0.1, v25.0.0, v24.0.0, v23.0.2, v23.0.1, v23.0.0, v22.0.0, v21.0.1, v21.0.0, v20.0.2, v20.0.1, v20.0.0, v17.0.3, v19.0.2, v18.0.4, v19.0.1, v19.0.0, v18.0.3, v18.0.2, v17.0.2, v18.0.1, v18.0.0, v17.0.1, v17.0.0, v16.0.0, v15.0.1, v15.0.0, v14.0.4, v14.0.3, v14.0.2, v13.0.1, v14.0.1, v14.0.0, minimum-viable-wasi-proxy-serve, v13.0.0, v12.0.2, v11.0.2, v10.0.2, v12.0.1, v12.0.0, v11.0.1, v11.0.0, v10.0.1, v10.0.0, v9.0.4, v9.0.3, v9.0.2, v9.0.1, v9.0.0, v6.0.2, v7.0.1, v8.0.1, v8.0.0, v7.0.0, v6.0.1, v5.0.1, v4.0.1, v6.0.0, v5.0.0, v4.0.0, v3.0.1, v3.0.0, v1.0.2, v2.0.2, v2.0.1, v2.0.0, v1.0.1, v1.0.0, v0.40.1, v0.40.0, v0.39.1, v0.38.3, v0.38.2, v0.39.0, v0.38.1, v0.38.0, v0.37.0, v0.36.0, v0.35.3, v0.34.2, v0.35.2, v0.35.1, v0.35.0, v0.33.1, v0.34.1, v0.34.0, v0.33.0, v0.32.1, v0.32.0, v0.31.0, v0.30.0, v0.29.0, v0.28.0, v0.26.1, v0.27.0, v0.26.0, v0.25.0, v0.24.0, v0.23.0
# 9ab84eea 10-Feb-2021 Chris Fallin <[email protected]>

Add C++ example using function renaming to handle ctors properly.

Previously, it was difficult to properly use Wizer with C++ programs
that have static constructors. These constructors are normally

Add C++ example using function renaming to handle ctors properly.

Previously, it was difficult to properly use Wizer with C++ programs
that have static constructors. These constructors are normally run
before `main()` is invoked by some libc/linker plumbing at the usual
entry point. This causes a set of undesirable problems:

- In the Wizer initialization entry point, our globals' constructors
have not yet run.

- If we manually invoke the constructors to resolve the first issue,
then they will be *re*-invoked when the program's main entry point is
run on the initialized module. This may cause surprising or
inconsistent results.

In order to properly handle this, we add a `wizer.h` header with a
convenient macro that allows specifying a user initialization function,
and adds an exported top-level Wizer initialization entry point and an
exported replacement main entry point.

The generated initialization entry point invokes any global constructors
(using the function `__wasm_call_ctors()` which is generated by
`wasm-ld`) then invokes the user's initialization function.

The generated main entry point is meant to replace `_start` and performs
the same work, *except* that it does not re-invoke constructors.
Instead, it immediately invokes `main()` (because everything has already
been initialized) and then calls destructors and exits.

Taken together, the two entry points match the code that is present in
`_start` in an ordinary Wasm binary compiled by wasi-sdk. This approach
should be relatively stable, as long as the symbols
`__wasm_call_ctors()`, `__wasm_call_dtors()`, and `__original_main()`
are not renamed in the WASI SDK (this seems unlikely).

show more ...