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
19 changes: 17 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ env:

jobs:
build-std:
name: Build and test (std)
name: Build and test
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -28,7 +28,7 @@ jobs:
- name: Run dylib-tests
run: cargo test -p dylib-tests --features debug-assertions
build-miri:
name: Build and test (Miri)
name: Miri
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -37,6 +37,21 @@ jobs:
components: miri
- name: Build
run: cargo +nightly miri test --features debug-assertions
wasm:
name: WASM
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Test stringleton-registry (Chrome)
run: cd stringleton-registry && wasm-pack test --headless --chrome --features debug-assertions && cd ..
- name: Test stringleton (Chrome)
run: cd stringleton && wasm-pack test --headless --chrome --features debug-assertions && cd ..
- name: Test stringleton-registry (Firefox)
run: cd stringleton-registry && wasm-pack test --headless --firefox --features debug-assertions && cd ..
- name: Test stringleton (Firefox)
run: cd stringleton && wasm-pack test --headless --firefox --features debug-assertions && cd ..
lint:
name: Lint
runs-on: ubuntu-latest
Expand Down
260 changes: 260 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,20 @@ The latter can be supported by the `spin` and `critical-section` features:

Do not use these features unless you are familiar with the tradeoffs.

## WASM caveats

`stringleton` works in WASM binaries, but since the `wasm32-unknown-unknown`
does not support static constructors, the `sym!(..)` macro will fall back to a
slightly slower implementation that uses atomics and a single branch. (Note that
WASM is normally single-threaded, so atomic operations have no overhead.)

Please note that it is *not* possible to pass a `Symbol` across a WASM boundary,
because the host and the guest have different views of memory, and use separate
registries. However, it is possible to pass an opaque `u64` representing the
symbol across such a boundary using `Symbol::to_ffi()` and
`Symbol::try_from_ffi()`. Getting the string representation of the symbol is
only possible on the side that owns the symbol.

## Name

The name is a portmanteau of "string" and "singleton".
3 changes: 3 additions & 0 deletions stringleton-registry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ spin = { version = "0.9.8", optional = true, default-features = false, features
"rwlock",
] }

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test = "0.3"

[features]
default = ["std"]
std = ["alloc"]
Expand Down
Loading