Skip to content

Commit 09a2214

Browse files
richard-townsend-armJohn Kleinschmidt
authored andcommitted
build: bring in a later compiler for Windows on Arm (electron#18625)
* build: allow pulling in a later version of Clang Due to a code-generation defect related to virtual method thunks in the official compiler used for Chromium M76, it's necessary to build for WoA with a later version of Clang. When running gclient sync, setting ELECTRON_BUILD_WOA=1 in the environment will download a corrected compiler which doesn't have this defect. * docs: add a note about building for Windows on Arm
1 parent 81e8f5c commit 09a2214

File tree

3 files changed

+58
-4
lines changed

3 files changed

+58
-4
lines changed

docs/development/build-instructions-gn.md

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,16 +197,39 @@ $ gn gen out/Debug-x86 --args='... target_cpu = "x86"'
197197
```
198198

199199
Not all combinations of source and target CPU/OS are supported by Chromium.
200-
Only cross-compiling Windows 32-bit from Windows 64-bit and Linux 32-bit from
201-
Linux 64-bit have been tested in Electron. If you test other combinations and
202-
find them to work, please update this document :)
200+
201+
<table>
202+
<tr><th>Host</th><th>Target</th><th>Status</th></tr>
203+
<tr><td>Windows x64</td><td>Windows arm64</td><td>Experimental</td>
204+
<tr><td>Windows x64</td><td>Windows x86</td><td>Automatically tested</td></tr>
205+
<tr><td>Linux x64</td><td>Linux x86</td><td>Automatically tested</td></tr>
206+
</table>
207+
208+
If you test other combinations and find them to work, please update this document :)
203209

204210
See the GN reference for allowable values of [`target_os`][target_os values]
205-
and [`target_cpu`][target_cpu values]
211+
and [`target_cpu`][target_cpu values].
206212

207213
[target_os values]: https://gn.googlesource.com/gn/+/master/docs/reference.md#built_in-predefined-variables-target_os_the-desired-operating-system-for-the-build-possible-values
208214
[target_cpu values]: https://gn.googlesource.com/gn/+/master/docs/reference.md#built_in-predefined-variables-target_cpu_the-desired-cpu-architecture-for-the-build-possible-values
209215

216+
#### Windows on Arm (experimental)
217+
218+
To cross-compile for Windows on Arm, [follow Chromium's guide](https://chromium.googlesource.com/chromium/src/+/refs/heads/master/docs/windows_build_instructions.md#Visual-Studio) to get the necessary dependencies, SDK and libraries, then build with `ELECTRON_BUILDING_WOA=1` in your environment before running `gclient sync`.
219+
220+
```bat
221+
set ELECTRON_BUILDING_WOA=1
222+
gclient sync -f --with_branch_heads --with_tags
223+
```
224+
225+
Or (if using PowerShell):
226+
```powershell
227+
$env:ELECTRON_BUILDING_WOA=1
228+
gclient sync -f --with_branch_heads --with_tags
229+
```
230+
231+
Next, run `gn gen` as above with `target_cpu="arm64"`.
232+
210233
## Tests
211234

212235
To run the tests, you'll first need to build the test modules against the

patches/common/chromium/.patches

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,4 @@ add_contentgpuclient_precreatemessageloop_callback.patch
7979
partially_revert_fb4ab3be3fc0024d00358d5b7816d3215a8ff20c.patch
8080
disable_custom_libcxx_on_windows.patch
8181
fix_breakpad_symbol_generation_on_linux_arm.patch
82+
woa_compiler_workaround.patch
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Richard Townsend <richard.townsend@arm.com>
3+
Date: Tue, 4 Jun 2019 09:36:17 +0100
4+
Subject: build: pull in a fixed compiler for Windows on Arm
5+
6+
Due to a code-generation defect in the version of Clang used for the M76
7+
branch related to virtual method thunks, it's necessary to build M76
8+
with a later version of Clang. This change pulls in a corrected version
9+
by setting ELECTRON_BUILDING_WOA=1 or similar in the environment.
10+
11+
This PR is only intended to be a temporary workaround and will be
12+
removed when Electron's Chromium updates to a compiler unaffected by
13+
this issue.
14+
15+
diff --git a/tools/clang/scripts/update.py b/tools/clang/scripts/update.py
16+
index 082dc5ec7ac304109a267456df4660c2cfa672f9..a4b14a8dddb02a9bd3ac7a0967ae6c4c7031d83b 100755
17+
--- a/tools/clang/scripts/update.py
18+
+++ b/tools/clang/scripts/update.py
19+
@@ -40,6 +40,11 @@ CLANG_REVISION = '67510fac36d27b2e22c7cd955fc167136b737b93'
20+
CLANG_SVN_REVISION = '361212'
21+
CLANG_SUB_REVISION = 4
22+
23+
+if os.getenv("ELECTRON_BUILDING_WOA"):
24+
+ CLANG_REVISION = '56bee1a90a71876cb5067b108bf5715fa1c4e843'
25+
+ CLANG_SVN_REVISION = '361657'
26+
+ CLANG_SUB_REVISION = 1
27+
+
28+
PACKAGE_VERSION = '%s-%s-%s' % (CLANG_SVN_REVISION, CLANG_REVISION[:8],
29+
CLANG_SUB_REVISION)
30+
RELEASE_VERSION = '9.0.0'

0 commit comments

Comments
 (0)