componentize-py icon indicating copy to clipboard operation
componentize-py copied to clipboard

Build error: configure: error: You must get working getaddrinfo() function or pass the "--disable-ipv6" option to configure.

Open nullie opened this issue 11 months ago • 3 comments

I'm trying to build componentize-py with Nix and encountered the following problem. Am I missing something or maybe doing something obviously wrong?

Build error:

       > error: failed to run custom build command for `componentize-py v0.16.0 (/build/source)`
       >
       > Caused by:
       >   process didn't exit successfully: `/build/source/target/release/build/componentize-py-a59959045623dda0/build-script-build` (exit status: 1)
       >   --- stdout
       >   cargo:rerun-if-changed=build.rs
       >
       >   --- stderr
       >   Error: command `../../Tools/wasm/wasi-env ../../configure -C --host=wasm32-unknown-wasi --build=x86_64-pc-linux-gnu
       >    --with-build-python=/build/source/cpython/builddir/wasi/../build/python --prefix=/build/source/cpython/builddir/wasi/install --disable-test-modules --enable-ipv6` failed: configure: error: You must get working getaddrinfo() function or pass the "--disable-ipv6" option to configure.
       >
       > 💥 maturin failed
       >   Caused by: Failed to build a native library through cargo
       >   Caused by: Cargo build finished with "exit status: 101": `env -u CARGO "cargo" "rustc" "--jobs" "16" "--features" "pyo3/extension-module" "--target" "x86_64-unknown-linux-gnu" "--message-format" "json-render-diagnostics" "--offline" "--manifest-path" "/build/source/Cargo.toml" "--release" "--lib" "--crate-type" "cdylib" "--" "-C" "strip=symbols"`

I've dug a bit, and configure fails because netdb.h header is missing:

cpython/builddir/wasi/config.log
<snip>
configure:22403: checking for getaddrinfo
configure:22426: /nix/store/jflmkk9kx2cw7qwxij7iw9fzphjv194s-wasi-sdk-wasi-sockets-alpha-5/opt/wasi-sdk/bin/clang --sysroot=/nix/store/jflmkk9kx2cw7qwxij7iw9fzphjv194s-wasi-sdk-wasi-sockets-alpha-5/opt/wasi-sdk/share/wasi-sysroot -o conftest    conftest.c -ldl  -lwasi-emulated-signal -lwasi-emulated-getpid -lwasi-emulated-process-clocks >&5
conftest.c:201:10: fatal error: 'netdb.h' file not found
  201 | #include <netdb.h>
      |          ^~~~~~~~~
1 error generated.
<snip>

I'm using wasi-sockets-alpha-5 tag (f3a1f89915357e0b00fb269a34f92b6d0bafd4c1) for wasi-sdk, as specified in CONTRIBUTING.md. It seem to omit netdb.h for target wasm32-wasip1 , which is synonymous with wasm32-wasi:

wasi-sdk/src/wasi-libc/Makefile
<snip>
ifeq ($(WASI_SNAPSHOT), p1)
MUSL_OMIT_HEADERS += "netdb.h"
endif
<snip>

componentize-py revision: https://github.com/bytecodealliance/componentize-py/commit/c50822c825b4333ff41a0ea3cd9e0c9bc3df49da wasi-sdk revision: https://github.com/dicej/wasi-sdk/commit/f3a1f89915357e0b00fb269a34f92b6d0bafd4c1

nullie avatar Jan 03 '25 20:01 nullie

Hi @nullie. Thanks for reporting this.

As you noted, componentize-py uses forks of both CPython and WASI-SDK. When I published the artifacts for https://github.com/dicej/wasi-sdk/releases/tag/wasi-sockets-alpha-5, I ran the following to make wasm32-wasi an alias for wasm32-wasip2 instead of wasm32-wasip1.

cd share/wasi-sysroot
for x in include lib share; do rm -r $x/wasm32-wasi && mv $x/wasm32-wasip2 $x/wasm32-wasi; done

That tricks CPython into using the WASIp2 build of wasi-libc, which has much more complete socket support (including netdb.h). Eventually, I hope CPython will adopt WASIp2 natively, but that hasn't happened yet.

Since you're building the fork from source rather than using one of the pre-built artifacts, you'll need to run the above for loop yourself before building CPython.

Hope that helps!

dicej avatar Jan 03 '25 21:01 dicej

Thanks, does that mean I can use upstream wasi-sdk with this alias or your fork still contains necessary changes?

nullie avatar Jan 03 '25 21:01 nullie

Thanks, does that mean I can use upstream wasi-sdk with this alias or your fork still contains necessary changes?

In theory, yes (i.e. you should be able to use upstream instead of my fork), and that's what https://github.com/bytecodealliance/componentize-py/issues/113 is about, but I haven't tried it myself yet.

dicej avatar Jan 03 '25 21:01 dicej