summaryrefslogtreecommitdiffstats
path: root/llvm/utils
diff options
context:
space:
mode:
authorPetr Hosek <phosek@chromium.org>2019-05-02 17:29:37 +0000
committerPetr Hosek <phosek@chromium.org>2019-05-02 17:29:37 +0000
commitf0652f03b66e8abc0100da8829f0af27ac8fb2d6 (patch)
tree6d2738374ac5f03a8396f3c928116d0a69879d19 /llvm/utils
parent156226bb7042def3af8b7a9ef81a05a5d41b52eb (diff)
downloadbcm5719-llvm-f0652f03b66e8abc0100da8829f0af27ac8fb2d6.tar.gz
bcm5719-llvm-f0652f03b66e8abc0100da8829f0af27ac8fb2d6.zip
[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 llvm-svn: 359804
Diffstat (limited to 'llvm/utils')
-rw-r--r--llvm/utils/gn/secondary/BUILD.gn5
-rw-r--r--llvm/utils/gn/secondary/libunwind/BUILD.gn5
-rw-r--r--llvm/utils/gn/secondary/libunwind/src/BUILD.gn124
3 files changed, 133 insertions, 1 deletions
diff --git a/llvm/utils/gn/secondary/BUILD.gn b/llvm/utils/gn/secondary/BUILD.gn
index 5fbddf93168..af0c85711c4 100644
--- a/llvm/utils/gn/secondary/BUILD.gn
+++ b/llvm/utils/gn/secondary/BUILD.gn
@@ -11,7 +11,10 @@ group("default") {
"//llvm/test",
]
if (current_os == "linux") {
- deps += [ "//compiler-rt" ]
+ deps += [
+ "//compiler-rt",
+ "//libunwind",
+ ]
}
if (current_os == "linux" || current_os == "android") {
deps += [ "//compiler-rt/test/hwasan" ]
diff --git a/llvm/utils/gn/secondary/libunwind/BUILD.gn b/llvm/utils/gn/secondary/libunwind/BUILD.gn
new file mode 100644
index 00000000000..b55d9c75808
--- /dev/null
+++ b/llvm/utils/gn/secondary/libunwind/BUILD.gn
@@ -0,0 +1,5 @@
+group("libunwind") {
+ deps = [
+ "//libunwind/src(//llvm/utils/gn/build/toolchain:stage2_unix)",
+ ]
+}
diff --git a/llvm/utils/gn/secondary/libunwind/src/BUILD.gn b/llvm/utils/gn/secondary/libunwind/src/BUILD.gn
new file mode 100644
index 00000000000..1e96b5643ad
--- /dev/null
+++ b/llvm/utils/gn/secondary/libunwind/src/BUILD.gn
@@ -0,0 +1,124 @@
+import("//clang/runtimes.gni")
+
+declare_args() {
+ # Build libunwind as a shared library.
+ libunwind_enable_shared = true
+
+ # Build libunwind as a static library.
+ libunwind_enable_static = true
+
+ # Do not export any symbols from the static library.
+ libunwind_hermetic_static_library = true
+}
+
+unwind_headers = [
+ "../include/libunwind.h",
+ "../include/unwind.h",
+]
+if (target_os == "mac") {
+ unwind_headers += [
+ # This comment prevents `gn format` from putting the file on the same line
+ # as `sources +=`, for sync_source_lists_from_cmake.py.
+ "../include/mach-o/compact_unwind_encoding.h",
+ ]
+}
+
+unwind_sources = [
+ "libunwind.cpp",
+ "Unwind-EHABI.cpp",
+ "Unwind-seh.cpp",
+ "UnwindLevel1.c",
+ "UnwindLevel1-gcc-ext.c",
+ "Unwind-sjlj.c",
+ "UnwindRegistersRestore.S",
+ "UnwindRegistersSave.S",
+ "AddressSpace.hpp",
+ "assembly.h",
+ "CompactUnwinder.hpp",
+ "config.h",
+ "dwarf2.h",
+ "DwarfInstructions.hpp",
+ "DwarfParser.hpp",
+ "libunwind_ext.h",
+ "Registers.hpp",
+ "RWMutex.hpp",
+ "UnwindCursor.hpp",
+]
+if (target_os == "mac") {
+ unwind_sources += [ "src/Unwind_AppleExtras.cpp" ]
+}
+
+config("unwind_config") {
+ cflags = []
+ cflags_c = [ "-std=c99" ]
+ cflags_cc = [ "-fno-rtti" ]
+ include_dirs = [ "//libunwind/include" ]
+ if (target_os == "mac") {
+ cflags += [ "-U__STRICT_ANSI__" ]
+ }
+}
+
+if (libunwind_enable_shared) {
+ shared_library("unwind_shared") {
+ output_dir = runtimes_dir
+ output_name = "unwind"
+ if (target_os == "linux" || target_os == "mac") {
+ cflags = [ "-fPIC" ]
+ ldflags = [ "-nostdlib++" ]
+ libs = [
+ "dl",
+ "pthread",
+ ]
+ }
+ if (target_os == "mac") {
+ ldflags += [
+ "-compatibility_version 1",
+ "-install_name /usr/lib/libunwind.1.dylib",
+ ]
+ }
+ sources = unwind_sources
+ public = unwind_headers
+ deps = [
+ "//compiler-rt/lib/builtins",
+ ]
+ configs += [ ":unwind_config" ]
+ configs -= [
+ "//llvm/utils/gn/build:no_exceptions",
+ "//llvm/utils/gn/build:no_rtti",
+ ]
+ }
+}
+
+if (libunwind_enable_static) {
+ static_library("unwind_static") {
+ output_dir = runtimes_dir
+ output_name = "unwind"
+ complete_static_lib = true
+ configs -= [ "//llvm/utils/gn/build:thin_archive" ]
+ sources = unwind_sources
+ public = unwind_headers
+ if (libunwind_hermetic_static_library) {
+ cflags = [ "-fvisibility=hidden" ]
+ cflags_cc = [ "-fvisibility-global-new-delete-hidden" ]
+ defines = [ "_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS" ]
+ }
+ deps = [
+ "//compiler-rt/lib/builtins",
+ ]
+ configs += [ ":unwind_config" ]
+ configs -= [
+ "//llvm/utils/gn/build:no_exceptions",
+ "//llvm/utils/gn/build:no_rtti",
+ ]
+ }
+}
+
+group("src") {
+ deps = []
+ if (libunwind_enable_shared) {
+ deps += [ ":unwind_shared" ]
+ }
+ if (libunwind_enable_static) {
+ deps += [ ":unwind_static" ]
+ }
+}
OpenPOWER on IntegriCloud