• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2020 The Pigweed Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14
15import("//build_overrides/pigweed.gni")
16
17declare_args() {
18  # Sets the sanitizer to pass to clang. Valid values are those for "-fsanitize"
19  # listed in https://clang.llvm.org/docs/UsersManual.html#id9.
20  pw_toolchain_SANITIZERS = []
21
22  # Indicates if this build is a part of OSS-Fuzz, which needs to be able to
23  # provide its own compiler and flags. This violates the build hermeticisim and
24  # should only be used for OSS-Fuzz.
25  pw_toolchain_OSS_FUZZ_ENABLED = false
26}
27
28# Specifies the tools used by host Clang toolchains.
29_host_clang_toolchain = {
30  ar = "llvm-ar"
31
32  if (pw_toolchain_OSS_FUZZ_ENABLED) {
33    cc = getenv("CC")
34    cxx = getenv("CXX")
35  } else {
36    cc = "clang"
37    cxx = "clang++"
38  }
39
40  is_host_toolchain = true
41}
42
43# Common default scope shared by all host Clang toolchains.
44_defaults = {
45  default_configs = [
46    "$dir_pw_build:extra_debugging",
47    "$dir_pw_toolchain/host_clang:no_system_libcpp",
48    "$dir_pw_toolchain/host_clang:xcode_sysroot",
49  ]
50}
51
52pw_toolchain_host_clang = {
53  debug = {
54    name = "host_clang_debug"
55    forward_variables_from(_host_clang_toolchain, "*")
56    defaults = {
57      forward_variables_from(_defaults, "*")
58      default_configs += [ "$dir_pw_build:optimize_debugging" ]
59    }
60  }
61
62  speed_optimized = {
63    name = "host_clang_speed_optimized"
64    forward_variables_from(_host_clang_toolchain, "*")
65    defaults = {
66      forward_variables_from(_defaults, "*")
67      default_configs += [ "$dir_pw_build:optimize_speed" ]
68    }
69  }
70
71  size_optimized = {
72    name = "host_clang_size_optimized"
73    forward_variables_from(_host_clang_toolchain, "*")
74    defaults = {
75      forward_variables_from(_defaults, "*")
76      default_configs += [ "$dir_pw_build:optimize_size" ]
77    }
78  }
79
80  fuzz = {
81    name = "host_clang_fuzz"
82    forward_variables_from(_host_clang_toolchain, "*")
83    defaults = {
84      forward_variables_from(_defaults, "*")
85
86      # Fuzz faster.
87      default_configs += [ "$dir_pw_build:optimize_speed" ]
88
89      if (pw_toolchain_SANITIZERS == []) {
90        # Default to ASan for fuzzing, which is what we typically care about.
91        pw_toolchain_SANITIZERS = [ "address" ]
92      }
93      foreach(sanitizer, pw_toolchain_SANITIZERS) {
94        default_configs +=
95            [ "$dir_pw_toolchain/host_clang:sanitize_$sanitizer" ]
96      }
97
98      if (pw_toolchain_OSS_FUZZ_ENABLED) {
99        default_configs += [ "$dir_pw_fuzzer:oss_fuzz_extra" ]
100      }
101    }
102  }
103}
104
105# Describes host clang toolchains.
106pw_toolchain_host_clang_list = [
107  pw_toolchain_host_clang.debug,
108  pw_toolchain_host_clang.speed_optimized,
109  pw_toolchain_host_clang.size_optimized,
110  pw_toolchain_host_clang.fuzz,
111]
112