• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2023 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14if (current_cpu == "arm" || current_cpu == "arm64") {
15  import("$build_root/config/arm.gni")
16}
17
18if (current_cpu == "arm" || current_cpu == "arm64") {
19  import("$build_root/config/arm.gni")
20}
21
22is_ohos_or_android = is_ohos || is_android
23
24optimize_for_size = is_ohos_or_android
25
26declare_args() {
27  symbol_level = -1
28
29  # Set to true to use lld, the LLVM linker. This flag may be used on Windows,
30  # Linux.
31  use_lld = is_clang &&
32            (is_win || (is_linux && current_cpu == "x64") ||
33             (is_linux && (current_cpu == "x86" || current_cpu == "arm64")) ||
34             (is_ohos_or_android && (current_cpu != "arm" || arm_version >= 7)))
35}
36
37declare_args() {
38  # Whether to use the gold linker from binutils instead of lld or bfd.
39  use_gold =
40      !use_lld &&
41      ((is_linux && (current_cpu == "x64" || current_cpu == "x86" ||
42                     current_cpu == "arm")) ||
43       (is_ohos_or_android && (current_cpu == "x86" || current_cpu == "x64" ||
44                               current_cpu == "arm" || current_cpu == "arm64")))
45}
46
47if (symbol_level == -1) {
48  if (is_ohos_or_android) {
49    # With instrumentation enabled, debug info puts libchrome.so over 4gb, which
50    # causes the linker to produce an invalid ELF. http://crbug.com/574476
51    symbol_level = 0
52  } else if (is_ohos) {
53    # Reduce symbol level when it will cause invalid elf files to be created
54    # (due to file size). https://crbug.com/648948.
55    symbol_level = 1
56  } else {
57    symbol_level = 0
58  }
59}
60