blob: 89761185faf95de248518755482f9401d883f46f [file] [log] [blame]
Alexei Frolov844ff0f2020-05-06 12:15:29 -07001# 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
Armando Montanezfb3d3fb2020-06-09 18:12:12 -070015# gn-format disable
16import("//build_overrides/pigweed.gni")
Alexei Frolov844ff0f2020-05-06 12:15:29 -070017declare_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.
Alexei Frolov4c0428a2020-06-10 10:46:04 -070020 pw_toolchain_SANITIZER = ""
Alexei Frolov844ff0f2020-05-06 12:15:29 -070021
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.
Alexei Frolov4c0428a2020-06-10 10:46:04 -070025 pw_toolchain_OSS_FUZZ_ENABLED = false
Alexei Frolov844ff0f2020-05-06 12:15:29 -070026}
27
28# Specifies the tools used by host Clang toolchains.
29_host_clang_toolchain = {
30 # Note: On macOS, there is no "llvm-ar", only "ar", which happens to be LLVM
31 # ar. This should get updated for linux systems.
32 ar = "ar"
33
Alexei Frolov4c0428a2020-06-10 10:46:04 -070034 if (pw_toolchain_OSS_FUZZ_ENABLED) {
Alexei Frolov844ff0f2020-05-06 12:15:29 -070035 cc = getenv("CC")
36 cxx = getenv("CXX")
37 } else {
38 cc = "clang"
39 cxx = "clang++"
40 }
41
42 is_host_toolchain = true
43}
44
45# Common default scope shared by all host Clang toolchains.
46_defaults = {
47 default_configs = [
48 "$dir_pw_build:extra_debugging",
49 "$dir_pw_toolchain/host_clang:no_system_libcpp",
50 "$dir_pw_toolchain/host_clang:xcode_sysroot",
51 ]
Alexei Frolov4c0428a2020-06-10 10:46:04 -070052 if (pw_toolchain_SANITIZER != "") {
Alexei Frolov258fc1b2020-06-10 16:24:50 -070053 configs +=
54 [ "$dir_pw_toolchain/host_clang:sanitize_$pw_toolchain_SANITIZER" ]
Alexei Frolov844ff0f2020-05-06 12:15:29 -070055 }
Alexei Frolov4c0428a2020-06-10 10:46:04 -070056 if (pw_toolchain_OSS_FUZZ_ENABLED) {
Alexei Frolov844ff0f2020-05-06 12:15:29 -070057 default_configs += oss_fuzz_added_configs
58 default_configs += [ "$dir_pw_fuzzer:oss_fuzz_extra" ]
59
60 # Add the configs to be removed. They will be de-duplicated, and this
61 # ensures they are present to be removed.
62 default_configs += oss_fuzz_removed_configs
Alexei Frolove9bc14b2020-06-15 10:25:10 -070063 remove_default_configs = oss_fuzz_removed_configs
Alexei Frolov844ff0f2020-05-06 12:15:29 -070064 }
65}
66
Armando Montanez164624f2020-06-10 15:00:29 -070067pw_toolchain_host_clang = {
68 debug = {
69 name = "host_clang_debug"
70 forward_variables_from(_host_clang_toolchain, "*")
71 defaults = {
72 forward_variables_from(_defaults, "*")
73 default_configs += [ "$dir_pw_build:optimize_debugging" ]
74 }
Alexei Frolov4c0428a2020-06-10 10:46:04 -070075 }
Alexei Frolov4c0428a2020-06-10 10:46:04 -070076
Armando Montanez164624f2020-06-10 15:00:29 -070077 speed_optimized = {
78 name = "host_clang_speed_optimized"
79 forward_variables_from(_host_clang_toolchain, "*")
80 defaults = {
81 forward_variables_from(_defaults, "*")
82 default_configs += [ "$dir_pw_build:optimize_speed" ]
83 }
Alexei Frolov4c0428a2020-06-10 10:46:04 -070084 }
Alexei Frolov4c0428a2020-06-10 10:46:04 -070085
Armando Montanez164624f2020-06-10 15:00:29 -070086 size_optimized = {
87 name = "host_clang_size_optimized"
Alexei Frolov844ff0f2020-05-06 12:15:29 -070088 forward_variables_from(_host_clang_toolchain, "*")
89 defaults = {
90 forward_variables_from(_defaults, "*")
91 default_configs += [ "$dir_pw_build:optimize_size" ]
92 }
Armando Montanez164624f2020-06-10 15:00:29 -070093 }
94}
95
96# Describes host clang toolchains.
97pw_toolchain_host_clang_list = [
98 pw_toolchain_host_clang.debug,
99 pw_toolchain_host_clang.speed_optimized,
100 pw_toolchain_host_clang.size_optimized,
Alexei Frolov844ff0f2020-05-06 12:15:29 -0700101]