Skip to content

build: only run gn-typescript-definitions for default toolchain - #52122

Merged
dsanders11 merged 1 commit into
mainfrom
build/single-gn-typescript-definitions-cross-compile
Jun 27, 2026
Merged

dsanders11 merged 1 commit into
mainfrom
build/single-gn-typescript-definitions-cross-compile

Conversation

@dsanders11

Copy link
Copy Markdown
Member

Description of Change

When cross-compiling, we can end up with two concurrent invocations of the build_electron_definitions GN action, both writing to //electron/electron.d.ts. If one wins the race and moves on to TypeScript compilation it may see a partially written //electron/electron.d.ts as the other concurrent invocation writes to disk, causing the TS compilation to fail. This was observed in this linux-arm64 CI job.

$target_gen_dir/tsc/typings/electron.d.ts isn't actually used for anything, the TS compilation uses //electron/electron.d.ts as seen by the CI job failure, and the contents of the file are architecture independent, so generate the content once for the default toolchain and any other toolchains can reference it there.

Checklist

Release Notes

Notes: none

@dsanders11 dsanders11 added semver/none target/41-x-y PR should also be added to the "41-x-y" branch. target/42-x-y PR should also be added to the "42-x-y" branch. target/43-x-y PR should also be added to the "43-x-y" branch. labels Jun 25, 2026
@dsanders11
dsanders11 marked this pull request as ready for review June 25, 2026 08:08

@nikwen nikwen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM. Thanks!

Comment thread BUILD.gn
# and once in $target_gen_dir
# The one in $target_gen_dir is used for the actual TSC build later one
# and the one in //electron/electron.d.ts is used by your IDE (vscode)
# for typescript prompting

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be awesome to keep this comment. Looking at the new comment, I'd have no idea why we have two copies of the file.

@dsanders11 dsanders11 Jun 25, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is categorically wrong. 😅 It was maybe true at one point in time, but "The one in $target_gen_dir is used for the actual TSC build later" is wrong and misleading.

I'd have no idea why we have two copies of the file.

There's not really a succinct answer, it's a mess of historical implementation and GN fun. Actions in GN must have an output for state tracking, but the way our builds work these days those files aren't actually used, the identical content in //electron/electron.d.ts is used. 🤷

I played with doing a larger refactor here to make it fit better into how GN wants things to work, but gave up and went with this more surgical fix.

@dsanders11
dsanders11 merged commit 5624bb7 into main Jun 27, 2026
142 of 144 checks passed
@dsanders11
dsanders11 deleted the build/single-gn-typescript-definitions-cross-compile branch June 27, 2026 21:46
@release-clerk

release-clerk Bot commented Jun 27, 2026

Copy link
Copy Markdown

No Release Notes

@trop

trop Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "41-x-y", please check out #52163

@trop

trop Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "42-x-y", please check out #52164

@trop trop Bot removed the target/41-x-y PR should also be added to the "41-x-y" branch. label Jun 27, 2026
@trop

trop Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "43-x-y", please check out #52165

@trop trop Bot added in-flight/42-x-y in-flight/43-x-y and removed target/42-x-y PR should also be added to the "42-x-y" branch. target/43-x-y PR should also be added to the "43-x-y" branch. labels Jun 27, 2026
@dsanders11 dsanders11 added merged/41-x-y PR was merged to the "41-x-y" branch. merged/42-x-y PR was merged to the "42-x-y" branch. merged/43-x-y PR was merged to the "43-x-y" branch. and removed in-flight/41-x-y in-flight/42-x-y in-flight/43-x-y labels Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

44-x-y merged/41-x-y PR was merged to the "41-x-y" branch. merged/42-x-y PR was merged to the "42-x-y" branch. merged/43-x-y PR was merged to the "43-x-y" branch. semver/none

Projects

No open projects
Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants