tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

BUILD.gn (5708B)


      1 # Copyright 2014 The Chromium Authors
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 import("//chromium/build/config/android/rules.gni")
      6 import("//chromium/build/config/c++/c++.gni")
      7 import("//chromium/build/config/compiler/compiler.gni")
      8 import("//chromium/build/config/sanitizers/sanitizers.gni")
      9 
     10 if (current_toolchain == default_toolchain) {
     11   import("//chromium/build/toolchain/concurrent_links.gni")
     12 }
     13 
     14 assert(is_android)
     15 
     16 # This is included by reference in the //build/config/compiler config that
     17 # is applied to all targets. It is here to separate out the logic that is
     18 # Android-only.
     19 config("compiler") {
     20   cflags = [
     21     "-ffunction-sections",
     22     "-fno-short-enums",
     23   ]
     24   defines = [
     25     "ANDROID",
     26 
     27     # https://android.googlesource.com/platform/ndk/+/master/docs/BuildSystemMaintainers.md#weak-symbols-for-api-definitions
     28     "__ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__",
     29 
     30     # The NDK has these things, but doesn't define the constants to say that it
     31     # does. Define them here instead.
     32     "HAVE_SYS_UIO_H",
     33 
     34     # Forces full rebuilds on NDK rolls. To rebuild everything when NDK version
     35     # stays the same, increment the suffix number.
     36     "ANDROID_NDK_VERSION_ROLL=${android_ndk_version}_1",
     37   ]
     38 
     39   if (android_64bit_target_cpu) {
     40     _max_page_size = 16384
     41   } else {
     42     _max_page_size = 4096
     43   }
     44 
     45   ldflags = [
     46     # Don't allow visible symbols from libraries that contain
     47     # assembly code with symbols that aren't hidden properly.
     48     # http://crbug.com/448386
     49     "-Wl,--exclude-libs=libvpx_assembly_arm.a",
     50 
     51     # Reduce the page size from 65536 in order to reduce binary size slightly
     52     # by shrinking the alignment gap between segments. This also causes all
     53     # segments to be mapped adjacently, which breakpad relies on.
     54     "-Wl,-z,max-page-size=$_max_page_size",
     55   ]
     56 
     57   if (target_cpu == "arm64") {
     58     if (arm_control_flow_integrity == "standard") {
     59       cflags += [ "-mbranch-protection=standard" ]
     60       rustflags = [ "-Zbranch-protection=pac-ret,bti" ]
     61     } else if (arm_control_flow_integrity == "pac") {
     62       cflags += [ "-mbranch-protection=pac-ret" ]
     63       rustflags = [ "-Zbranch-protection=pac-ret" ]
     64     }
     65   }
     66 
     67   # Disable TLSDESC for riscv64 until the Android NDK supports it. While
     68   # Chromium's clang turns it on by default for Android RISC-V devices, NDK r27
     69   # currently has it disabled. This can likely be removed in NDK r28.
     70   if (target_cpu == "riscv64") {
     71     cflags += [ "-mtls-dialect=trad" ]
     72   }
     73 
     74   # $compile_api_level corresponds to the API level used for the sysroot path
     75   # calculation in //build/config/android/config.gni
     76   if (android_64bit_target_cpu) {
     77     compile_api_level = android64_ndk_api_level
     78   } else {
     79     compile_api_level = android32_ndk_api_level
     80   }
     81 
     82   cflags += [ "--target=$android_abi_target$compile_api_level" ]
     83   ldflags += [ "--target=$android_abi_target$compile_api_level" ]
     84 
     85   # Assign any flags set for the C compiler to asmflags so that they are sent
     86   # to the assembler.
     87   asmflags = cflags
     88 }
     89 
     90 # This is included by reference in the //build/config/compiler:runtime_library
     91 # config that is applied to all targets. It is here to separate out the logic
     92 # that is Android-only. Please see that target for advice on what should go in
     93 # :runtime_library vs. :compiler.
     94 config("runtime_library") {
     95 }
     96 
     97 config("hide_all_but_jni_onload") {
     98   _version_script = "//chromium/build/android/android_only_explicit_jni_exports.lst"
     99   inputs = [ _version_script ]
    100   ldflags =
    101       [ "-Wl,--version-script=" + rebase_path(_version_script, root_build_dir) ]
    102 }
    103 
    104 config("hide_all_but_jni") {
    105   _version_script = "//chromium/build/android/android_only_jni_exports.lst"
    106   inputs = [ _version_script ]
    107   ldflags =
    108       [ "-Wl,--version-script=" + rebase_path(_version_script, root_build_dir) ]
    109 }
    110 
    111 config("lld_pack_relocations") {
    112   ldflags = [ "-Wl,--pack-dyn-relocs=android" ]
    113 }
    114 
    115 config("lld_relr_relocations") {
    116   # RELR supported API 30+, but supported 28+ with --use-android-relr-tags.
    117   # https://android.googlesource.com/platform/bionic/+/master/android-changes-for-ndk-developers.md#relative-relocations-relr
    118   ldflags = [ "-Wl,--pack-dyn-relocs=relr,--use-android-relr-tags" ]
    119 }
    120 
    121 config("lld_branch_target_hardening") {
    122   # Config opts a shared library into BTI linker hardening. This
    123   # is an opt-in config (rather than default-enabled) to avoid
    124   # interfering with the V8 CFI bots (crbug.com/1334614).
    125   if (target_cpu == "arm64") {
    126     if (arm_control_flow_integrity == "standard") {
    127       # Linking objects without GNU_PROPERTY_AARCH64_FEATURE_1_BTI
    128       # in their .gnu.note section implicitly results in the final
    129       # binary losing Branch Target Identification (BTI) support.
    130       # Issue a warning if this happens.
    131       ldflags = [ "-Wl,-z,force-bti" ]
    132     }
    133   }
    134 }
    135 
    136 # Used for instrumented build to generate the orderfile.
    137 config("default_orderfile_instrumentation") {
    138   if (use_order_profiling) {
    139     cflags = [ "-finstrument-function-entry-bare" ]
    140     if (use_thin_lto) {
    141       # TODO(pcc): This should not be necessary. Remove once
    142       # https://reviews.llvm.org/D50016 lands and gets rolled in.
    143       ldflags = [ "-Wl,-u,__cyg_profile_func_enter_bare" ]
    144     }
    145   }
    146 }
    147 
    148 if (current_toolchain == default_toolchain) {
    149   # nocompile tests share output directory to avoid them all needing to rebuild
    150   # things. But this also means they can't run in parallel.
    151   pool("nocompile_pool") {
    152     depth = 1
    153   }
    154 
    155   # When defined, this pool should be used instead of link_pool for command
    156   # that need 1-2GB of RAM. https://crbug.com/1078460
    157   if (defined(java_cmd_pool_size)) {
    158     pool("java_cmd_pool") {
    159       depth = java_cmd_pool_size
    160     }
    161   }
    162 }