Skip to content

Restructure building the C API #7341

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 1 commit into from
Oct 24, 2023

Conversation

alexcrichton
Copy link
Member

This commit introduces a wrapper crate which is now the new "real" C API. The purpose of this change is to enable using LTO when building the C API. Currently LTO is disabled because one of the crate types of the C API is an "rlib" which means that it can't have LTO performed due to rustc limitations. The solution here is to remove the "cdylib" and "staticlib" crate types from the "wasmtime-c-api" crate and introduce a new crate 'wasmtime-c-api-artfact' which wraps the previous crate and reexports it.

This way LTO can be enabled when just building the artifacts and the use case from #6765 is still satisfied by having a crate that can be linked to from Rust. Locally this reduces the size of the C API artifact for me by nearly 1M.

@alexcrichton alexcrichton marked this pull request as ready for review October 23, 2023 22:23
@alexcrichton alexcrichton requested review from a team as code owners October 23, 2023 22:23
@alexcrichton alexcrichton requested review from pchickey and removed request for a team October 23, 2023 22:23
Copy link
Contributor

@pchickey pchickey left a comment

Choose a reason for hiding this comment

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

Looks good to me, my only question is the naming - would it make more sense to rename the current wasmtime-c-api crate something like wasmtime-c-api-impl so that users of wasmtime-c-api, which becomes this new trivial facade, don't need to make any changes in order to benefit from this?

@github-actions github-actions bot added the wasmtime:c-api Issues pertaining to the C API. label Oct 24, 2023
@github-actions
Copy link

Subscribe to Label Action

cc @peterhuene

This issue or pull request has been labeled: "wasmtime:c-api"

Thus the following users have been cc'd because of the following labels:

  • peterhuene: wasmtime:c-api

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

This commit introduces a wrapper crate which is now the new "real" C
API. The purpose of this change is to enable using LTO when building the
C API. Currently LTO is disabled because one of the crate types of the C
API is an "rlib" which means that it can't have LTO performed due to
rustc limitations. The solution here is to remove the "cdylib" and
"staticlib" crate types from the "wasmtime-c-api" crate, rename that
crate to "wasmtime-c-api-impl", and reintroduce 'wasmtime-c-api' as a
new crate which wraps the previous crate and reexports it.

This way LTO can be enabled when just building the artifacts and the use
case from bytecodealliance#6765 is still satisfied by having a crate that can be linked
to from Rust. Locally this reduces the size of the C API artifact for me
by nearly 1M.
@alexcrichton
Copy link
Member Author

Good idea! I've switched to that naming scheme instead

@alexcrichton alexcrichton added this pull request to the merge queue Oct 24, 2023
Merged via the queue into bytecodealliance:main with commit 282edac Oct 24, 2023
@alexcrichton alexcrichton deleted the lto-c-api branch October 24, 2023 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wasmtime:c-api Issues pertaining to the C API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants