1 import("//clang/runtimes.gni")
4 # Build libunwind as a shared library.
5 libunwind_enable_shared = true
7 # Build libunwind as a static library.
8 libunwind_enable_static = true
10 # Do not export any symbols from the static library.
11 libunwind_hermetic_static_library = true
15 "../include/libunwind.h",
16 "../include/unwind.h",
18 if (target_os == "mac") {
20 # This comment prevents `gn format` from putting the file on the same line
21 # as `sources +=`, for sync_source_lists_from_cmake.py.
22 "../include/mach-o/compact_unwind_encoding.h",
31 "UnwindLevel1-gcc-ext.c",
33 "UnwindRegistersRestore.S",
34 "UnwindRegistersSave.S",
37 "CompactUnwinder.hpp",
40 "DwarfInstructions.hpp",
47 if (target_os == "mac") {
49 # This comment prevents `gn format` from putting the file on the same line
50 # as `sources +=`, for sync_source_lists_from_cmake.py.
51 "Unwind_AppleExtras.cpp",
55 config("unwind_config") {
57 cflags_c = [ "-std=c99" ]
58 cflags_cc = [ "-fno-rtti" ]
59 include_dirs = [ "//libunwind/include" ]
60 if (target_os == "mac") {
61 cflags += [ "-U__STRICT_ANSI__" ]
65 if (libunwind_enable_shared) {
66 shared_library("unwind_shared") {
67 output_dir = runtimes_dir
68 output_name = "unwind"
69 if (target_os == "linux" || target_os == "mac") {
71 ldflags = [ "-nostdlib++" ]
77 if (target_os == "mac") {
79 "-compatibility_version 1",
80 "-install_name /usr/lib/libunwind.1.dylib",
83 sources = unwind_sources
84 public = unwind_headers
86 "//compiler-rt/lib/builtins",
88 configs += [ ":unwind_config" ]
90 "//llvm/utils/gn/build:no_exceptions",
91 "//llvm/utils/gn/build:no_rtti",
96 if (libunwind_enable_static) {
97 static_library("unwind_static") {
98 output_dir = runtimes_dir
99 output_name = "unwind"
100 complete_static_lib = true
101 configs -= [ "//llvm/utils/gn/build:thin_archive" ]
102 sources = unwind_sources
103 public = unwind_headers
104 if (libunwind_hermetic_static_library) {
105 cflags = [ "-fvisibility=hidden" ]
106 cflags_cc = [ "-fvisibility-global-new-delete-hidden" ]
107 defines = [ "_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS" ]
110 "//compiler-rt/lib/builtins",
112 configs += [ ":unwind_config" ]
114 "//llvm/utils/gn/build:no_exceptions",
115 "//llvm/utils/gn/build:no_rtti",
122 if (libunwind_enable_shared) {
123 deps += [ ":unwind_shared" ]
125 if (libunwind_enable_static) {
126 deps += [ ":unwind_static" ]