xref: /aosp_15_r20/external/angle/third_party/clspv/gn/build/BUILD.gn (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1# This sets up the GN configs that are used by default in GN targets in
2# BUILDCONFIG.gn.
3#
4# This is based on LLVM `utils/gn/build/BUILD.gn`. Only the LLVM and Clang
5# related options are retained
6
7import("//build_overrides/clspv.gni")
8
9declare_args() {
10  # Whether to build everything with test coverage information.
11  # After building with this, run tests and then run
12  #    llvm/utils/prepare-code-coverage-artifact.py \
13  #        --compilation-dir=out/gn \
14  #        .../llvm-profdata .../llvm-cov out/gn/profiles/ report/ \
15  #        out/gn/bin/llvm-undname ...
16  # to generate a HTML report for the binaries passed in the last line.
17  llvm_build_instrumented_coverage = false
18
19  # Whether to build everything with instrumentation for PGO
20  # After building with this:
21  # 1. Remove old profile data with `rm *.profraw`
22  # 2. Run the built instrumented binaries.
23  #    This will produce *.profraw files in the current working directory.
24  # 3. Run `llvm-profdata merge *.profraw -o llvm.profdata` to merge them.
25  # 4. Then build again, with this set to false, and with
26  #    `llvm_pgo_use = "//llvm.profdata"` set to use the created profile.
27  llvm_pgo_instrument = false
28
29  # If non-empty, path to merged profiling data used for optimization
30  # See documentation for llvm_pgo_instrument for how to create profile data.
31  llvm_pgo_use = ""
32
33  # If set, puts relative paths in debug info.
34  # Makes the build output independent of the build directory, but makes
35  # most debuggers harder to use. See "Getting to local determinism" and
36  # "Getting debuggers to work well with locally deterministic builds" in
37  # http://blog.llvm.org/2019/11/deterministic-builds-with-clang-and-lld.html
38  # for more information.
39  use_relative_paths_in_debug_info = false
40
41  # The version of host gcc. Ignored if is_clang is true.
42  gcc_version = 9
43}
44
45assert(!llvm_build_instrumented_coverage || is_clang,
46       "llvm_build_instrumented_coverage requires clang as host compiler")
47assert(!llvm_pgo_instrument || is_clang,
48       "llvm_pgo_instrument requires clang as host compiler")
49assert(llvm_pgo_use == "" || is_clang,
50       "llvm_pgo_use requires clang as host compiler")
51assert(!llvm_pgo_instrument || llvm_pgo_use == "",
52       "set at most one of llvm_pgo_instrument and llvm_pgo_use")
53
54config("llvm_code") {
55  include_dirs = [
56    "//$clspv_llvm_dir/llvm/include",
57    "$root_gen_dir/$clspv_llvm_dir//llvm/include",
58  ]
59  if (current_os != "win") {
60    cflags = [ "-fPIC" ]
61    if (is_clang) {
62      cflags += [
63        "-Wno-deprecated-declarations",
64        "-Wno-deprecated-this-capture",
65        "-Wno-deprecated-enum-enum-conversion",
66        "-Wno-deprecated-anon-enum-enum-conversion",
67      ]
68    }
69  }
70}
71
72config("clang_code") {
73  if (current_os != "win") {
74    cflags = [
75      "-fno-strict-aliasing",
76      "-Wno-deprecated-declarations",
77    ]
78  }
79  include_dirs = [
80    "//$clspv_llvm_dir/clang/include",
81    "$root_gen_dir/$clspv_llvm_dir//clang/include",
82  ]
83}
84
85config("warn_covered_switch_default") {
86  if (is_clang) {
87    cflags = [ "-Wcovered-switch-default" ]
88  }
89}
90