Add dynamic build for curl and update tests#188
Open
vidyalakshmir wants to merge 2 commits intomainfrom
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #100
Enable dynamic WebAssembly builds (LIND_DYLINK=1) for curl`
Shared libraries that
gitdepends on:libssl.soandlibcrypto.so)libz.so)Summary
This PR updates the
curlbuild pipeline to support cross-compiling as a WebAssembly Position Independent Executable (PIE). WhenLIND_DYLINK=1is enabled,curlwill be compiled to dynamically link its external dependencies (OpenSSL, zlib) at runtime via thelind-wasmenvironment, rather than statically linking them into the binary.Technical Details
Building Autotools/Libtool projects for WebAssembly dynamic linking requires bypassing several traditional Linux/ELF assumptions. This PR implements the "Static Internal, Dynamic External" workaround.
1. Libtool / ELF Versioning Bypass
--enable-sharedtocurl's configure script causes Libtool to generate ELF version scripts (.ver), which WebAssembly's linker (wasm-ld) completely rejects.--disable-shared --enable-staticenabled for Libtool, but overrides the environment to force the compiler to use Position Independent Code (-fPIC). This causescurl's internal libraries (libcurl.la) to compile safely as.aarchives containing PIC objects, which are then successfully linked into the final dynamic executable.2. Linker Flag Splitting (
LDFLAGS)autoconffeature tests frequently fail if they encounter undefined symbols too early.LDFLAGS_CONFIGUREuses strict static linking rules so feature detection works cleanly.LDFLAGS_WASM(injected only during themakestep) includes the necessary-Wl,-pie,--allow-undefined, and--unresolved-symbols=import-dynamicflags required to build the Wasm PIE.3. CRT & Export Handling
set_stack_pointer.o,crt1_shared.o).wasm-optto support bulk memory and threads for dynamic environments.add-export-toolimmediately after optimization to expose__wasm_apply_tls_relocs,__wasm_apply_global_relocs, and__stack_pointerto the runtime host.Test Runner Updates
LIND_DYLINK=1, the test suite now runslind_runwith the necessary--preload env=...arguments. This resolves theunknown importerrors by ensuring the Wasm runtime populates theenvnamespace with our shared dependencies before executingcurl.cwasm.How to Test
Test Static Path:
make curlAPP=curl make testTest Dynamic Path:
LIND_DYLINK=1 make curlLIND_DYLINK=1 APP=curl make test(This requires the updates from this PR which does dynamic compilation of libraries)