xref: /aosp_15_r20/external/perfetto/gn/standalone/toolchain/llvm.gni (revision 6dbdd20afdafa5e3ca9b8809fa73465d530080dc)
1# Copyright (C) 2017 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://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,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15import("//gn/standalone/sanitizers/vars.gni")
16
17declare_args() {
18  is_hermetic_clang = is_clang && (is_linux_host || is_win_host)
19  non_hermetic_clang_stdlib = ""
20}
21
22assert(!is_hermetic_clang || is_clang, "is_hermetic_clang requires is_clang")
23
24linux_llvm_objcopy = ""
25if (is_linux_host) {
26  if (is_hermetic_clang) {
27    _hermetic_llvm_dir =
28        rebase_path("//buildtools/linux64/clang", root_build_dir)
29    linux_clang_bin = "$_hermetic_llvm_dir/bin/clang"
30    linux_clangxx_bin = "$_hermetic_llvm_dir/bin/clang++"
31    linux_llvm_objcopy = "$_hermetic_llvm_dir/bin/llvm-objcopy"
32    linux_clang_linker = "lld"
33  } else if (is_clang && !is_system_compiler) {
34    # Guess the path for the system clang.
35    # When is_system_compiler = true users neet to explicitly set cc / target_cc
36    # vars in the GN args."
37    _find_llvm_out = exec_script("linux_find_llvm.py", [], "list lines")
38    _linux_llvm_dir = _find_llvm_out[0]
39    linux_clang_bin = _find_llvm_out[1]
40    linux_clangxx_bin = _find_llvm_out[2]
41    linux_clang_linker = "gold"
42  }
43} else if (is_mac_host && is_clang && !is_system_compiler) {
44  _mac_toolchain_dirs = exec_script("mac_find_llvm.py", [], "list lines")
45
46  # _mac_toolchain_dirs[0] contains the mac toolchain dir.
47  mac_clangrt_dir = _mac_toolchain_dirs[1]
48} else if (is_win_host) {
49  if (is_hermetic_clang) {
50    # Use the toolchain pulled by //tools/install-build-deps. This tracks
51    # chromium's llvm dist.
52    _llvm_win_path = rebase_path("//buildtools/win/clang/bin", root_build_dir)
53    win_clang_bin = "${_llvm_win_path}\clang-cl.exe"
54    win_clangxx_bin = "${_llvm_win_path}\clang-cl.exe"
55    win_clang_linker = "${_llvm_win_path}\lld-link.exe"
56  } else {
57    # Assume clang-cl.exe / lld-link.exe are on the PATH. The user can always
58    # ovveride them by setting cc/cxx/linker GN variables.
59    # See //gn/standalone/toolchain/BUILD.gn.
60    win_clang_bin = "clang-cl.exe"
61    win_clangxx_bin = "clang-cl.exe"
62    win_clang_linker = "lld-link.exe"
63  }
64}
65