[llvm-readobj] - Simplify stack-sizes.test test case.
[llvm-complete.git] / utils / gn / secondary / libunwind / src / BUILD.gn
blob1e96b5643ad3b14f0f6ef82cb7171ff62d0795d3
1 import("//clang/runtimes.gni")
3 declare_args() {
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
14 unwind_headers = [
15   "../include/libunwind.h",
16   "../include/unwind.h",
18 if (target_os == "mac") {
19   unwind_headers += [
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",
23   ]
26 unwind_sources = [
27   "libunwind.cpp",
28   "Unwind-EHABI.cpp",
29   "Unwind-seh.cpp",
30   "UnwindLevel1.c",
31   "UnwindLevel1-gcc-ext.c",
32   "Unwind-sjlj.c",
33   "UnwindRegistersRestore.S",
34   "UnwindRegistersSave.S",
35   "AddressSpace.hpp",
36   "assembly.h",
37   "CompactUnwinder.hpp",
38   "config.h",
39   "dwarf2.h",
40   "DwarfInstructions.hpp",
41   "DwarfParser.hpp",
42   "libunwind_ext.h",
43   "Registers.hpp",
44   "RWMutex.hpp",
45   "UnwindCursor.hpp",
47 if (target_os == "mac") {
48   unwind_sources += [ "src/Unwind_AppleExtras.cpp" ]
51 config("unwind_config") {
52   cflags = []
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__" ]
58   }
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") {
66       cflags = [ "-fPIC" ]
67       ldflags = [ "-nostdlib++" ]
68       libs = [
69         "dl",
70         "pthread",
71       ]
72     }
73     if (target_os == "mac") {
74       ldflags += [
75         "-compatibility_version 1",
76         "-install_name /usr/lib/libunwind.1.dylib",
77       ]
78     }
79     sources = unwind_sources
80     public = unwind_headers
81     deps = [
82       "//compiler-rt/lib/builtins",
83     ]
84     configs += [ ":unwind_config" ]
85     configs -= [
86       "//llvm/utils/gn/build:no_exceptions",
87       "//llvm/utils/gn/build:no_rtti",
88     ]
89   }
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" ]
104     }
105     deps = [
106       "//compiler-rt/lib/builtins",
107     ]
108     configs += [ ":unwind_config" ]
109     configs -= [
110       "//llvm/utils/gn/build:no_exceptions",
111       "//llvm/utils/gn/build:no_rtti",
112     ]
113   }
116 group("src") {
117   deps = []
118   if (libunwind_enable_shared) {
119     deps += [ ":unwind_shared" ]
120   }
121   if (libunwind_enable_static) {
122     deps += [ ":unwind_static" ]
123   }