-
Notifications
You must be signed in to change notification settings - Fork 348
Add a Rust based Wasm language module that supports the component model #1122
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
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
f2e6447
Wasm-wc: Register a new Wasm component model language module type
ac000 f078272
Wasm-wc: Add core configuration data structure
ac000 20ada4b
Wasm-wc: Core of initial Wasm component model language module support
alexcrichton a9345dd
Add a .rustfmt.toml file
ac000 79c8177
Wasm-wc: Run src/lib.rs through rustfmt
ac000 ac3a54d
Wasm-wc: Improve request buffer handling
ac000 98f808a
Wasm-wc: Upgrade to wasmtime 17
ac000 60eb6c4
Wasm-wc: Allow to use the 'reactor' adaptor again
ac000 8d03013
Wasm-wc: Add Cargo.lock
ac000 07a0c9a
Wasm-wc: Wire up the language module to the config system
ac000 da44dc0
Fix alignment of wasm options text in auto/help
ac000 4e6d7e8
Wasm-wc: Wire it up to the build system
ac000 7702293
Docker: Bump rust version to 1.76.0
ac000 1297f6f
Docker: Add wasm-wasi-component to the wasm target
ac000 4c55869
Docker: Re-generate Dockerfile.wasm
ac000 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
max_width = 80 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
# Copyright (C) Andrew Clayton | ||
# Copyright (C) F5, Inc. | ||
|
||
|
||
NXT_WCM_MODULE=wasm-wasi-component | ||
NXT_WCM_MOD_NAME=`echo $NXT_WCM_MODULE | tr '-' '_'`.unit.so | ||
|
||
|
||
shift | ||
|
||
for nxt_option; do | ||
|
||
case "$nxt_option" in | ||
-*=*) value=`echo "$nxt_option" | sed -e 's/[-_a-zA-Z0-9]*=//'` ;; | ||
*) value="" ;; | ||
esac | ||
|
||
case "$nxt_option" in | ||
|
||
--help) | ||
cat << END | ||
|
||
END | ||
exit 0 | ||
;; | ||
|
||
*) | ||
echo | ||
echo $0: error: invalid $NXT_WCM_MODULE option \"$nxt_option\" | ||
echo | ||
exit 1 | ||
;; | ||
esac | ||
|
||
done | ||
|
||
|
||
if [ ! -f $NXT_AUTOCONF_DATA ]; then | ||
echo | ||
echo Please run common $0 before configuring module \"$nxt_module\". | ||
echo | ||
exit 1 | ||
fi | ||
|
||
. $NXT_AUTOCONF_DATA | ||
|
||
NXT_WCM_WASM_TOOLS_BIN=${NXT_WCM_WASM_TOOLS_BIN=} | ||
|
||
|
||
$echo "configuring $NXT_WCM_MODULE module" | ||
$echo "configuring $NXT_WCM_MODULE module ..." >> $NXT_AUTOCONF_ERR | ||
|
||
$echo -n "looking for rust compiler ... " | ||
|
||
if [ -z `which rustc 2>/dev/null` ]; then | ||
$echo "not found." | ||
exit 1; | ||
fi | ||
|
||
$echo "found." | ||
|
||
$echo -n "looking for cargo ... " | ||
|
||
if [ -z `which cargo 2>/dev/null` ]; then | ||
$echo "not found." | ||
exit 1; | ||
fi | ||
|
||
$echo "found." | ||
|
||
|
||
if grep ^$NXT_WCM_MODULE: $NXT_MAKEFILE 2>&1 > /dev/null; then | ||
$echo | ||
$echo $0: error: duplicate \"$NXT_WCM_MODULE\" module configured. | ||
$echo | ||
exit 1; | ||
fi | ||
|
||
|
||
$echo " + $NXT_WCM_MODULE module: $NXT_WCM_MOD_NAME" | ||
|
||
|
||
NXT_OS=$(uname -o) | ||
|
||
if [ $NXT_OS = "Darwin" ]; then | ||
NXT_CARGO_CMD="cargo rustc --release --manifest-path src/wasm-wasi-component/Cargo.toml -- --emit link=target/release/libwasm_wasi_component.so -C link-args='-undefined dynamic_lookup'" | ||
else | ||
NXT_CARGO_CMD="cargo build --release --manifest-path src/wasm-wasi-component/Cargo.toml" | ||
fi | ||
|
||
|
||
cat << END >> $NXT_MAKEFILE | ||
|
||
.PHONY: ${NXT_WCM_MODULE} | ||
.PHONY: ${NXT_WCM_MODULE}-install | ||
.PHONY: ${NXT_WCM_MODULE}-uninstall | ||
|
||
all: ${NXT_WCM_MODULE} | ||
|
||
${NXT_WCM_MODULE}: $NXT_BUILD_DIR/lib/unit/modules/$NXT_WCM_MOD_NAME | ||
|
||
$NXT_BUILD_DIR/lib/unit/modules/$NXT_WCM_MOD_NAME: | ||
make build/src/nxt_unit.o | ||
$NXT_CARGO_CMD | ||
|
||
install: ${NXT_WCM_MODULE}-install | ||
|
||
${NXT_WCM_MODULE}-install: ${NXT_WCM_MODULE} install-check | ||
install -d \$(DESTDIR)$NXT_MODULESDIR | ||
install -p src/wasm-wasi-component/target/release/libwasm_wasi_component.so \\ | ||
\$(DESTDIR)$NXT_MODULESDIR/$NXT_WCM_MOD_NAME | ||
|
||
uninstall: ${NXT_WCM_MODULE}-uninstall | ||
|
||
${NXT_WCM_MODULE}-uninstall: | ||
rm -f \$(DESTDIR)$NXT_MODULESDIR/$NXT_WCM_MOD_NAME | ||
@rmdir -p \$(DESTDIR)$NXT_MODULESDIR 2>/dev/null || true | ||
|
||
END |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ LABEL org.opencontainers.image.url="https://unit.nginx.org" | |
LABEL org.opencontainers.image.source="https://github.com/nginx/unit" | ||
LABEL org.opencontainers.image.documentation="https://unit.nginx.org/installation/#docker-images" | ||
LABEL org.opencontainers.image.vendor="NGINX Docker Maintainers <[email protected]>" | ||
LABEL org.opencontainers.image.version="1.31.1" | ||
LABEL org.opencontainers.image.version="1.32.0" | ||
|
||
RUN set -ex \ | ||
&& savedAptMark="$(apt-mark showmanual)" \ | ||
|
@@ -15,7 +15,7 @@ RUN set -ex \ | |
&& mkdir -p /usr/lib/unit/modules /usr/lib/unit/debug-modules \ | ||
&& mkdir -p /usr/src/unit \ | ||
&& cd /usr/src/unit \ | ||
&& git clone --depth 1 -b 1.31.1-1 https://github.com/nginx/unit \ | ||
&& git clone --depth 1 -b 1.32.0-1 https://github.com/nginx/unit \ | ||
&& cd unit \ | ||
&& NCPU="$(getconf _NPROCESSORS_ONLN)" \ | ||
&& DEB_HOST_MULTIARCH="$(dpkg-architecture -q DEB_HOST_MULTIARCH)" \ | ||
|
@@ -45,7 +45,8 @@ RUN set -ex \ | |
&& make -j $NCPU unitd \ | ||
&& install -pm755 build/sbin/unitd /usr/sbin/unitd \ | ||
&& make clean \ | ||
&& export RUST_VERSION=1.71.0 \ | ||
&& apt-get install --no-install-recommends --no-install-suggests -y libclang-dev \ | ||
&& export RUST_VERSION=1.76.0 \ | ||
&& export RUSTUP_HOME=/usr/src/unit/rustup \ | ||
&& export CARGO_HOME=/usr/src/unit/cargo \ | ||
&& export PATH=/usr/src/unit/cargo/bin:$PATH \ | ||
|
@@ -67,12 +68,12 @@ RUN set -ex \ | |
&& make -C pkg/contrib .wasmtime \ | ||
&& install -pm 755 pkg/contrib/wasmtime/target/release/libwasmtime.so /usr/lib/$(dpkg-architecture -q DEB_HOST_MULTIARCH)/ \ | ||
&& ./configure $CONFIGURE_ARGS_MODULES --cc-opt="$CC_OPT" --modulesdir=/usr/lib/unit/debug-modules --debug \ | ||
&& ./configure wasm --include-path=`pwd`/pkg/contrib/wasmtime/crates/c-api/include --lib-path=/usr/lib/$(dpkg-architecture -q DEB_HOST_MULTIARCH)/ \ | ||
&& make -j $NCPU wasm-install \ | ||
&& ./configure wasm --include-path=`pwd`/pkg/contrib/wasmtime/crates/c-api/include --lib-path=/usr/lib/$(dpkg-architecture -q DEB_HOST_MULTIARCH)/ && ./configure wasm-wasi-component \ | ||
&& make -j $NCPU wasm-install wasm-wasi-component-install \ | ||
&& make clean \ | ||
&& ./configure $CONFIGURE_ARGS_MODULES --cc-opt="$CC_OPT" --modulesdir=/usr/lib/unit/modules \ | ||
&& ./configure wasm --include-path=`pwd`/pkg/contrib/wasmtime/crates/c-api/include --lib-path=/usr/lib/$(dpkg-architecture -q DEB_HOST_MULTIARCH)/ \ | ||
&& make -j $NCPU wasm-install \ | ||
&& ./configure wasm --include-path=`pwd`/pkg/contrib/wasmtime/crates/c-api/include --lib-path=/usr/lib/$(dpkg-architecture -q DEB_HOST_MULTIARCH)/ && ./configure wasm-wasi-component \ | ||
&& make -j $NCPU wasm-install wasm-wasi-component-install \ | ||
&& cd \ | ||
&& rm -rf /usr/src/unit \ | ||
&& for f in /usr/sbin/unitd /usr/lib/unit/modules/*.unit.so; do \ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
target |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
99% of our users will want
wasm-wasi-component
... I wonder if we can signpost this better?Hm. I don't like that either. Food for thought if you have something better that immediately comes to mind.
Not blocking on this feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Users should be consuming it via packages... If they're building from source they hopefully have some idea of what they're doing and then there's documentation...