交叉编译 chromium windows linux
Cross-compiling Chrome/win
As many Chromium developers are on Linux/Mac, cross-compiling Chromium for Windows targets facilitates development for Windows targets on non-Windows machines.
It‘s possible to build most parts of the codebase on a Linux or Mac host while targeting Windows. It’s also possible to run the locally-built binaries on swarming. This document describes how to set that up, and current restrictions.
Limitations
What does not work:
js2gtest
tests are omitted from the build (bug)- on Mac hosts, 32-bit builds don't work (bug has more information, and this is unlikely to ever change)
All other targets build fine (including chrome
, browser_tests
, ...).
Uses of .asm
files have been stubbed out. As a result, Crashpad cannot report crashes, and NaCl defaults to disabled and cannot be enabled in cross builds (.asm bug).
.gclient setup
-
Tell gclient that you need Windows build dependencies by adding
target_os = ['win']
to the end of your.gclient
. (If you already have atarget_os
line in there, just add'win'
to the list.) e.g.solutions = [ { ... } ] target_os = ['android', 'win']
-
gclient sync
, follow instructions on screen.
If you're at Google, this will automatically download the Windows SDK for you. If this fails with an error:
Please follow the instructions at https://chromium.googlesource.com/chromium/src/+/master/docs/windows_build_instructions.md
then you may need to re-authenticate via:
cd path/to/chrome/src # Follow instructions, enter 0 as project id. download_from_google_storage --config
If you are not at Google, you can package your Windows SDK installation into a zip file by running the following on a Windows machine:
cd path/to/depot_tools/win_toolchain # customize the Windows SDK version numbers python package_from_installed.py 2017 -w 10.0.17134.0
These commands create a zip file named <hash value>.zip
. Then, to use the generated file in a Linux or Mac host, the following environment variables need to be set:
export DEPOT_TOOLS_WIN_TOOLCHAIN_BASE_URL=<path/to/sdk/zip/file> export GYP_MSVS_HASH_<toolchain hash>=<hash value>
<toolchain hash>
is hardcoded in src/build/vs_toolchain.py
and can be found by setting DEPOT_TOOLS_WIN_TOOLCHAIN_BASE_URL
and running gclient sync
:
gclient sync ... Running hooks: 17% (11/64) win_toolchain ________ running '/usr/bin/python src/build/vs_toolchain.py update --force' in <chromium dir> Windows toolchain out of date or doesn't exist, updating (Pro)... current_hashes: desired_hash: <toolchain hash>
GN setup
Add target_os = "win"
to your args.gn. Then just build, e.g.
ninja -C out/gnwin base_unittests.exe
Goma
For now, one needs to use the rbe backend, not the borg backend (default for Googlers). Use cloud backend instead.
goma_auth.py login
# GOMA_* are needed for Googlers only
export GOMA_SERVER_HOST=goma.chromium.org
export GOMA_RPC_EXTRA_PARAMS=?rbe
goma_ctl.py ensure_start
Copying and running chrome
A convenient way to copy chrome over to a Windows box is to build the mini_installer
target. Then, copy just mini_installer.exe
over to the Windows box and run it to install the chrome you just built.
Note that the mini_installer
doesn't include PDB files. PDB files are needed to correctly symbolize stack traces (or if you want to attach a debugger).
Running tests on swarming
You can run the Windows binaries you built on swarming, like so:
tools/run-swarmed.py out/gnwin base_unittests [ --gtest_filter=... ]
See the contents of run-swarmed.py for how to do this manually.
The linux-win_cross-rel buildbot does 64-bit release cross builds, and also runs tests. You can look at it to get an idea of which tests pass in the cross build.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
2018-06-05 琶音的正确弹奏法
2014-06-05 用友