1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
  104
  105

buildtools / third_party / libc++abi / BUILD.gn [blame]

# Copyright 2015 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/android/config.gni")
import("//build/config/c++/c++.gni")
import("//build/config/unwind.gni")

source_set("libc++abi") {
  if (export_libcxxabi_from_executables) {
    visibility = [ "//build/config:executable_deps" ]
  } else {
    visibility = [ "//buildtools/third_party/libc++" ]
  }

  # Fuchsia builds don't link against any libraries that provide stack
  # unwinding symbols, unlike Linux does with glibc (same applies for Android).
  # Build and link against libunwind manually to get this functionality.
  if (use_custom_libunwind) {
    deps = [ "//buildtools/third_party/libunwind" ]
  }

  # TODO(crbug.com/40273848): Move this build file to third_party/libc++/BUILD.gn once submodule migration is done
  sources = [
    "//third_party/libc++abi/src/src/abort_message.cpp",
    "//third_party/libc++abi/src/src/cxa_aux_runtime.cpp",
    "//third_party/libc++abi/src/src/cxa_default_handlers.cpp",
    "//third_party/libc++abi/src/src/cxa_exception.cpp",
    "//third_party/libc++abi/src/src/cxa_exception_storage.cpp",
    "//third_party/libc++abi/src/src/cxa_handlers.cpp",

    # This file is supposed to be used in fno-exception builds of
    # libc++abi.  We build lib++/libc++abi with exceptions enabled.
    #"//third_party/libc++abi/src/src/cxa_noexception.cpp",
    "//third_party/libc++abi/src/src/cxa_personality.cpp",
    "//third_party/libc++abi/src/src/cxa_vector.cpp",
    "//third_party/libc++abi/src/src/cxa_virtual.cpp",
    "//third_party/libc++abi/src/src/fallback_malloc.cpp",
    "//third_party/libc++abi/src/src/private_typeinfo.cpp",
    "//third_party/libc++abi/src/src/stdlib_exception.cpp",
    "//third_party/libc++abi/src/src/stdlib_stdexcept.cpp",
    "//third_party/libc++abi/src/src/stdlib_typeinfo.cpp",
  ]

  if (!is_tsan) {
    sources += [ "//third_party/libc++abi/src/src/cxa_guard.cpp" ]
  }

  # See the comment in cxa_demangle_stub.cc for why we don't use LLVM's
  # demangler on android.
  # TODO(thakis): Switch to building with LIBCXXABI_NON_DEMANGLING_TERMINATE
  # defined instead.
  if (is_android) {
    sources += [ "cxa_demangle_stub.cc" ]
  } else {
    sources += [ "//third_party/libc++abi/src/src/cxa_demangle.cpp" ]
  }

  defines = [ "LIBCXXABI_SILENT_TERMINATE" ]

  if (is_fuchsia || (is_posix && !is_apple)) {
    sources += [ "//third_party/libc++abi/src/src/cxa_thread_atexit.cpp" ]

    # Android's bionic libc added support for '__cxa_thread_atexit_impl' as of
    # API level 23.
    if (is_android &&
        ((!android_64bit_target_cpu && android32_ndk_api_level >= 23) ||
         (android_64bit_target_cpu && android64_ndk_api_level >= 23))) {
      defines += [ "HAVE___CXA_THREAD_ATEXIT_IMPL" ]
    }
  }

  configs -= [
    "//build/config/compiler:chromium_code",
    "//build/config/compiler:no_exceptions",
    "//build/config/compiler:no_rtti",
    "//build/config/coverage:default_coverage",
  ]
  configs += [
    "//build/config/compiler:no_chromium_code",
    "//build/config/compiler:exceptions",
    "//build/config/compiler:rtti",
    "//buildtools/third_party/libc++:config",
  ]

  # private_typeinfo.cpp implements __dynamic_cast(), which is the runtime
  # bit that implements dynamic_cast<>(). But ubsan's vptr check inserts
  # dynamic_cast<>()s, which leads to infinite recursion. So make sure we don't
  # pass -fsanitize=vptr.
  configs -= [ "//build/config/sanitizers:default_sanitizer_flags" ]
  configs +=
      [ "//build/config/sanitizers:default_sanitizer_flags_but_ubsan_vptr" ]

  if (export_libcxxabi_from_executables || libcxx_is_shared) {
    configs -= [ "//build/config/gcc:symbol_visibility_hidden" ]
    configs += [ "//build/config/gcc:symbol_visibility_default" ]
  }

  # libc++abi depends on libc++ internals.
  include_dirs = [ "//third_party/libc++/src/src" ]

  if (use_libcxx_modules) {
    configs -= [ "//build/config/compiler:libcxx_module" ]
  }
}