Skip to content
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

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

Open
nullie opened this issue Jan 3, 2025 · 3 comments

Comments

@nullie
Copy link

nullie commented Jan 3, 2025

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: c50822c
wasi-sdk revision: dicej/wasi-sdk@f3a1f89

@dicej
Copy link
Collaborator

dicej commented Jan 3, 2025

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!

@nullie
Copy link
Author

nullie commented Jan 3, 2025

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

@dicej
Copy link
Collaborator

dicej commented Jan 3, 2025

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 #113 is about, but I haven't tried it myself yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants