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
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ jobs:
run: |
./ci/vendor-wit.sh
git diff --exit-code
- run: cargo install wit-bindgen-cli@0.39.0 --locked
- run: cargo install wit-bindgen-cli@0.45.0 --locked
- run: ./ci/regenerate.sh
- run: git diff --exit-code
9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,18 @@ wasi = { version = "0.14", path = ".", default-features = false }
members = ["./crates/*"]

[dependencies]
wit-bindgen-rt = { version = "0.39.0", features = ["bitflags"] }
wit-bindgen = { version = "0.45.0", default-features = false }

# When built as part of libstd
core = { version = "1.0", optional = true, package = "rustc-std-workspace-core" }
rustc-std-workspace-alloc = { version = "1.0", optional = true }
alloc = { version = "1.0", optional = true, package = "rustc-std-workspace-alloc" }

[features]
default = ["std"]
default = ["std", "bitflags"]
std = []
bitflags = ["wit-bindgen/bitflags"]
# Unstable feature to support being a libstd dependency
rustc-dep-of-std = ["core", "rustc-std-workspace-alloc"]
rustc-dep-of-std = ["core", "alloc", "wit-bindgen/rustc-dep-of-std"]

[[example]]
name = "cli-command-no_std"
Expand Down
8 changes: 6 additions & 2 deletions ci/regenerate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ set -ex
generate() {
file="$1"
shift
wit-bindgen rust wit --async none --out-dir src --std-feature "$@" --format \
--runtime-path wit_bindgen_rt
wit-bindgen rust wit --out-dir src --std-feature "$@" --format

sed -z -i 's/#\[unsafe(\n link_section = "\(.*\)"\n)\]/\
#[cfg_attr(feature = "rustc-dep-of-std", unsafe(link_section = "\1-in-libstd"))]\
#[cfg_attr(not(feature = "rustc-dep-of-std"), unsafe(link_section = "\1"))]\
/' $file
Copy link
Member

Choose a reason for hiding this comment

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

Can you use wit-bindgen's --type-section-suffix flag to add the suffix?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh we actually already use it but the problem here is that it needs a different suffix depending on whether rustc-dep-of-std is enabled or not (to have one name when depended on by libstd and another name when normally used from crates.io)

}

# Generate the main body of the bindings which includes all imports from the two
Expand Down
Loading