1
1
import (" //clang/runtimes.gni" )
2
+ import (" //compiler-rt/target.gni" )
2
3
3
4
declare_args () {
4
5
# Build libunwind as a shared library.
5
6
libunwind_enable_shared = true
6
7
7
8
# Build libunwind as a static library.
8
9
libunwind_enable_static = true
9
-
10
- # Do not export any symbols from the static library.
11
- libunwind_hermetic_static_library = true
12
10
}
13
11
14
12
unwind_headers = [
15
13
" ../include/libunwind.h" ,
16
14
" ../include/unwind.h" ,
17
15
]
18
- if (target_os == " mac" ) {
16
+ if (current_os == " mac" ) {
19
17
unwind_headers += [
20
18
# Make `gn format` not collapse this, for sync_source_lists_from_cmake.py.
21
19
" ../include/mach-o/compact_unwind_encoding.h" ,
@@ -44,33 +42,47 @@ unwind_sources = [
44
42
" libunwind.cpp" ,
45
43
" libunwind_ext.h" ,
46
44
]
47
- if (target_os == " mac" ) {
45
+ if (current_os == " mac" ) {
48
46
unwind_sources += [ " Unwind_AppleExtras.cpp" ]
49
47
}
50
48
49
+ if (current_os == " android" ) {
50
+ if (current_cpu == " arm64" ) {
51
+ unwind_output_dir = " $crt_current_out_dir /aarch64"
52
+ } else if (current_cpu == " arm" ) {
53
+ unwind_output_dir = " $crt_current_out_dir /arm"
54
+ }
55
+ } else {
56
+ unwind_output_dir = runtimes_dir
57
+ }
58
+
51
59
config (" unwind_config" ) {
52
60
cflags = []
53
61
cflags_c = [ " -std=c99" ]
54
62
cflags_cc = [ " -fno-rtti" ]
63
+ defines = [ " _LIBUNWIND_IS_NATIVE_ONLY" ]
55
64
include_dirs = [ " //libunwind/include" ]
56
- if (target_os == " mac" ) {
65
+ if (current_os == " mac" ) {
57
66
cflags += [ " -U__STRICT_ANSI__" ]
58
67
}
68
+ if (current_os == " android" ) {
69
+ defines += [ " _LIBUNWIND_USE_DLADDR=0" ]
70
+ }
59
71
}
60
72
61
73
if (libunwind_enable_shared ) {
62
74
shared_library (" unwind_shared" ) {
63
- output_dir = runtimes_dir
75
+ output_dir = unwind_output_dir
64
76
output_name = " unwind"
65
- if (target_os == " linux" || target_os == " mac" ) {
77
+ if (current_os == " linux" || current_os == " mac" ) {
66
78
cflags = [ " -fPIC" ]
67
79
ldflags = [ " -nostdlib++" ]
68
80
libs = [
69
81
" dl" ,
70
82
" pthread" ,
71
83
]
72
84
}
73
- if (target_os == " mac" ) {
85
+ if (current_os == " mac" ) {
74
86
ldflags += [
75
87
" -compatibility_version 1" ,
76
88
" -install_name /usr/lib/libunwind.1.dylib" ,
@@ -88,24 +100,35 @@ if (libunwind_enable_shared) {
88
100
}
89
101
90
102
if (libunwind_enable_static ) {
91
- static_library (" unwind_static" ) {
92
- output_dir = runtimes_dir
93
- output_name = " unwind"
94
- complete_static_lib = true
95
- configs -= [ " //llvm/utils/gn/build:thin_archive" ]
96
- sources = unwind_sources
97
- public = unwind_headers
98
- if (libunwind_hermetic_static_library ) {
99
- cflags = [ " -fvisibility=hidden" ]
100
- cflags_cc = [ " -fvisibility-global-new-delete-hidden" ]
101
- defines = [ " _LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS" ]
103
+ template (" libunwind_static_library" ) {
104
+ static_library (target_name ) {
105
+ output_dir = unwind_output_dir
106
+ output_name = invoker .output_name
107
+ complete_static_lib = true
108
+ configs -= [ " //llvm/utils/gn/build:thin_archive" ]
109
+ sources = unwind_sources
110
+ public = unwind_headers
111
+ if (! invoker .export ) {
112
+ cflags = [ " -fvisibility=hidden" ]
113
+ cflags_cc = [ " -fvisibility-global-new-delete-hidden" ]
114
+ defines = [ " _LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS" ]
115
+ }
116
+ deps = [ " //compiler-rt/lib/builtins" ]
117
+ configs += [ " :unwind_config" ]
118
+ configs -= [
119
+ " //llvm/utils/gn/build:no_exceptions" ,
120
+ " //llvm/utils/gn/build:no_rtti" ,
121
+ ]
102
122
}
103
- deps = [ " //compiler-rt/lib/builtins" ]
104
- configs += [ " :unwind_config" ]
105
- configs -= [
106
- " //llvm/utils/gn/build:no_exceptions" ,
107
- " //llvm/utils/gn/build:no_rtti" ,
108
- ]
123
+ }
124
+
125
+ libunwind_static_library (" unwind_static_exported" ) {
126
+ output_name = " unwind-exported"
127
+ export = true
128
+ }
129
+ libunwind_static_library (" unwind_static" ) {
130
+ output_name = " unwind"
131
+ export = false
109
132
}
110
133
}
111
134
@@ -115,6 +138,9 @@ group("src") {
115
138
deps += [ " :unwind_shared" ]
116
139
}
117
140
if (libunwind_enable_static ) {
118
- deps += [ " :unwind_static" ]
141
+ deps += [
142
+ " :unwind_static" ,
143
+ " :unwind_static_exported" ,
144
+ ]
119
145
}
120
146
}
0 commit comments