GN error when attempting to build on Windows 11 arm64 natively

21 views
Skip to first unread message

geisserml

unread,
Nov 13, 2025, 10:58:50 AMNov 13
to pdfium
When attempting to build pdfium on a GitHub actions windows-11-arm runner, I am stuck with the build error below. I've tried all I could think of, to no effect.

On windows-latest (x86_64), I initially had a similar error that could be solved with this step:
```
      - name: Install Windows cross deps
        if: ${{ startsWith(inputs.os, 'windows') && inputs.target_cpu }}
        uses: ChristopheLav/windows-sdk-install@v1
        with:
          version-sdk: 26100
          features: 'OptionId.WindowsDesktopDebuggers'
```
However, this didn't help on windows-11-arm.

```
Build config:
is_debug = false
treat_warnings_as_errors = false
use_glib = false
is_component_build = false
pdf_is_standalone = true
pdf_use_partition_alloc = false
pdf_enable_v8 = false
pdf_enable_xfa = false
pdf_use_skia = false
target_cpu = "arm64"

['C:\\a\\pypdfium2\\pypdfium2\\sbuild\\toolchained\\depot_tools\\gn.bat', 'gen', 'C:\\a\\pypdfium2\\pypdfium2\\sbuild\\toolchained\\pdfium\\out\\Default'] (cwd=WindowsPath('C:/a/pypdfium2/pypdfium2/sbuild/toolchained/pdfium'))
Traceback (most recent call last):
  File "C:\a\pypdfium2\pypdfium2\sbuild\toolchained\pdfium\build\vs_toolchain.py", line 656, in <module>
    sys.exit(main())
             ^^^^^^
  File "C:\a\pypdfium2\pypdfium2\sbuild\toolchained\pdfium\build\vs_toolchain.py", line 652, in main
    return commands[sys.argv[1]](*sys.argv[2:])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\a\pypdfium2\pypdfium2\sbuild\toolchained\pdfium\build\vs_toolchain.py", line 431, in CopyDlls
    _CopyDebugger(target_dir, target_cpu)
  File "C:\a\pypdfium2\pypdfium2\sbuild\toolchained\pdfium\build\vs_toolchain.py", line 464, in _CopyDebugger
    raise Exception('%s not found in "%s"\r\nYou must install '
Exception: dbghelp.dll not found in "C:\Program Files (x86)\Windows Kits\10\Debuggers\x64\dbghelp.dll"

You must install Windows 10 SDK version 10.0.26100.0 including the "Debugging Tools for Windows" feature.
ERROR at //build/toolchain/win/BUILD.gn:24:3: Script returned non-zero exit code.
  exec_script("../../vs_toolchain.py",
  ^----------
Current dir: C:/a/pypdfium2/pypdfium2/sbuild/toolchained/pdfium/out/Default/
Command: C:/a/pypdfium2/pypdfium2/sbuild/toolchained/depot_tools/bootstrap-2@3_11_8_chromium_35_bin/python3/bin/python3.exe C:/a/pypdfium2/pypdfium2/sbuild/toolchained/pdfium/build/vs_toolchain.py copy_dlls C:/a/pypdfium2/pypdfium2/sbuild/toolchained/pdfium/out/Default Release arm64
Returned 1 and printed out:

Copying C:\Program Files/Microsoft Visual Studio/2022/Enterprise\VC\Redist\MSVC\14.44.35112\arm64\Microsoft.VC143.CRT\msvcp140.dll to C:/a/pypdfium2/pypdfium2/sbuild/toolchained/pdfium/out/Default\msvcp140.dll...
Copying C:\Program Files/Microsoft Visual Studio/2022/Enterprise\VC\Redist\MSVC\14.44.35112\arm64\Microsoft.VC143.CRT\vccorlib140.dll to C:/a/pypdfium2/pypdfium2/sbuild/toolchained/pdfium/out/Default\vccorlib140.dll...
Copying C:\Program Files/Microsoft Visual Studio/2022/Enterprise\VC\Redist\MSVC\14.44.35112\arm64\Microsoft.VC143.CRT\vcruntime140.dll to C:/a/pypdfium2/pypdfium2/sbuild/toolchained/pdfium/out/Default\vcruntime140.dll...
Copying C:\Program Files (x86)\Windows Kits\10\Debuggers\arm64\dbghelp.dll to C:/a/pypdfium2/pypdfium2/sbuild/toolchained/pdfium/out/Default\dbghelp.dll...
Copying C:\Program Files (x86)\Windows Kits\10\Debuggers\arm64\dbgcore.dll to C:/a/pypdfium2/pypdfium2/sbuild/toolchained/pdfium/out/Default\dbgcore.dll...
Copying C:\Program Files/Microsoft Visual Studio/2022/Enterprise\DIA SDK\bin\amd64\msdia140.dll to C:/a/pypdfium2/pypdfium2/sbuild/toolchained/pdfium/out/Default\msdia140.dll...
Copying C:\Windows\System32\msvcp140.dll to C:/a/pypdfium2/pypdfium2/sbuild/toolchained/pdfium/out/Default\win_clang_x64\msvcp140.dll...
Copying C:\Windows\System32\vccorlib140.dll to C:/a/pypdfium2/pypdfium2/sbuild/toolchained/pdfium/out/Default\win_clang_x64\vccorlib140.dll...
Copying C:\Windows\System32\vcruntime140.dll to C:/a/pypdfium2/pypdfium2/sbuild/toolchained/pdfium/out/Default\win_clang_x64\vcruntime140.dll...
Copying C:\Windows\System32\vcruntime140_1.dll to C:/a/pypdfium2/pypdfium2/sbuild/toolchained/pdfium/out/Default\win_clang_x64\vcruntime140_1.dll...

See //BUILD.gn:10:1: which caused the file to be included.
group("default") {
^-----------------
Traceback (most recent call last):
  File "C:\a\pypdfium2\pypdfium2\setupsrc\build_toolchained.py", line 265, in <module>
    main_cli()
  File "C:\a\pypdfium2\pypdfium2\setupsrc\build_toolchained.py", line 261, in main_cli
    return main(**vars(args))
           ^^^^^^^^^^^^^^^^^^
  File "C:\a\pypdfium2\pypdfium2\setupsrc\build_toolchained.py", line 217, in main
    configure(GN, config_str)
  File "C:\a\pypdfium2\pypdfium2\setupsrc\build_toolchained.py", line 145, in configure
    run_cmd([*GN, "gen", PDFiumOutDir], cwd=PDFiumDir)
  File "C:\a\pypdfium2\pypdfium2\setupsrc\base.py", line 647, in run_cmd
    comp_process = subprocess.run(command, cwd=cwd, check=check, **kwargs)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\hostedtoolcache\windows\Python\3.12.10\arm64\Lib\subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['C:\\a\\pypdfium2\\pypdfium2\\sbuild\\toolchained\\depot_tools\\gn.bat', 'gen', 'C:\\a\\pypdfium2\\pypdfium2\\sbuild\\toolchained\\pdfium\\out\\Default']' returned non-zero exit status 1.
```

