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 = [ "${musl_sysroot}/usr/include/${abi_target}" ] 46 47 ldflags += [ "--target=$abi_target" ] 48 49 # Assign any flags set for the C compiler to asmflags so that they are sent 50 # to the assembler. 51 asmflags = cflags 52} 53 54# This is included by reference in the //build/config/compiler:runtime_library 55# config that is applied to all targets. It is here to separate out the logic 56# that is ohos-only. Please see that target for advice on what should go in 57# :runtime_library vs. :compiler. 58config("runtime_library") { 59 cflags_cc = [] 60 61 defines = [ 62 "__GNU_SOURCE=1", # Necessary for clone(). 63 "CHROMIUM_CXX_TWEAK_INLINES", # Saves binary size. 64 ] 65 66 defines += [ 67 "__MUSL__", 68 "_LIBCPP_HAS_MUSL_LIBC", 69 "__BUILD_LINUX_WITH_CLANG", 70 ] 71 ldflags = [ "-nostdlib" ] 72 73 libs = [] 74 75 # arm builds of libc++ starting in NDK r12 depend on unwind. 76 if (current_cpu == "arm" || current_cpu == "arm64") { 77 libs += [ "unwind" ] 78 } 79 80 ldflags += [ 81 "-L" + rebase_path("${musl_sysroot}/usr/lib/${abi_target}", root_build_dir), 82 "-L" + rebase_path( 83 "${clang_base_path}/lib/clang/${clang_version}/lib/${abi_target}", 84 root_build_dir), 85 ] 86 87 libs += [ 88 rebase_path(libclang_rt_file), 89 "c", 90 rebase_path(libcxxabi_file), 91 ] 92 93 if (current_cpu == "arm" && arm_version == 6) { 94 libs += [ "atomic" ] 95 } 96 97 ldflags += [ "-Wl,--warn-shared-textrel" ] 98 99 # We add this parameter to speed up link process, enable_lto_O0 default is false. 100 if (!is_mac && !is_win && use_lld && enable_lto_O0) { 101 ldflags += [ "-Wl,--lto-O0" ] 102 } 103} 104 105config("executable_config") { 106 configs = [ "//build/config/security:executable_config" ] 107} 108 109# Used for instrumented build to generate the orderfile. 110config("default_orderfile_instrumentation") { 111 if (use_order_profiling) { 112 cflags = [ "-finstrument-function-entry-bare" ] 113 if (use_thin_lto) { 114 ldflags = [ "-Wl,-u,__cyg_profile_func_enter_bare" ] 115 } 116 } 117} 118