Repository navigation
build: fix local WebKit configure on PIE-default distros #30710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴
cfg.unixincludes darwin (config.ts:596:unix = linux || darwin || freebsd), so this now passes-no-pieto the WebKit cmake on macOS. Everywhere else in the codebase the link-time-no-pieis deliberately gated to linux/freebsd only (flags.ts:943-944, flags.ts:1046-1047, source.ts:1210-1212) — on arm64 darwin, clang's Darwin driver forwards this to ld64 as-no_pie, which ld64 rejects with "-no_pie cannot be used with arm64", so everytry_compile()probe fails — the exact regression this PR is fixing on Linux. Gate the-no-piepush on(cfg.linux || cfg.freebsd)(or!cfg.darwin) to match flags.ts; the R_X86_64_32S rationale is ELF-specific and doesn't apply to Mach-O anyway.Extended reasoning...
What the bug is
The new
-no-pieflag is pushed undercfg.unix && cfg.abi !== "android". Per config.ts:596,const unix = linux || darwin || freebsd, so this gate includes darwin. The flag therefore lands inCMAKE_C_FLAGS/CMAKE_CXX_FLAGSfor local-WebKit builds on macOS, where it was never passed before.This diverges from the codebase's established pattern: the link-time
-no-pieis gated onc.linux && c.abi !== "android"at flags.ts:943-944 and onc.freebsdat flags.ts:1046-1047. Darwin only ever gets the compile-mode-fno-pic -fno-pie(flags.ts:533-534, source.ts:1210-1212, source.ts:1494-1495) — never the link-mode-no-pie. The pre-PR webkit.ts line matched that pattern exactly.Why it manifests
On darwin,
cfg.ldis empty (config.ts:184: "May be empty on darwin (clang invokes ld)"), and source.ts:1135 only setsCMAKE_EXE_LINKER_FLAGS=--ld-path=...whencfg.linux. So WebKit's nested-cmaketry_compile()probes on macOS link via clang's Darwin driver → Apple ld64, not lld.CMake's
try_compile()includesCMAKE_C_FLAGSin the<FLAGS>slot for both the compile and the link of the probe executable. When clang's Darwin driver sees-no-pieon a link line, it translates it to ld64's spelling-no_pie. On arm64, ld64 hard-errors with "-no_pie cannot be used with arm64" (arm64 macOS mandates PIE). The-Qunused-argumentsthat WebKit prepends only suppresses clang's unused-argument compile warning; it does not stop the driver from forwarding-no_pieto the linker.Nothing filters this out on the way to cmake: source.ts:1225-1227 appends
spec.args(which carries webkit'sCMAKE_C_FLAGS=optFlagStr) last, so it overrides the globalCMAKE_C_FLAGSand the-no-piedefinitely reaches darwin's configure.Step-by-step proof
bun run build:local --target=configure-WebKit(or any local-WebKit build).cfg.darwin = true, socfg.unix = true,cfg.abi !== "android"→optFlagsgets-fno-pic -fno-pie -no-pie.args.CMAKE_C_FLAGS = optFlagStris passed to the nested cmake (source.ts appends spec.args last, so it sticks).FindThreads→try_compile()compiles a probe with-fno-pic -fno-pie -no-pie -c probe.c -o probe.o(fine), then links withclang ... -fno-pic -fno-pie -no-pie probe.o -o probe.-no-pie→-no_pieto ld64.ld: -no_pie cannot be used with arm64→ link fails →Threads_FOUND = FALSE.FindThreadsisREQUIRED→CMake Error ... FindThreads→ configure aborts.This is exactly the regression class the PR is fixing on Linux, transplanted onto macOS. CI won't catch it because the prebuilt path returns
{kind: "none"}beforeoptFlagsis built; only local-mode developers on Apple Silicon hit it.Why the flag is unnecessary on darwin anyway
The PR's stated rationale — driver-default
-pie+-fno-picobject →R_X86_64_32Srelocation failure — is ELF-specific. macOS uses Mach-O, Apple clang does not default-link try_compile probes as PIE in a way that conflicts with-fno-pic, and there is no equivalent failure mode. So even setting aside the ld64 error,-no-pieprovides zero benefit on darwin while creating risk.Fix
Match the rest of the codebase by gating the link-mode flag separately:
(or equivalently keep one line and add
-no-pieunder!cfg.darwin). This mirrors flags.ts:943-944 / flags.ts:1046-1047 and keeps the Linux fix intact.