Skip to content

sdk: preserve pthread compiler semantics - #938

Closed
brandonpayton wants to merge 2 commits into
mainfrom
fix/sdk-pthread-compile-semantics
Closed

sdk: preserve pthread compiler semantics#938
brandonpayton wants to merge 2 commits into
mainfrom
fix/sdk-pthread-compile-semantics

Conversation

@brandonpayton

@brandonpayton brandonpayton commented Jul 14, 2026

Copy link
Copy Markdown
Member

Why

AX_PTHREAD is a standard Autoconf configure check that discovers how a compiler enables POSIX threads. The SDK is Kandelo's software development kit, which drives Clang for package builds.

XZ's standard AX_PTHREAD configure probe compiles with -pthread and requires Clang's _REENTRANT definition. Kandelo's SDK silently removed -pthread, so the probe failed even though Kandelo provides working pthread APIs. That left PTHREAD_CFLAGS and PTHREAD_LIBS empty and produced incomplete liblzma.pc metadata.

This is an SDK compiler-driver defect exposed by the Homebrew XZ build. The fix belongs in the platform, not in an XZ Formula cache override.

What changed

  • forward -pthread to Clang in the TypeScript SDK driver;
  • preserve the same flag in the packaged in-guest shell driver;
  • keep -lpthread as the existing compatibility no-op because pthread symbols come from musl's libc.a;
  • document the compiler semantics; and
  • add unit and Autoconf-shaped compile/link regressions that require _REENTRANT and real pthread symbols.

The change preserves #913's exact linker-input ordering: -pthread enters the single ordered forwarding stream at the position supplied by the caller.

Ordering

This PR is stacked on #913 (sdk: preserve static linker argument order) because both changes touch the SDK argument-forwarding path. Merge #913 first, then retarget this PR to main.

ABI

No ABI bump is required. This changes how the compiler driver treats an existing source/build flag; it does not change syscalls, marshalling, channel or memory layouts, exported runtime interfaces, libc signatures, fork frames, or ABI metadata. The canonical ABI snapshot/version check is unchanged and passes.

Consumer proof

A disposable future-platform integration combined exact #936 + #913 + #874 + #883 with this fix (synthetic tree f1614ed97525db9d9f80bac987645787ecdecad5). The supported XZ Homebrew build then reported:

  • AX_PTHREAD selected PTHREAD_CFLAGS=-pthread and PTHREAD_LIBS=-lpthread;
  • installed liblzma.pc recorded Libs.private: -pthread -lpthread;
  • the complete XZ source build, both final-artifact validators, literal Formula test, bottle inspection, handoff creation, and independent handoff validation passed.

This evidence is local and unpublished; no XZ-specific source or Formula workaround is part of this PR.

Validation

Exact head: a27676e3b397996417397c0428a46ea12bf54ecc
Exact tree: ce3ea9b1b287919eb46216bd735fa49b6f3a66ac

  • focused SDK flag/compiler tests: 41/41 passed;
  • sdk: preserve static linker argument order #913 linker-order plus Autoconf pthread integration tests: 2/2 passed;
  • full SDK suite: 66/66 passed;
  • both the TypeScript and packaged compiler drivers emit #define _REENTRANT 1 for -pthread;
  • ./scripts/dev-shell.sh bash scripts/check-abi-version.sh: passed;
  • packaged driver shell syntax and git diff --check: passed.

All validation ran through scripts/dev-shell.sh. No XZ-specific patch is included.

Keep parser classifications for SDK mode and thread inference, but forward non-SDK arguments in their original sequence so objects, -l libraries, archives, and linker group controls retain normal static-link semantics. Add unit and real wasm-ld coverage for mixed input ordering and linker controls.
Forward -pthread to Clang so configure probes receive the standard _REENTRANT definition while keeping -lpthread as the existing musl compatibility no-op. Keep the source and in-guest SDK drivers aligned and cover the Autoconf compile-and-link shape.
@github-actions

