Skip to content

Conversation

@aduh95
Copy link
Contributor

@aduh95 aduh95 commented Aug 18, 2025

Without this change, I'm unable to build node with --shared-uvwasi.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/gyp

@nodejs-github-bot nodejs-github-bot added build Issues and PRs related to build files or the CI. needs-ci PRs that need a full CI run. labels Aug 18, 2025
@richardlau
Copy link
Member

Without this change, I'm unable to build node with --shared-uvwasi.

That's odd because we don't have to add other dependencies like openssl, c-ares, etc, in this place when using --shared. The gyp file is included in

node/node.gypi

Lines 212 to 214 in 3a5c262

[ 'node_shared_uvwasi=="false"', {
'dependencies': [ 'deps/uvwasi/uvwasi.gyp:uvwasi' ],
}],

but conditional on node_shared_uvwasi=="false". If building with --shared-uvwasi you should either have pkg_config set up to point to the includes/libraries for the shared uvwasi or manually configure those via arguments to configure.py.

@aduh95
Copy link
Contributor Author

aduh95 commented Aug 18, 2025

If building with --shared-uvwasi you should either have pkg_config set up to point to the includes/libraries for the shared uvwasi or manually configure those via arguments to configure.py.

That's what I am doing in https://github.com/aduh95/node/actions/runs/17038332094/job/48295920942, as you can see node_shared_uvwasi is set to 'true', the LD flags list contains -L/nix/store/20v34va6hya6lcayl0w3a8y6y32881jf-uvwasi-0.0.22/lib -luvwasi, and yet:

FAILED: node_mksnapshot 
/nix/store/479ladh0c73qdmwz3vmnjhjgckgqgf3q-sccache-0.10.0/bin/sccache clang++ -Wl,-force_load,libv8_snapshot.a -Wl,-search_paths_first -mmacosx-version-min=13.5 -arch arm64 -L./ -stdlib=libc++ -o node_mksnapshot obj/src/node_mksnapshot.node_snapshot_stub.o obj/tools/snapshot/node_mksnapshot.node_mksnapshot.o libnode.a libhistogram.a libnbytes.a libncrypto.a libv8_snapshot.a libv8_libplatform.a libabseil.a libcrdtp.a libv8_base_without_compiler.a libv8_libbase.a libv8_zlib.a libhighway.a libsimdutf.a libv8_compiler.a libv8_initializers.a libv8_initializers_slow.a  -L/nix/store/k7jkicn0ld7461m2p92xyh49rak8drzn-zlib-1.3.1/lib -lz -L/nix/store/mca4ahbzg0bkvrj8zs5vwl6n7nvnjjip-llhttp-9.3.0/lib -lllhttp -L/nix/store/y1czw9fryif402z8lkv3fc0dfysqgic7-libuv-1.51.0/lib -luv -L/nix/store/a8hzh8mvb5w0zm1584864r0pwdbk314k-ada-3.2.7/lib -lada -L/nix/store/whsq4yz86k6q7wm123bwk2r1pgbx2r5r-simdjson-3.13.0/lib -lsimdjson -L/nix/store/jp76w3w3xdj4gjnw9h8mx0cckclfdp7i-simdutf-6.5.0/lib -lsimdutf -L/nix/store/dhnid58km9chl2kx87gjkp80jdlbxdrq-brotli-1.1.0-lib/lib -lbrotlidec -lbrotlienc -L/nix/store/a7p9wyv6s2j8g94j2r2lv97k3qcpnx81-c-ares-1.34.5/lib -lcares -L/nix/store/9yf4s4ds7qdsc9w2477kidlcjq08s76h-nghttp2-1.65.0-lib/lib -lnghttp2 -L/nix/store/iw33fy5d3g6ahs0l7wjl2kdr7ii5qmgp-nghttp3-1.11.0/lib -lnghttp3 -L/nix/store/1xz94ac8a5wc0vwk5kk3fsf9mnrmxb1h-ngtcp2-1.14.0/lib -lngtcp2 -L/nix/store/73iiazjcn1qscb8m0l5f3jg56vjgwxbj-sqlite-3.50.2/lib -lsqlite3 -L/nix/store/20v34va6hya6lcayl0w3a8y6y32881jf-uvwasi-0.0.22/lib -luvwasi -L/nix/store/0xirya2s5pi6xpq757g8a5ljlxzkp3vg-zstd-1.5.7/lib -lzstd -L/nix/store/v7ip9q2908xcmq4i9wray4w1g81qb3sc-openssl-3.5.1/lib -lcrypto -lssl -L/nix/store/nhfd5kvyr9p958cvvbd6sjccwh9ycwb6-icu4c-76.1/lib -licui18n -licuuc -framework CoreFoundation -framework Security
Undefined symbols for architecture arm64:
  "_uvwasi_args_get", referenced from:
      node::wasi::WASI::ArgsGet(node::wasi::WASI&, node::wasi::WasmMemory, unsigned int, unsigned int) in libnode.a(libnode.node_wasi.o)
  "_uvwasi_args_sizes_get", referenced from:
      node::wasi::WASI::ArgsSizesGet(node::wasi::WASI&, node::wasi::WasmMemory, unsigned int, unsigned int) in libnode.a(libnode.node_wasi.o)
  "_uvwasi_clock_res_get", referenced from:
      node::wasi::WASI::ClockResGet(node::wasi::WASI&, node::wasi::WasmMemory, unsigned int, unsigned int) in libnode.a(libnode.node_wasi.o)
  "_uvwasi_clock_time_get", referenced from:
      node::wasi::WASI::ClockTimeGet(node::wasi::WASI&, node::wasi::WasmMemory, unsigned int, unsigned long long, unsigned int) in libnode.a(libnode.node_wasi.o)
  "_uvwasi_destroy", referenced from:
      node::wasi::WASI::~WASI() in libnode.a(libnode.node_wasi.o)
  "_uvwasi_embedder_err_code_to_string", referenced from:
      node::wasi::WASIException(v8::Local<v8::Context>, int, char const*) in libnode.a(libnode.node_wasi.o)
  "_uvwasi_environ_get", referenced from:
      node::wasi::WASI::EnvironGet(node::wasi::WASI&, node::wasi::WasmMemory, unsigned int, unsigned int) in libnode.a(libnode.node_wasi.o)
  "_uvwasi_environ_sizes_get", referenced from:
      node::wasi::WASI::EnvironSizesGet(node::wasi::WASI&, node::wasi::WasmMemory, unsigned int, unsigned int) in libnode.a(libnode.node_wasi.o)
  "_uvwasi_fd_advise", referenced from:
      node::wasi::WASI::FdAdvise(node::wasi::WASI&, node::wasi::WasmMemory, unsigned int, unsigned long long, unsigned long long, unsigned int) in libnode.a(libnode.node_wasi.o)
  "_uvwasi_fd_allocate", referenced from:
      node::wasi::WASI::FdAllocate(node::wasi::WASI&, node::wasi::WasmMemory, unsigned int, unsigned long long, unsigned long long) in libnode.a(libnode.node_wasi.o)
  "_uvwasi_fd_close", referenced from:
      node::wasi::WASI::FdClose(node::wasi::WASI&, node::wasi::WasmMemory, unsigned int) in libnode.a(libnode.node_wasi.o)
