Import changes for goma client

  - 67f444c4cd4cbd8ebf7e52ddeb9ea5abbe307471 Use go 1.17.8
  - 88a8e41116560f499100efd9eee1037a2e666e08 Roll boringssl from 4b55af0fc5c6 to 81502beeddc5 (1 revis...
  - c5b52d3fb1e3f1cc4dec5fffcea4574dd1fb63d2 Roll clang from 3730026620f6 to 1f05f8edb265 (3 revisions)
  - 6bffed5922afe245b27becbe4ba32c63a8b5eb64 Roll boringssl from 4d955d20d27b to 4b55af0fc5c6 (4 revis...
  - 0b01151aca26fadcd8be79f917ca0a2296d46bd1 Roll boringssl from 123eaaef26ab to 4d955d20d27b (24 revi...
  - d8e57dc791c2b91725b8fafc47d9b8d61ca14813 update_boringssl: add new os-arch dir
  - 524dbc285f1a4636d6f1af65fe779bf934200748 update clang features
  - 1758a1403446b36fd44d388d9a74d929e391866c Roll client/tools/clang/ b9894ca3b..373002662 (7 commits)

Bug: b/219613977
GitOrigin-RevId: 67f444c4cd4cbd8ebf7e52ddeb9ea5abbe307471
Change-Id: I040ea87868eca2435f9134f6d089d08f71035b75
61 files changed
tree: 0ebd011355a0b00bd3fbfaf10701388600b3b840
  1. base/
  2. benchmark/
  3. build/
  4. client/
  5. doc/
  6. go/
  7. infra/
  8. lib/
  9. test/
  10. testing/
  11. third_party/
  12. tools/
  13. .clang-format
  14. .gitignore
  15. .gn
  16. .style.yapf
  17. BUILD.gn
  18. codereview.settings
  19. CONTRIBUTING.md
  20. DEPS
  21. LICENSE
  22. OWNERS
  23. PRESUBMIT.py
  24. README.md
README.md

Goma client

Goma is a distributed compiler service for open-source project such as Chromium and Android. It's some kind of replacement of distcc+ccache.

NOTE: For non-Googler usage, please see Goma for Chromium Contributors.

Google employees interested in contributing to the goma client should use internal version. see http://go/ma-client-code

How Goma works

Goma hooks a compile request, and sends it to a backend compile server. If you have plenty of backend servers, a lot of compile can be processed in parallel, for example, -j100, -j500 or -j1000.

Also, the Goma backend caches the compile result. If the same compile request comes, the cached result is returned from the Goma cache server.

How to build

Goma client can be built on Linux, Mac, and Win.

Prerequisite

  1. Use 64bit platform (Linux, Mac or Win).
  2. Install depot_tools.
  3. Install dependencies.
    • On Mac, install Xcode.
    • On Windows, install Visual Studio 2017. Community edition is OK.

Checkout source

$ mkdir goma && cd goma
$ gclient config https://chromium.googlesource.com/infra/goma/client
$ gclient sync
$ cd client

We assume the Goma client code is checked out to ${GOMA_SRC}. You can set this in your environment, but do not export it as it will make gomacc complain.

If you want to develop goma client, make goma client source unmanaged by gclient. Open .gclient file, and check "managed" value. If it's True, changed it to False. Otherwise, gclient will manage your repository, so your checkout can be unintentionally changed with gclient sync.

Move to client directory (which is under git repo), and configure git repository with your username and emails.

$ cd client
$ git config user.email 'foo@example.com'
$ git config user.name 'Your Name'

Build

$ cd "${GOMA_SRC}/client"
$ gclient sync
$ gn gen --args="is_debug=false" out/Release
$ ninja -C out/Release

Several important gn args

The build option can be modified with gn args.

is_debug=true/false
  Do debug build if true.
dcheck_always_on=true/false
  Enable DCHECK always (even in release build).
is_asan=true/false
  Use ASan build (with clang).
use_link_time_optimization=true/false
  Currently working only on Win. If true, /LTCG is enable.
use_lld=true/false
  Use lld for link (it will be fast)

Run unittest

$ cd "${GOMA_SRC}/client"
$ ./build/run_unittest.py --target=Release --build-dir=out

Coding style

Follow Google code style.

For C++11/14 features, we prefer to follow Chromium's guidelines.

How to use

For Chromium/Android development

Goma can be integrated with Chromium/Android development easily.

  1. Build goma client
  2. Start compiler_proxy
$ "${GOMA_SRC}/client/out/Release/goma_ctl.py" start

For Chromium

In Chromium src, specify the following args in gn args

use_goma = true
goma_dir = "${GOMA_SRC}/client/out/Release"  (Replace ${GOMA_SRC} to your checkout)

Then build like the following:

$ cd /path/to/chromium/src/out/Release
$ ninja -j100 chrome

More details are avairable in chromium's build instructions.

For Android

$ source build/envsetup.sh
$ lunch aosp_arm-eng
$ GOMA_DIR="${GOMA_SRC}/client/out/Release" USE_GOMA=true make -j4

Here, -j4 is not related to Goma parallelism. Android internally sets -j500 (or -j with NINJA_REMOTE_NUM_JOBS environment variable) for Goma.

For general development

  1. Build Goma client
  2. Start compiler_proxy
$ ./goma_ctl.py ensure_start
  1. Change your build script so that gomacc is prepended to compiler command. For example:
$ gomacc clang++ -c foo.cc
  1. Build your product with make -j100, ninja -j100 or larger -j. Check http://localhost:8088 to see compiler_proxy is actually working.
  • You can use autoninja in depot_tools instead of specifying gomacc manually.