Skip to content

Build and test python#191

Open
vidyalakshmir wants to merge 23 commits intomainfrom
cpython-build-test
Open

Build and test python#191
vidyalakshmir wants to merge 23 commits intomainfrom
cpython-build-test

Conversation

@vidyalakshmir
Copy link
Copy Markdown
Contributor

@vidyalakshmir vidyalakshmir commented Apr 14, 2026

@qianxichen233 and @vidyalakshmir worked on this.

This PR is aimed at

  1. Producing both static and dynamic builds of python.
  2. Run python tests for both static and dynamic builds.
  3. Adds a clean.sh which cleans up python builds.

This is a cleaned up PR from the following PRs

Closes #40
Closes #128
Closes #148
Closes #113

Testing

Test dynamic build of python

APP=cpython make clean
LIND_DYLINK=1 make cpython
LIND_DYLINK=1 APP=cpython make test

Test static build of python

APP=cpython make clean
cd lind-wasm-apps
make cpython
APP=cpython make test

Comment thread cpython/run.sh
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this file is redundent, should remove

Copy link
Copy Markdown
Contributor

@rennergade rennergade left a comment

Choose a reason for hiding this comment

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

This one needs the most work:

  1. run.sh has hardcoded path: /home/lind/lind-wasm/src/wasmtime/target/debug/wasmtime — won't work outside that specific container. Should use lind_run or be parameterized.

  2. clean.sh references $SYSROOT which is never defined in that script — will fail with "unbound variable" under set -eu.

  3. clean.sh uses sudo rm -rf — dangerous in a build script. The build shouldn't require sudo.

  4. Modifies shared sysrootbuild_python_wasm.sh creates empty placeholder .a files (libwasi-emulated-getpid.a, etc.) directly in $SYSROOT/lib/wasm32-wasi/. This modifies the shared sysroot and affects all other builds. Should use the overlay pattern instead.

  5. Hardcodes CLANG_BIN instead of loading from .toolchain.env like other scripts.

  6. make ... &> make.log — hides all build output. If the build fails, you have to dig into the log file to find the error. Other scripts use V=1 to show output.

  7. run_tests.sh modifies the build Makefile with sed — very fragile. Will break if the Makefile format changes.

  8. Missing space before || in lind-boot precompile call.

  9. build_shared_python_wasm.sh duplicates the same 50-line dylink pipeline from PR #185 — should use a shared helper.

  10. Duplicate --export flags in the shared python link command — --export=__wasm_call_ctors, --export-if-defined=__wasm_init_tls, and --export=__tls_base each appear twice.


Cross-cutting feedback for all the dynamic PRs (#185, #188, #189, #190, #191):

The dylink pipeline (clang link → add-export-tool ×3 → wasm-opt → precompile → stage) should be extracted into a shared helper script. It's duplicated 8+ times across these PRs with only the library name changing. A single scripts/build_dynamic_lib.sh taking the static archive and output name as args would eliminate ~400 lines of duplication and make it much easier to update the pipeline when flags change.

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

Successfully merging this pull request may close these issues.

CPython setup for evaluation Standardize build process and staging for python Test script for cpython Build Python with dynamic loading

3 participants