llvm.org GIT mirror llvm / 6f0a807
[gn] Support for building libunwind This change introduces support for building libuwind. The library build should be complete, but not all CMake options have been replicated in GN. We also don't support tests yet. We only support two stage build at the moment. Differential Revision: https://reviews.llvm.org/D60370 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359804 91177308-0d34-0410-b5e6-96231b3b80d8 Petr Hosek 5 months ago
3 changed file(s) with 133 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
1010 "//llvm/test",
1111 ]
1212 if (current_os == "linux") {
13 deps += [ "//compiler-rt" ]
13 deps += [
14 "//compiler-rt",
15 "//libunwind",
16 ]
1417 }
1518 if (current_os == "linux" || current_os == "android") {
1619 deps += [ "//compiler-rt/test/hwasan" ]
0 group("libunwind") {
1 deps = [
2 "//libunwind/src(//llvm/utils/gn/build/toolchain:stage2_unix)",
3 ]
4 }
0 import("//clang/runtimes.gni")
1
2 declare_args() {
3 # Build libunwind as a shared library.
4 libunwind_enable_shared = true
5
6 # Build libunwind as a static library.
7 libunwind_enable_static = true
8
9 # Do not export any symbols from the static library.
10 libunwind_hermetic_static_library = true
11 }
12
13 unwind_headers = [
14 "../include/libunwind.h",
15 "../include/unwind.h",
16 ]
17 if (target_os == "mac") {
18 unwind_headers += [
19 # This comment prevents `gn format` from putting the file on the same line
20 # as `sources +=`, for sync_source_lists_from_cmake.py.
21 "../include/mach-o/compact_unwind_encoding.h",
22 ]
23 }
24
25 unwind_sources = [
26 "libunwind.cpp",
27 "Unwind-EHABI.cpp",
28 "Unwind-seh.cpp",
29 "UnwindLevel1.c",
30 "UnwindLevel1-gcc-ext.c",
31 "Unwind-sjlj.c",
32 "UnwindRegistersRestore.S",
33 "UnwindRegistersSave.S",
34 "AddressSpace.hpp",
35 "assembly.h",
36 "CompactUnwinder.hpp",
37 "config.h",
38 "dwarf2.h",
39 "DwarfInstructions.hpp",
40 "DwarfParser.hpp",
41 "libunwind_ext.h",
42 "Registers.hpp",
43 "RWMutex.hpp",
44 "UnwindCursor.hpp",
45 ]
46 if (target_os == "mac") {
47 unwind_sources += [ "src/Unwind_AppleExtras.cpp" ]
48 }
49
50 config("unwind_config") {
51 cflags = []
52 cflags_c = [ "-std=c99" ]
53 cflags_cc = [ "-fno-rtti" ]
54 include_dirs = [ "//libunwind/include" ]
55 if (target_os == "mac") {
56 cflags += [ "-U__STRICT_ANSI__" ]
57 }
58 }
59
60 if (libunwind_enable_shared) {
61 shared_library("unwind_shared") {
62 output_dir = runtimes_dir
63 output_name = "unwind"
64 if (target_os == "linux" || target_os == "mac") {
65 cflags = [ "-fPIC" ]
66 ldflags = [ "-nostdlib++" ]
67 libs = [
68 "dl",
69 "pthread",
70 ]
71 }
72 if (target_os == "mac") {
73 ldflags += [
74 "-compatibility_version 1",
75 "-install_name /usr/lib/libunwind.1.dylib",
76 ]
77 }
78 sources = unwind_sources
79 public = unwind_headers
80 deps = [
81 "//compiler-rt/lib/builtins",
82 ]
83 configs += [ ":unwind_config" ]
84 configs -= [
85 "//llvm/utils/gn/build:no_exceptions",
86 "//llvm/utils/gn/build:no_rtti",
87 ]
88 }
89 }
90
91 if (libunwind_enable_static) {
92 static_library("unwind_static") {
93 output_dir = runtimes_dir
94 output_name = "unwind"
95 complete_static_lib = true
96 configs -= [ "//llvm/utils/gn/build:thin_archive" ]
97 sources = unwind_sources
98 public = unwind_headers
99 if (libunwind_hermetic_static_library) {
100 cflags = [ "-fvisibility=hidden" ]
101 cflags_cc = [ "-fvisibility-global-new-delete-hidden" ]
102 defines = [ "_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS" ]
103 }
104 deps = [
105 "//compiler-rt/lib/builtins",
106 ]
107 configs += [ ":unwind_config" ]
108 configs -= [
109 "//llvm/utils/gn/build:no_exceptions",
110 "//llvm/utils/gn/build:no_rtti",
111 ]
112 }
113 }
114
115 group("src") {
116 deps = []
117 if (libunwind_enable_shared) {
118 deps += [ ":unwind_shared" ]
119 }
120 if (libunwind_enable_static) {
121 deps += [ ":unwind_static" ]
122 }
123 }