swift-flake: skip host cc-wrapper flags for every non-host -target (not just wasm32); Android bridge back to plain swiftc #41
No reviewers
Labels
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
key-store/key.store!41
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "claude/cranky-wu-a15bdd"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Packages/swift-flake/build/wrapper.sh(the cc-wrapper-derivedswiftc/swiftwrapper thatbuild.nixinstalls into both the swift-flakeswifttoolchain and the Androidskip-swift-toolchain-6.2.3) only exempted-target wasm32*from host-flag injection. Every other non-host-targeton Linux still sourced the clang-wrapper/bintoolsadd-flags.sh+add-hardening.sh, synthesized the glibcSDKROOT/COMPILER_PATH, and appended-L<glibc>/lib,-B<glibc>/lib,-idirafter <glibc-dev>/include,-nostdlibinc,-resource-dir=<clang-wrapper>/resource-root,-Xlinker -dynamic-linker=<x86_64 ld.so>and the glibc/gcc-Ldirs. That is what broke the Android bridge link (Build (Android) red 2026-06-19..08-16; #37 works around it by driving the unwrapped swift-driver).Change
build.nix: substitute@defaultTarget@=targetPlatform.config(the same value nixpkgs' cc-wrapper uses for its owndefaultTarget;suffixSaltis derived from it).wrapper.sh: replaceisWasmTargetwithisCrossTarget= "the last Swift-target/--target=is not the wrapper's host triple", after canonicalizingarm64-→aarch64-,-apple-macosx/-apple-macos→-apple-darwinand stripping OS versions (macosx14.0,android35). A cross target keeps the driver-mode / PATH / LD_LIBRARY_PATH / frontend plumbing and skips: SDKROOT + COMPILER_PATH/LIBRARY_PATH setup, bintools+ccadd-flags.sh,add-hardening.sh, the link-flag / dynamic-linker injection, host-march-style flags, and theadd-local-cc-cflags-before.shhook (which for a cross target only printed cc-wrapper's multi-target warning). Values of pass-through flags (-Xcc -target …) are not mistaken for the Swift target; SwiftPM helpers (swift-build& co., whose--targetis a module name and which compile host + cross code in one run) always count as host — the swiftc calls they spawn come back through the wrapper and are classified individually. Host builds (no-target, or the host-target) are unchanged.NIX_DEBUG>=1prints the decision.Scripts/build-android-bridge.sh: back to the plain wrappedswiftc(so Build (Android) exercises the wrapper's cross path like the wasm lane does); the per-ABI ELF-machine verification from #37 stays.This changes the hash of every Swift toolchain derivation built from
build.nix, so the web/wasm lane, lately macro plugin, KaiOS core and the Android skip toolchain rebuild once.Verification (forge, x86_64-linux, this branch)
nix build .#web-container: rebuiltswift(6.3.2) → KaiOS core (host module emit +-target wasm32-unknown-wasip1sidecar),swift-syntax-host(swift build --target SwiftCompilerPluginthrough the helper wrapper),lately-macro-plugin(host link),lately-web-core(9.8 MBlately-core.wasm), site, image — all green.nix develop .#android --command Scripts/build-android-bridge.shwith the rebuiltskip-swift-toolchain-6.2.3and the plain wrappedswiftc: both ABIs link,llvm-readelfshows AArch64 / X86-64,libc++_shared.soin NEEDED and staged; wrapperNIX_DEBUGdump for both*-linux-android35targets:cross=1, extra flags =--driver-mode=swiftconly, zero glibc/gcc/dynamic-linker paths in the whole log.f8h44vy7…-swift) vs new (g4vwlk5q…-swift)NIX_DEBUG=1flag dumps forswiftc hello.swiftinside a gcc stdenv env (NIX_CCset), with and without an explicit-target x86_64-unknown-linux-gnu, are identical apart from the new debug line and temp/output names; both binaries link and run. Bare invocations withoutNIX_CCfail identically old vs new (missing required module 'SwiftGlibc', pre-existing).defaultTargetspellings,-Xcc -target, last--target-wins, helper--target <module>).Follow-up in flight:
Build: Androidworkflow dispatch on this branch (Namespace runner) to cover the full bazel → prepare-skip-core → bridge → APK lane with the rebuilt toolchain.🤖 Generated with Claude Code
c0e93912d60b3fe1c1930b3fe1c1939cc18a4bb29cc18a4bb2180a43ef55