1# Tint
2
3Tint is a compiler for the WebGPU Shader Language (WGSL).
4
5This is not an officially supported Google product.
6
7## Requirements
8 * Git
9 * CMake (3.10.2 or later)
10 * Ninja (or other build tool)
11 * Python, for fetching dependencies
12 * [depot_tools] in your path
13
14## Build options
15 * `TINT_BUILD_SPV_READER` : enable the SPIR-V input reader (off by default)
16 * `TINT_BUILD_WGSL_READER` : enable the WGSL input reader (on by default)
17 * `TINT_BUILD_SPV_WRITER` : enable the SPIR-V output writer (on by default)
18 * `TINT_BUILD_WGSL_WRITER` : enable the WGSL output writer (on by default)
19 * `TINT_BUILD_FUZZERS` : enable building fuzzzers (off by default)
20
21## Building
22Tint uses Chromium dependency management so you need to install [depot_tools]
23and add it to your PATH.
24
25[depot_tools]: http://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up
26
27### Getting source & dependencies
28
29```sh
30# Clone the repo as "tint"
31git clone https://dawn.googlesource.com/tint tint
32cd tint
33
34# Bootstrap the gclient configuration
35cp standalone.gclient .gclient
36
37# Fetch external dependencies and toolchains with gclient
38gclient sync
39```
40
41### Compiling using CMake + Ninja
42```sh
43mkdir -p out/Debug
44cd out/Debug
45cmake -GNinja ../..
46ninja # or autoninja
47```
48
49### Compiling using CMake + make
50```sh
51mkdir -p out/Debug
52cd out/Debug
53cmake ../..
54make # -j N for N-way parallel build
55```
56
57### Compiling using gn + ninja
58```sh
59mkdir -p out/Debug
60gn gen out/Debug
61autoninja -C out/Debug
62```
63
64### Fuzzers on MacOS
65If you are attempting fuzz, using `TINT_BUILD_FUZZERS=ON`, the version of llvm
66in the XCode SDK does not have the needed libfuzzer functionality included.
67
68The build error that you will see from using the XCode SDK will look something
69like this:
70```
71ld: file not found:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.0/lib/darwin/libclang_rt.fuzzer_osx.a
72```
73
74The solution to this problem is to use a full version llvm, like what you would
75get via homebrew, `brew install llvm`, and use something like `CC=<path to full
76clang> cmake ..` to setup a build using that toolchain.
77
78### Checking [chromium-style] issues in CMake builds
79The gn based work flow uses the Chromium toolchain for building in anticipation
80of integration of Tint into Chromium based projects. This toolchain has
81additional plugins for checking for style issues, which are marked with
82[chromium-style] in log messages. This means that this toolchain is more strict
83then the default clang toolchain.
84
85In the future we will have a CQ that will build this work flow and flag issues
86automatically. Until that is in place, to avoid causing breakages you can run
87the [chromium-style] checks using the CMake based work flows. This requires
88setting `CC` to the version of clang checked out by `gclient sync` and setting
89the `TINT_CHECK_CHROMIUM_STYLE` to `ON`.
90
91```sh
92mkdir -p out/style
93cd out/style
94cmake ../..
95CC=../../third_party/llvm-build/Release+Asserts/bin/clang cmake -DTINT_CHECK_CHROMIUM_STYLE=ON ../../ # add -GNinja for ninja builds
96```
97
98## Issues
99Please file any issues or feature requests at
100https://bugs.chromium.org/p/tint/issues/entry
101
102## Contributing
103Please see the CONTRIBUTING and CODE_OF_CONDUCT files on how to contribute to
104Tint.
105