geisserml

unread,
Nov 14, 2025, 3:14:19 PM (13 days ago) Nov 14
to pdfium
Taking a look at the code, I think the failing spot implicitly assumes an x64 host if target_cpu == "arm64".
I'm getting past the error with this patch now:
```patch
diff --git a/vs_toolchain.py b/vs_toolchain.py
index 61b3229..4acf530 100755
--- a/vs_toolchain.py
+++ b/vs_toolchain.py
@@ -420,15 +420,6 @@ def CopyDlls(target_dir, configuration, target_cpu):
   if configuration == 'Debug':
     _CopyRuntime(target_dir, runtime_dir, target_cpu, debug=True)
   _CopyDebugger(target_dir, target_cpu)
-  if target_cpu == 'arm64':
-    target_dir = os.path.join(target_dir, 'win_clang_x64')
-    target_cpu = 'x64'
-    runtime_dir = x64_runtime
-    os.makedirs(target_dir, exist_ok=True)
-    _CopyRuntime(target_dir, runtime_dir, target_cpu, debug=False)
-    if configuration == 'Debug':
-      _CopyRuntime(target_dir, runtime_dir, target_cpu, debug=True)
-    _CopyDebugger(target_dir, target_cpu)
 
 
 def _CopyDebugger(target_dir, target_cpu):
```
I'd appreciate if this code could be updated such that this block is not run on a native arm64 host.
Weirdly enough though, changing the check to `if platform.machine().lower() != 'arm64' and target_cpu == 'arm64'` didn't work - but removing the block did.
I'm not sure why. Haven't debug printed yet, but it seems like platform.machine() returns something other than arm64. Possibly, this script is run by an (emulated) x64 build of Python?

geisserml

unread,
Nov 14, 2025, 3:37:36 PM (13 days ago) Nov 14
to pdfium
Another finding was that we strictly need to set `target_cpu = "arm64"`, otherwise we're still getting the vs_toolchain.py error, patch or no.
This is unlike the other platforms, where setting target_cpu is not needed for native compilation.

Lei Zhang

unread,
Nov 14, 2025, 4:38:25 PM (13 days ago) Nov 14
to geisserml, pdfium
Thanks for investigating this. Given vs_toolchain.py is part of
Chromium's //build dir, please consider asking on the chromium-dev
mailing list. Likely any improves made will benefit both Chromium and
PDFium.
> --
> You received this message because you are subscribed to the Google Groups "pdfium" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to pdfium+un...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/pdfium/bdb08da2-1c2e-4601-8ac6-365dc7b93712n%40googlegroups.com.

geisserml

unread,
Nov 14, 2025, 5:04:29 PM (13 days ago) Nov 14
to pdfium
Thanks for the info, I'll post any future questions about //build on chromium-dev then.
Reply all
Reply to author
Forward
0 new messages