• 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
44  cflags += [ "--target=$abi_target" ]
45  include_dirs = [
46    "${musl_sysroot}/usr/include/${abi_target}",
47    "${clang_base_path}/include/c++/v1",
48  ]
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") {
80    libs += [ "unwind" ]
81  }
82
83  ldflags += [
84    "-L" +
85        rebase_path("${clang_base_path}/lib/${abi_target}/c++", root_build_dir),
86    "-L" + rebase_path("${musl_sysroot}/usr/lib/${abi_target}", root_build_dir),
87    "-L" + rebase_path("${clang_base_path}/lib/clang/10.0.1/lib/${abi_target}",
88                       root_build_dir),
89  ]
90
91  libs += [
92    rebase_path(libclang_rt_file),
93    "c",
94    "c++",
95    "c++abi",
96  ]
97
98  if (current_cpu == "arm" && arm_version == 6) {
99    libs += [ "atomic" ]
100  }
101
102  ldflags += [ "-Wl,--warn-shared-textrel" ]
103}
104
105config("executable_config") {
106  cflags = [ "-fPIE" ]
107  asmflags = [ "-fPIE" ]
108  ldflags = [ "-pie" ]
109}
110
111# Used for instrumented build to generate the orderfile.
112config("default_orderfile_instrumentation") {
113  if (use_order_profiling) {
114    cflags = [ "-finstrument-function-entry-bare" ]
115    if (use_thin_lto) {
116      ldflags = [ "-Wl,-u,__cyg_profile_func_enter_bare" ]
117    }
118  }
119}
120