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

Command to build _testexternalinspection.o gets truncated when building under WASI #116229

Closed
brettcannon opened this issue Mar 1, 2024 · 10 comments
Labels
build The build process and cross-build OS-wasi

Comments

@brettcannon
Copy link
Member

Bug description:

The output from make is:

z stack-size=524288 -Wl,--stack-first -Wl,--initial-memory=10485760   Modules/_testexternalinspection.o   -o Modules/_testexternalinspection.cpython-313d-wasm32-wasi.so
/bin/sh: 1: z: not found

It seems like the command is partially from CONFIGURE_LDFLAGS_NODIST= -z stack-size=524288 -Wl,--stack-first -Wl,--initial-memory=10485760.

And the Makefile line is:

Modules/_testexternalinspection$(EXT_SUFFIX):  Modules/_testexternalinspection.o; $(BLDSHARED)  Modules/_testexternalinspection.o $(MODULE__TESTEXTERNALINSPECTION_LDFLAGS) $(MODULE_LDFLAGS) -o Modules/_testexternalinspection$(EXT_SUFFIX)

But BLDSHARED is BLDSHARED= $(PY_CORE_LDFLAGS) in Makefile. That suggests there's some expansion failing.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Other

@brettcannon brettcannon added build The build process and cross-build OS-wasi labels Mar 1, 2024
@erlend-aasland
Copy link
Contributor

cc. @mhsmith

@mhsmith
Copy link
Member

mhsmith commented Mar 2, 2024

I'm not sure what's going on here, but I don't think it's caused by any of the things I've changed recently.

@erlend-aasland
Copy link
Contributor

@brettcannon, how can I reproduce? I tried following the instructions in Tools/wasm/README.md but got no build failure.

@brettcannon
Copy link
Member Author

@brettcannon, how can I reproduce? I tried following the instructions in Tools/wasm/README.md but got no build failure.

@erlend-aasland the overall build will succeed, but _testexternalinspection won't be kept due to not being imported. I only noticed this because I had another build failure related to that module that I have fixed.

@mhsmith
Copy link
Member

mhsmith commented Mar 6, 2024

If I understand correctly, WASI doesn't actually support building shared library modules at all, so it doesn't set BLDSHARED. But _testexternalinspection was added to a small list of test modules at the bottom of Setup.stdlib.in which "MUST be built as shared libraries". The reason this has never caused a problem for WASI before is that all the other modules in the list are skipped due to WASI not supporting dlopen.

@brettcannon
Copy link
Member Author

@mhsmith Correct, but all the other modules fail due to not being importable (I have #115983 to track turning off building them in the first place). For some reason with _testkexternalinspection I see this odd situation where the command run gets truncated down to z and causes the compilation to fail.

@brettcannon
Copy link
Member Author

The list of modules that @mhsmith referred to:

# Some testing modules MUST be built as shared libraries.
*shared*
@MODULE__TESTIMPORTMULTIPLE_TRUE@_testimportmultiple _testimportmultiple.c
@MODULE__TESTMULTIPHASE_TRUE@_testmultiphase _testmultiphase.c
@MODULE__TESTSINGLEPHASE_TRUE@_testsinglephase _testsinglephase.c
@MODULE__TESTEXTERNALINSPECTION_TRUE@_testexternalinspection _testexternalinspection.c
@MODULE__CTYPES_TEST_TRUE@_ctypes_test _ctypes/_ctypes_test.c
# Limited API template modules; must be built as shared modules.
@MODULE_XXLIMITED_TRUE@xxlimited xxlimited.c
@MODULE_XXLIMITED_35_TRUE@xxlimited_35 xxlimited_35.c

If we don't want to bother trying to figure out why the truncation is occurring I can just turn off trying to build this module under WASI (and all the other ones listed there).

@sobolevn
Copy link
Member

sobolevn commented Mar 9, 2024

I just tried the whole thing on my mac, I got expected result: BLDSHARED= $(CC) -bundle -undefined dynamic_lookup $(PY_CORE_LDFLAGS)

No warning happened when running make.

@mhsmith
Copy link
Member

mhsmith commented Mar 11, 2024

@sobolevn: From that command line, it looks like you were building for macOS, not WASI.

@brettcannon
Copy link
Member Author

I turned off building _testexternalinspection under WASI in #116528 . I'm going to close this as indirectly fixed, but if someone wanted to continue to dig into why the command is getting truncated I can open it again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build The build process and cross-build OS-wasi
Projects
None yet
Development

No branches or pull requests

4 participants