Skip to content
Closed
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
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ rustflags = ["-C", "link-args=-Wl,-undefined,dynamic_lookup"]

[target.aarch64-apple-darwin]
rustflags = ["-C", "link-args=-Wl,-undefined,dynamic_lookup"]

[target.wasm32-wasip1-threads]
rustflags = ["--cfg", "tokio_unstable"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is, as per the name, unstable. The whole capability architecture was made so that we did not need to either compile to wasi nor have unstable/nightly features enabled. I'm not opposing this change of direction, but it has to be thought-out properly.

4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
- run: yarn install
- run: yarn install
working-directory: test/crashtracker
- run: npm ci --prefix packages/libdatadog
- run: yarn lint

build-libdatadog:
Expand All @@ -31,7 +32,6 @@ jobs:
- name: Validate artifact dependencies
run: npm run check:dependencies
- run: npm ci --prefix packages/libdatadog
- run: cargo install wasm-pack --version 0.14.0 --locked
- run: cargo install cargo-bloat --version 0.12.1 --locked
- run: npm run build --prefix packages/libdatadog
- name: Report N-API binary size
Expand All @@ -41,7 +41,7 @@ jobs:
- name: Report and validate WASM binary size
run: >-
npm run report:wasm-size --prefix packages/libdatadog --
../../target/size/libdatadog_wasm_bg.wasm
../../target/size/libdatadog.wasm
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: libdatadog-wasm
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ jobs:
with:
node-version: 24
- name: Add WASM target
run: rustup target add wasm32-unknown-unknown
run: rustup target add wasm32-wasip1-threads
- run: npm ci --prefix packages/libdatadog
- run: cargo install wasm-pack --version 0.14.0 --locked
- name: Set package version
run: node packages/libdatadog/scripts/set-version.js '${{ needs.versions.outputs.version }}'
- run: npm run build:wasm --prefix packages/libdatadog
Expand Down
187 changes: 174 additions & 13 deletions Cargo.lock

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

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ lto = true
opt-level = "z"
panic = "abort"
strip = true

[profile.profiling]
inherits = "release"
debug = true
strip = false
2 changes: 2 additions & 0 deletions LICENSE-3rdparty.csv
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ dispatch2,https://github.com/madsmtm/objc2,Zlib OR Apache-2.0 OR MIT,"Mads Marqu
displaydoc,https://github.com/yaahc/displaydoc,MIT OR Apache-2.0,Jane Lusby <jlusby@yaah.dev>
dyn-clone,https://github.com/dtolnay/dyn-clone,MIT OR Apache-2.0,David Tolnay <dtolnay@gmail.com>
either,https://github.com/rayon-rs/either,MIT OR Apache-2.0,bluss
emnapi,https://github.com/toyobayashi/emnapi,MIT,Toyobayashi
equivalent,https://github.com/indexmap-rs/equivalent,Apache-2.0 OR MIT,The equivalent Authors
errno,https://github.com/lambda-fairy/rust-errno,MIT OR Apache-2.0,"Chris Wong <lambda.fairy@gmail.com>, Dan Gohman <dev@sunfishcode.online>"
fallible-iterator,https://github.com/sfackler/rust-fallible-iterator,MIT OR Apache-2.0,Steven Fackler <sfackler@gmail.com>
Expand Down Expand Up @@ -152,6 +153,7 @@ napi,https://github.com/napi-rs/napi-rs,MIT,"Nathan Sobo <nathan@github.com>, Yi
napi-derive,https://github.com/napi-rs/napi-rs,MIT,"LongYinan <lynweklm@gmail.com>, Forehalo <forehalo@gmail.com>"
napi-derive-backend,https://github.com/napi-rs/napi-rs,MIT,The napi-derive-backend Authors
napi-sys,https://github.com/napi-rs/napi-rs,MIT,LongYinan <lynweklm@gmail.com>
napi-wasm-runtime,https://github.com/napi-rs/napi-rs/tree/main/wasm-runtime,MIT,LongYinan
nix,https://github.com/nix-rust/nix,MIT,The nix-rust Project Developers
nu-ansi-term,https://github.com/nushell/nu-ansi-term,MIT,"ogham@bsago.me, Ryan Scheel (Havvy) <ryan.havvy@gmail.com>, Josh Triplett <josh@joshtriplett.org>, The Nushell Project Developers"
num-conv,https://github.com/jhpratt/num-conv,MIT OR Apache-2.0,Jacob Pratt <jacob@jhpratt.dev>
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ The universal package is maintained under
backends expose the agentless data pipeline, Zstandard compression, and
DDSketch from a single native or WASM artifact.

The package tries a platform-native napi-rs backend first. Native artifacts are
published as optional dependencies using napi-rs-compatible package names such
as `@datadog/libdatadog-linux-x64-gnu`. If the platform package cannot be
loaded, the package falls back to a wasm-bindgen backend whose WebAssembly bytes
are embedded in JavaScript. This fallback is always part of the metapackage, so
it also works when native extensions are unavailable, omitted by a bundler, or
moved to another platform.
The package uses one napi-rs binding crate for both native and WASM artifacts.
Native artifacts are published as optional dependencies using napi-rs-compatible
package names such as `@datadog/libdatadog-linux-x64-gnu`. If the platform
package cannot be loaded, the package falls back to the WASM build of the same
bindings. Its WebAssembly bytes and emnapi runtime are embedded in JavaScript,
so the fallback also works when native extensions are unavailable, omitted by
a bundler, or moved to another platform.

See the [package README](packages/libdatadog/README.md) for implementation and
packaging details.
Expand Down
9 changes: 9 additions & 0 deletions crates/libdatadog-wasm-bindgen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "libdatadog-wasm-bindgen"
version = "0.1.0"
edition = "2021"
publish = false

[dependencies]
anyhow = "1"
wasm-bindgen-cli-support = "=0.2.127"
Loading
Loading