tor-browser

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

BUILD.gn (4746B)


      1 import("//chromium/build/config/c++/c++.gni")
      2 import("//chromium/build/config/chrome_build.gni")
      3 import("//chromium/build/config/chromeos/ui_mode.gni")
      4 import("//chromium/build/config/compiler/compiler.gni")
      5 import("//chromium/build/config/dcheck_always_on.gni")
      6 import("//buildtools/deps_revisions.gni")
      7 
      8 assert(use_custom_libcxx, "should only be used if use_custom_libcxx is set")
      9 
     10 # This is included by reference in the //build/config/compiler:runtime_library
     11 # config that is applied to all targets. It is here to separate out the logic
     12 # that is specific to libc++. Please see that target for advice on what should
     13 # go in :runtime_library vs. :compiler.
     14 config("runtime_library") {
     15   cflags = []
     16   cflags_cc = []
     17   defines = []
     18   include_dirs = []
     19   ldflags = []
     20   libs = []
     21 
     22   # Fixed libc++ configuration macros are in
     23   # buildtools/third_party/libc++/__config_site. This config only has defines
     24   # that vary depending on gn args, and non-define flags.
     25 
     26   if (!libcxx_is_shared) {
     27     # Don't leak any symbols on a static build.
     28     defines += [ "_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS" ]
     29     if (!export_libcxxabi_from_executables && !is_win) {
     30       defines += [ "_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS" ]
     31     }
     32   }
     33 
     34   include_dirs += [ "//buildtools/third_party/libc++" ]
     35 
     36   # libc++ has two levels of additional checking:
     37   # 1. _LIBCPP_ENABLE_ASSERTIONS enables assertions for bounds checking.
     38   #    We always enable this in __config_site, in all build configurations.
     39   # 2. _LIBCPP_ENABLE_DEBUG_MODE enables iterator debugging and other
     40   #    expensive checks. Enable these only if enable_iterator_debugging is on.
     41   if (enable_iterator_debugging) {
     42     defines += [ "_LIBCPP_ENABLE_DEBUG_MODE" ]
     43   }
     44 
     45   # Fuzzers build parts of the code with asan enabled and some with it
     46   # disabled. That's incompatible with _LIBCPP_INSTRUMENTED_WITH_ASAN, see
     47   # https://crbug.com/347026228#comment25
     48   # TODO(thakis): Enable on apple if https://llvm.org/PR96099 gets fixed.
     49   if (is_asan && !use_fuzzing_engine && !is_apple) {
     50     defines += [ "_LIBCPP_INSTRUMENTED_WITH_ASAN=1" ]
     51   } else {
     52     defines += [ "_LIBCPP_INSTRUMENTED_WITH_ASAN=0" ]
     53   }
     54 
     55   defines += [ "CR_LIBCXX_REVISION=$libcxx_revision" ]
     56 
     57   # Temporarily add a define to force a rebuild when changing
     58   # buildtools/third_party/libc++/__config_site which isn't picked up by
     59   # dependency tracking (because it's an #include of headers included via
     60   # -isysroot).
     61   # TODO(thakis): Remove this after a few days.
     62   defines += [ "TMP_REBUILD_HACK" ]
     63 
     64   if (is_win) {
     65     # Intentionally not using libc++abi on Windows because libc++abi only
     66     # implements the Itanium C++ ABI, and not the Microsoft ABI which we use on
     67     # Windows (and we need to use in order to interoperate correctly with COM
     68     # among other things).
     69     assert(!export_libcxxabi_from_executables,
     70            "Don't use libcxxabi on Windows.")
     71 
     72     cflags_cc +=
     73         [ "-I" + rebase_path("$libcxx_prefix/include", root_build_dir) ]
     74 
     75     # Add a debug visualizer for Microsoft's debuggers so that they can display
     76     # libc++ types well.
     77     if (libcxx_natvis_include) {
     78       # chrome.natvis listed as an input in //buildtools/third_party/libc++ to
     79       # guarantee relinking on changes.
     80       ldflags += [ "/NATVIS:" + rebase_path("libc++.natvis", root_build_dir) ]
     81     }
     82   } else {
     83     cflags_cc += [
     84       "-nostdinc++",
     85       "-isystem" + rebase_path("$libcxx_prefix/include", root_build_dir),
     86       "-isystem" + rebase_path("$libcxxabi_prefix/include", root_build_dir),
     87     ]
     88 
     89     cflags_objcc = cflags_cc
     90 
     91     # Make sure we don't link against the system libstdc++ or libc++.
     92     if (is_clang) {
     93       ldflags += [ "-nostdlib++" ]
     94     } else {
     95       # Gcc has a built-in abs() definition with default visibility.
     96       # If it was not disabled, it would conflict with libc++'s abs()
     97       # with hidden visibility.
     98       cflags += [ "-fno-builtin-abs" ]
     99 
    100       ldflags += [ "-nodefaultlibs" ]
    101 
    102       # Unfortunately, there's no way to disable linking against just libc++
    103       # (gcc doesn't have -notstdlib++:
    104       # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83931); -nodefaultlibs
    105       # removes all of the default libraries, so add back the ones that we need.
    106       libs += [
    107         "c",
    108         "gcc_s",
    109         "m",
    110         "rt",
    111       ]
    112     }
    113   }
    114 
    115   # In a world without NaCl, the `runtime_library` config would also configure
    116   # the `_LIBCPP_ENABLE_ASSERTIONS` define to enable hardening when using the
    117   # custom hermetic libc++. However, this is currently added by the `compiler`
    118   # config instead, since this hardening define should also be used by the NaCl
    119   # saigo toolchain, which uses a prebuilt libc++ that is distinct from the
    120   # custom hermetic libc++.
    121 }