• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2014 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import("//build/config/compiler/compiler.gni")
6import("//build/config/ohos/config.gni")
7
8import("//build/config/c++/c++.gni")
9import("//build/config/sanitizers/sanitizers.gni")
10
11assert(is_ohos)
12
13# This is included by reference in the //build/config/compiler config that
14# is applied to all targets. It is here to separate out the logic that is
15# ohos-only.
16config("compiler") {
17  cflags = [
18    "-ffunction-sections",
19    "-fno-short-enums",
20  ]
21  defines = [
22    # The NDK has these things, but doesn't define the constants to say that it
23    # does. Define them here instead.
24    "HAVE_SYS_UIO_H",
25  ]
26
27  defines += [
28    "__MUSL__",
29    "_LIBCPP_HAS_MUSL_LIBC",
30    "__BUILD_LINUX_WITH_CLANG",
31  ]
32
33  ldflags = [
34    "-Wl,--no-undefined",
35    "-Wl,--exclude-libs=libunwind_llvm.a",
36    "-Wl,--exclude-libs=libc++_static.a",
37
38    # Don't allow visible symbols from libraries that contain
39    # assembly code with symbols that aren't hidden properly.
40    # http://crbug.com/448386
41    "-Wl,--exclude-libs=libvpx_assembly_arm.a",
42  ]
43  if (current_cpu == "riscv64") {
44    ldflags -= [ "-Wl,--exclude-libs=libvpx_assembly_arm.a" ]
45  }
46
47  cflags += [ "--target=$abi_target" ]
48  include_dirs = [ "${musl_sysroot}/usr/include/${abi_target}" ]
49
50  ldflags += [ "--target=$abi_target" ]
51
52  # Assign any flags set for the C compiler to asmflags so that they are sent
53  # to the assembler.
54  asmflags = cflags
55}
56
57# This is included by reference in the //build/config/compiler:runtime_library
58# config that is applied to all targets. It is here to separate out the logic
59# that is ohos-only. Please see that target for advice on what should go in
60# :runtime_library vs. :compiler.
61config("runtime_library") {
62  cflags_cc = []
63
64  defines = [
65    "__GNU_SOURCE=1",  # Necessary for clone().
66    "CHROMIUM_CXX_TWEAK_INLINES",  # Saves binary size.
67  ]
68
69  defines += [
70    "__MUSL__",
71    "_LIBCPP_HAS_MUSL_LIBC",
72    "__BUILD_LINUX_WITH_CLANG",
73  ]
74  ldflags = [ "-nostdlib" ]
75
76  libs = []
77
78  # arm builds of libc++ starting in NDK r12 depend on unwind.
79  if (current_cpu == "arm" || current_cpu == "arm64" ||
80      current_cpu == "riscv64") {
81    libs += [ "unwind" ]
82  }
83
84  ldflags += [
85    "-L" + rebase_path("${musl_sysroot}/usr/lib/${abi_target}", root_build_dir),
86    "-L" + rebase_path(
87            "${clang_base_path}/lib/clang/${clang_version}/lib/${abi_target}",
88            root_build_dir),
89  ]
90  if (current_cpu == "riscv64") {
91    ldflags += [ "-Wl,--dynamic-linker,/lib/ld-musl-${musl_arch}.so.1" ]
92  }
93
94  libs += [
95    rebase_path(libclang_rt_file),
96    "c",
97    rebase_path(libcxxabi_file),
98  ]
99
100  if (!is_llvm_build && current_cpu != "riscv64") {
101    libs += [ rebase_path(libgwp_asan_file) ]
102  }
103
104  if (current_cpu == "arm" && arm_version == 6) {
105    libs += [ "atomic" ]
106  }
107
108  ldflags += [ "-Wl,--warn-shared-textrel" ]
109
110  # We add this parameter to speed up link process, enable_lto_O0 default is false.
111  if (!is_mac && !is_win && use_lld && enable_lto_O0) {
112    ldflags += [ "-Wl,--lto-O0" ]
113  }
114}
115
116config("executable_config") {
117  configs = [ "//build/config/security:executable_config" ]
118}
119
120# Used for instrumented build to generate the orderfile.
121config("default_orderfile_instrumentation") {
122  if (use_order_profiling) {
123    cflags = [ "-finstrument-function-entry-bare" ]
124    if (use_thin_lto) {
125      ldflags = [ "-Wl,-u,__cyg_profile_func_enter_bare" ]
126    }
127  }
128}
129
130config("adlt_config") {
131  ldflags = [
132    "-Wl,--emit-relocs",
133    "-Wl,--no-relax",
134  ]
135}
136