fix: repair wasi-libc sysroot patches so patched sysroot builds succesfully#1424
Open
airhorns wants to merge 1 commit intorivet-dev:mainfrom
Open
fix: repair wasi-libc sysroot patches so patched sysroot builds succesfully#1424airhorns wants to merge 1 commit intorivet-dev:mainfrom
airhorns wants to merge 1 commit intorivet-dev:mainfrom
Conversation
…ssfully The patched wasi-libc sysroot (make sysroot) has been broken since f833343 ("chore: duckdb"), which corrupted two patch files and introduced a workaround in the build script that masked some failures while causing others. 0008-sockets.patch: f833343 prepended 67 lines of plain unified-diff content (a commit message + duplicate diffs for install-include-headers.sh and sys/socket.h) to a patch that already had correct diff --git hunks for those same files at the end. When git apply processed the patch, the plain diffs applied first, then the git-format diffs failed because their context had already been modified. Restored to the last known-good version from cee26aa, which is a clean diff --git patch. 0012-posix-spawn-cwd.patch: was a plain unified diff with incorrect hunk line counts, causing "corrupt patch at line N" errors from git apply unless --recount was used. Regenerated as proper diff --git format from the intended changes (adding FDOP_CHDIR support and cwd propagation to posix_spawn in host_spawn_wait.c). patch-wasi-libc.sh: removed --recount flag from all git apply calls. --recount was added as a workaround for the malformed 0012 patch, but it caused silent misapplication of the valid plain-format patches 0013-0015 (posix-socket-header-surface, initialize-cwd-from-pwd, always-link-cwd-relative-path-resolution). With all patches now in correct format, --recount is unnecessary and harmful. Also removed the "layered patch scenario" fallback in --check mode that treated patch failures as success when destination files existed, which hid real errors. Verified: all 15 wasi-libc patches apply cleanly in sequence against the pinned wasi-libc commit (574b88d), and the full sysroot build (clone, patch, make libc, install CRT, rebuild llvm runtimes, install overrides) completes successfully.
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.
I went to work on adding some new packages that need the sysroot built to build themselves, but I couldn't build the sysroot locally!
Claude and I debugged and we believe the patched wasi-libc sysroot (make sysroot) has been broken since f833343 ("chore: duckdb"), which corrupted two patch files and introduced a workaround in the build script that masked some failures while causing others. After undoing the changes to the sysroot patches made there, the sysroot still builds for me locally, as does duckdb.
The changes:
0008-sockets.patch: f833343 prepended 67 lines of plain unified-diff content (a commit message + duplicate diffs for install-include-headers.sh and sys/socket.h) to a patch that already had correct diff --git hunks for those same files at the end. When git apply processed the patch, the plain diffs applied first, then the git-format diffs failed because their context had already been modified. Restored to the last known-good version from cee26aa, which is a clean diff --git patch.
0012-posix-spawn-cwd.patch: was a plain unified diff with incorrect hunk line counts, causing "corrupt patch at line N" errors from git apply unless --recount was used. Regenerated as proper diff --git format from the intended changes (adding FDOP_CHDIR support and cwd propagation to posix_spawn in host_spawn_wait.c).
patch-wasi-libc.sh: removed --recount flag from all git apply calls. --recount was added as a workaround for the malformed 0012 patch, but it caused silent misapplication of the valid plain-format patches 0013-0015 (posix-socket-header-surface, initialize-cwd-from-pwd, always-link-cwd-relative-path-resolution). With all patches now in correct format, --recount is unnecessary and harmful. Also removed the "layered patch scenario" fallback in --check mode that treated patch failures as success when destination files existed, which hid real errors.
Verified: all 15 wasi-libc patches apply cleanly in sequence against the pinned wasi-libc commit (574b88d), and the full sysroot build (clone, patch, make libc, install CRT, rebuild llvm runtimes, install overrides) completes successfully.