Copy link
Copy Markdown
Contributor

Phase B-1 matrix build status — pr-938-staging

ABI v39. 71 built, 0 failed, 71 total.

Package Arch Status Sha
icu wasm32 built f2e695e4
libcurl wasm32 built 2d9fc0e9
libcxx wasm32 built aca0859f
libcxx wasm64 built d3353c8b
libiconv wasm32 built c8ee6514
libpng wasm32 built d23eb9a8
libxml2 wasm32 built a2c268e1
libzip wasm32 built a8a2053d
openssl wasm32 built 7ec09ece
openssl wasm64 built 5138eb1d
sqlite wasm32 built 9964d42c
sqlite wasm64 built 3f6d4e53
zlib wasm32 built 6e32642b
zlib wasm64 built 7cb3e2c3
bc wasm32 built b5e1e72e
bzip2 wasm32 built 8360bb15
coreutils wasm32 built 9736f5c1
curl wasm32 built 08f31048
dash wasm32 built 0dda8fe7
diffutils wasm32 built a65dc325
dinit wasm32 built 021a7147
fbdoom wasm32 built da6efb4e
file wasm32 built d26064da
findutils wasm32 built 2b10b7a8
gawk wasm32 built eaf1ee46
git wasm32 built 46e089de
grep wasm32 built 89d985ed
gzip wasm32 built b473d3cb
hello wasm32 built 1b5808b4
kandelo-sdk wasm32 built 9d7c338f
kernel wasm32 built 1cd93cb0
less wasm32 built ecc93e5f
lsof wasm32 built 3d9ef32f
m4 wasm32 built d0f4764c
make wasm32 built c14f3ec3
mariadb wasm32 built af817f57
mariadb wasm64 built 2ce5a72e
modeset wasm32 built 1b6f3166
msmtpd wasm32 built c299471b
nano wasm32 built 59e63305
ncurses wasm32 built 2666604b
netcat wasm32 built edaa94f1
nginx wasm32 built 5b281460
php wasm32 built e33d9621
posix-utils-lite wasm32 built 124efa0c
ruby wasm32 built b70c442b
sed wasm32 built e30232c4
spidermonkey wasm32 built 5439f082
tar wasm32 built 0db63c2b
tcl wasm32 built fef4bbf1
unzip wasm32 built 71efacd8
userspace wasm32 built 6dead609
vim wasm32 built 8227dba0
wget wasm32 built bc3dfdbd
xz wasm32 built 6375c5a6
zip wasm32 built 0f9d71ae
zstd wasm32 built b233bb34
bash wasm32 built d06904ca
mariadb-test wasm32 built e1d1bc49
mariadb-vfs wasm32 built 36e04d39
mariadb-vfs wasm64 built c6ae7efa
nethack wasm32 built 286f0ea1
node wasm32 built 092ac57a
spidermonkey-node wasm32 built 113b2b34
vim-browser-bundle wasm32 built 1c521853
nethack-browser-bundle wasm32 built 73ba24a7
rootfs wasm32 built f90ec0a3
shell wasm32 built 0e21ee6d
lamp wasm32 built eb5bbda0
node-vfs wasm32 built 73f29b3c
wordpress wasm32 built 39952083

Auto-generated; replaced on each push. Raw data in the publish-status workflow artifact.

Base automatically changed from fix/sdk-preserve-linker-order to main July 14, 2026 18:42
@brandonpayton

Copy link
Copy Markdown
Member Author

Absorbed by rebase-merged #967. Main is now 6efb411 with the sealed tree b133bfa018f7e2bc84c4845edf2f945b2f844954, and ABI 41 activation completed successfully in run 29550069085. The absorption audit confirmed this PR\x27s behavior and tests are present in that merged tree, so this source PR is closed and its branch is deleted.

@brandonpayton
brandonpayton deleted the fix/sdk-pthread-compile-semantics branch July 17, 2026 02:39
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.

1 participant