Skip to content

Enable dynamic wasm build for git and update test runner#189

Open
vidyalakshmir wants to merge 1 commit intomainfrom
git-dynamic
Open

Enable dynamic wasm build for git and update test runner#189
vidyalakshmir wants to merge 1 commit intomainfrom
git-dynamic

Conversation

@vidyalakshmir
Copy link
Copy Markdown
Contributor

@vidyalakshmir vidyalakshmir commented Apr 13, 2026

Closes #101
This PR introduces the ability to compile git as a Position Independent Executable (PIE) that dynamically links its dependencies at runtime in the lind-wasm environment. It also updates our test harness to successfully execute these dynamic builds by preloading the required shared libraries.

Shared libraries that git depends on:

  • openssl (libssl.so and libcrypto.so)
  • zlib (libz.so)
  • libc

1. Build Script Updates (git)

  • Compiler Flags: Conditionally injects -fPIC into CFLAGS.
  • Linker Flags: Splits standard static linking from dynamic linking. Dynamic builds now include -Wl,-pie, -Wl,--shared-memory, and --unresolved-symbols=import-dynamic.
  • CRT Objects: Ensures the required Lind objects (set_stack_pointer.o, crt1_shared.o, lind_utils.o) are linked into the dynamic executable.
  • Wasm Optimization: Branches wasm-opt to include --enable-bulk-memory and --enable-threads, followed by add-export-tool to explicitly expose relocation and stack pointer symbols to the host environment.

Test Runner Updates

  • Runtime Preloading: Updated the test execution wrapper. When LIND_DYLINK=1, the test suite now runs lind_run with the necessary --preload env=... arguments. This resolves the unknown import errors by ensuring the Wasm runtime populates the env namespace with our shared dependencies before executing git.cwasm.

How to Test

Test Static Path:

  • make git
  • APP= git make test

Test Dynamic Path:

  • LIND_DYLINK=1 make git
  • LIND_DYLINK=1 APP= git make test
    (This requires the updates from this PR which does dynamic compilation of libraries)

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.

git - dynamic build

1 participant