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

buildtools / third_party / libunwind / BUILD.gn [blame]

# Copyright 2017 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/c++/c++.gni")

config("libunwind_config") {
  defines = [ "_LIBUNWIND_IS_NATIVE_ONLY" ]
  cflags = [
    "-fstrict-aliasing",
    "-fPIC",

    # ValueAsBitPattern in Unwind-EHABI.cpp is only used on Debug builds.
    "-Wno-unused-function",

    # libunwind expects to be compiled with unwind tables so it can
    # unwind its own frames.
    "-funwind-tables",
  ]
}

# TODO(crbug.com/40273848): Move this build file to third_party/libc++/BUILD.gn once submodule migration is done
source_set("libunwind") {
  visibility = [ "//buildtools/third_party/libc++abi" ]
  if (is_android) {
    visibility += [ "//services/tracing/public/cpp" ]
  }
  if (!is_component_build) {
    defines = [ "_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS" ]
  }
  include_dirs = [ "//third_party/libunwind/src/include" ]
  sources = [
    # C++ sources
    "//third_party/libunwind/src/src/Unwind-EHABI.cpp",
    "//third_party/libunwind/src/src/libunwind.cpp",

    # C sources
    "//third_party/libunwind/src/src/Unwind-sjlj.c",
    "//third_party/libunwind/src/src/UnwindLevel1-gcc-ext.c",
    "//third_party/libunwind/src/src/UnwindLevel1.c",

    # ASM sources
    "//third_party/libunwind/src/src/UnwindRegistersRestore.S",
    "//third_party/libunwind/src/src/UnwindRegistersSave.S",
  ]
  configs -= [
    "//build/config/compiler:chromium_code",
    "//build/config/compiler:no_exceptions",
    "//build/config/compiler:no_rtti",
    "//build/config/coverage:default_coverage",
    "//build/config/compiler:default_optimization",
  ]
  configs += [
    "//build/config/compiler:no_chromium_code",
    "//build/config/compiler:exceptions",
    "//build/config/compiler:rtti",
    "//build/config/compiler:optimize_speed",

    # Must be after no_chromium_code
    ":libunwind_config",
  ]
}