Prepare mini_chromium for using clang on Windows

This does several things to prepare for using clang on Windows:

* It makes `mini_chromium_is_clang` a GN arg on Windows, so that
  it's possible to opt in to using clang via args.gn.
  (It doesn't change the default yet, and once the default is
  flipped, we can make it not an arg again.)

* It stops passing a few cl.exe flags to the compiler if clang is
  being used. clang-cl supports most of cl.exe's flags, but it warns
  about the LTCG flags. It also stops passing a few cl.exe flags that
  are silently ignored by clang-cl to keep command lines tidier.

* It passes a few clang-only flags such as `-m32` on x86.

* It passes warning flags that we pass on other platforms to the compiler
  to clang-cl on Windows too. The important one is `Wno-unused-parameter`:
  without this, we get hundreds of build warnings.

* It also disables a few clang warnings on Windows only. These can be
  cleaned up and turned on later.

* It updates win_helper.py to accept slashes in the path to ml in
  ExecAsmWrapper, like already done for the linker in ExecLinkWrapper()

* Finally, and most importantly, it makes the toolchain call clang-cl,
  lld-link, and llvm-ml instead of cl.exe, link.exe, and ml.exe.
  On arm64, we use clang-cl instead of armasm64.exe (matching Chromium).

There are several cleanups that can be done with clang that I haven't
done yet and am currently not planning on doing:

* The ninja -e and ninja -t msvc wrapper processes for cc, cxx, ld, ar, ml
  can be removed by instead using clang-cl's /winsysroot flag

* Once that's done, it should be reasonably straightforward to set up
  a cross build to enable building crashpad/win on linux

* https://blog.llvm.org/2019/11/deterministic-builds-with-clang-and-lld.html
  describes how to make the build fully deterministic with clang-cl

No behavior change, since clang is still off by default.

Bug: 384682775
Change-Id: Ie7b16a94c595fdf7e281c6127520b69d380408df
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/mini_chromium/+/6261289
Reviewed-by: Mark Mentovai <mark@chromium.org>
3 files changed
tree: 598ba6c714a0296d304c78e53fca11309344e87d
  1. base/
  2. build/
  3. testing/
  4. .gitattributes
  5. .gitignore
  6. .style.yapf
  7. AUTHORS
  8. BUILD.gn
  9. codereview.settings
  10. LICENSE
  11. OWNERS
  12. README.md
README.md

mini_chromium

This is mini_chromium, a small collection of useful low-level (“base”) routines from the Chromium open-source project. Chromium is large, sprawling, full of dependencies, and a web browser. mini_chromium is small, self-contained, and a library. mini_chromium is especially useful as a dependency of other code that wishes to use Chromium’s base routines. By using mini_chromium, other projects’ code can function in a standalone environment outside of Chromium without having to treat all of Chromium as a dependency. When building as part of Chromium, those projects’ code can use Chromium’s own (non-mini_chromium) base implementation.

Code provided in mini_chromium provides the same interface as the equivalent code in Chromium.

While it’s a goal of mini_chromium to maintain interface compatibility with Chromium’s base library for the interfaces it does implement, there’s no requirement that it use the same implementations as Chromium’s base library. Many of the implementations used in mini_chromium are identical to Chromium’s, but many others have been modified to eliminate dependencies that are not desired in mini_chromium, and a few are completely distinct from Chromium’s altogether. Additionally, when mini_chromium provides an interface in the form of a file or class present in Chromium, it’s not bound to provide all functions, methods, or types that the Chromium equivalent does. The differences noted above notwithstanding, the interfaces exposed by mini_chromium’s base are and must remain a strict subset of Chromium’s.

Crashpad is the chief consumer of mini_chromium.

Mark Mentovai
mark@chromium.org