Skip to content

Commit

Permalink
Wasm-wc: Use the cargo build output as the make target dependency
Browse files Browse the repository at this point in the history
cargo build creates the language module under
src/wasm-wasi-component/target/release/libwasm_wasi_component.so and not
build/lib/unit/modules/wasm_wasi_component.unit.so which is what we were
using as a target dependency in the Makefile which doesn't exist so this
resulted in the following

  $ make wasm-wasi-component-install
  cargo build --release --manifest-path src/wasm-wasi-component/Cargo.toml
      Finished release [optimized] target(s) in 0.17s
  install -d /opt/unit/modules
  install -p src/wasm-wasi-component/target/release/libwasm_wasi_component.so \
          /opt/unit/modules/wasm_wasi_component.unit.so

I.e it wanted to rebuild the module, after this patch we get the more
correct

  $ make wasm-wasi-component-install
  install -d /opt/unit/modules
  install -p src/wasm-wasi-component/target/release/libwasm_wasi_component.so \
          /opt/unit/modules/wasm_wasi_component.unit.so

This is all a little ugly because we're fighting against cargo wanting
to do its own thing and this wasm-wasi-component language module build
process is likely going to get some re-working anyway, so this will do
for now.

Reported-by: Konstantin Pavlov <[email protected]>
Signed-off-by: Andrew Clayton <[email protected]>
  • Loading branch information
ac000 committed Feb 22, 2024
1 parent 7b13c30 commit d54af16
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions auto/modules/wasm-wasi-component
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
NXT_WCM_MODULE=wasm-wasi-component
NXT_WCM_MOD_NAME=`echo $NXT_WCM_MODULE | tr '-' '_'`.unit.so

NXT_WCM_MOD_CARGO="src/wasm-wasi-component/target/release/libwasm_wasi_component.so"


shift

Expand Down Expand Up @@ -97,16 +99,16 @@ cat << END >> $NXT_MAKEFILE

all: ${NXT_WCM_MODULE}

${NXT_WCM_MODULE}: $NXT_BUILD_DIR/lib/unit/modules/$NXT_WCM_MOD_NAME
${NXT_WCM_MODULE}: ${NXT_WCM_MOD_CARGO}

$NXT_BUILD_DIR/lib/unit/modules/$NXT_WCM_MOD_NAME: build/src/nxt_unit.o
${NXT_WCM_MOD_CARGO}: 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 \\
install -p ${NXT_WCM_MOD_CARGO} \\
\$(DESTDIR)$NXT_MODULESDIR/$NXT_WCM_MOD_NAME

uninstall: ${NXT_WCM_MODULE}-uninstall
Expand Down

0 comments on commit d54af16

Please sign in to comment.