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") {
48 unwind_sources += [ "src/Unwind_AppleExtras.cpp" ]
51 config("unwind_config") {
53 cflags_c = [ "-std=c99" ]
54 cflags_cc = [ "-fno-rtti" ]
55 include_dirs = [ "//libunwind/include" ]
56 if (target_os == "mac") {
57 cflags += [ "-U__STRICT_ANSI__" ]
61 if (libunwind_enable_shared) {
62 shared_library("unwind_shared") {
63 output_dir = runtimes_dir
64 output_name = "unwind"
65 if (target_os == "linux" || target_os == "mac") {
67 ldflags = [ "-nostdlib++" ]
73 if (target_os == "mac") {
75 "-compatibility_version 1",
76 "-install_name /usr/lib/libunwind.1.dylib",
79 sources = unwind_sources
80 public = unwind_headers
82 "//compiler-rt/lib/builtins",
84 configs += [ ":unwind_config" ]
86 "//llvm/utils/gn/build:no_exceptions",
87 "//llvm/utils/gn/build:no_rtti",
92 if (libunwind_enable_static) {
93 static_library("unwind_static") {
94 output_dir = runtimes_dir
95 output_name = "unwind"
96 complete_static_lib = true
97 configs -= [ "//llvm/utils/gn/build:thin_archive" ]
98 sources = unwind_sources
99 public = unwind_headers
100 if (libunwind_hermetic_static_library) {
101 cflags = [ "-fvisibility=hidden" ]
102 cflags_cc = [ "-fvisibility-global-new-delete-hidden" ]
103 defines = [ "_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS" ]
106 "//compiler-rt/lib/builtins",
108 configs += [ ":unwind_config" ]
110 "//llvm/utils/gn/build:no_exceptions",
111 "//llvm/utils/gn/build:no_rtti",
118 if (libunwind_enable_shared) {
119 deps += [ ":unwind_shared" ]
121 if (libunwind_enable_static) {
122 deps += [ ":unwind_static" ]