…

Applying this patch fixes the build – FWIW I also tried adding it as a dependency of node_mksnapshot, but then another target was failing, I don't remember which one (cctest maybe).

That's odd because we don't have to add other dependencies like openssl, c-ares, etc, in this place when using --shared.

I definitely agree that this is odd, and I can't explain why I don't need it for the other shared dependency I'm using. I can confirm uvwasi is the only one that need special treatment.

@legendecas
Copy link
Member

legendecas commented Aug 19, 2025

For --shared-* dependencies, their libraries are configured with --shared-*-includes, --shared-*-libpath and --shared-*-libname at

node/configure.py

Lines 1747 to 1761 in 3f51cb6

# libpath needs to be provided ahead libraries
if options.__dict__[shared_lib + '_libpath']:
if flavor == 'win':
if 'msvs_settings' not in output:
output['msvs_settings'] = { 'VCLinkerTool': { 'AdditionalOptions': [] } }
output['msvs_settings']['VCLinkerTool']['AdditionalOptions'] += [
f"/LIBPATH:{options.__dict__[shared_lib + '_libpath']}"]
else:
output['libraries'] += [
f"-L{options.__dict__[shared_lib + '_libpath']}"]
elif pkg_libpath:
output['libraries'] += [pkg_libpath]
default_libs = getattr(options, shared_lib + '_libname')
default_libs = [f'-l{l}' for l in default_libs.split(',')]

They are not listed as a gyp dependency.

If the shared library path and include dir are not specified when running ./configure, configure.py will try to find it with pkg-config. However, the script didn't raise an exception if both are not found and lead to link error. Maybe configure.py can raise an exception if either the path is not specified and pkg-config was not found.

Copy link
Member

@legendecas legendecas left a comment

Choose a reason for hiding this comment

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

See #59524 (comment). I think this is not the correct fix.

@richardlau
Copy link
Member

Applying this patch fixes the build – FWIW I also tried adding it as a dependency of node_mksnapshot, but then another target was failing, I don't remember which one (cctest maybe).

Applying this patch isn't going to do what is intended -- it's going to build the in-tree uvwasi and link to that instead of the shared library.

@aduh95
Copy link
Contributor Author

aduh95 commented Aug 19, 2025

Closing in favor of nodejs/uvwasi#308. Thanks for the help!

@aduh95 aduh95 closed this Aug 19, 2025
@aduh95 aduh95 deleted the uvwasi-build-deps branch August 19, 2025 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Issues and PRs related to build files or the CI. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants