Add libbacktrace submodule.

Change-Id: I40db6373718504cd2df3e328cefecb394e47e5c1
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/27783
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
diff --git a/.gitmodules b/.gitmodules
index 5a4e85a..4fe1ebb 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,7 @@
 [submodule "third_party/googletest"]
 	path = third_party/googletest
 	url = https://github.com/google/googletest.git
+
+[submodule "third_party/libbacktrace/src"]
+	path = third_party/libbacktrace/src
+	url = https://github.com/ianlancetaylor/libbacktrace.git
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6829719..a07454a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -123,6 +123,17 @@
     endif()
 endif()
 
+if (NOT TARGET libbacktrace)
+    if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/libbacktrace/src/.git)
+        message(WARNING "
+      third_party/libbacktrace/src submodule missing.
+      Running 'git submodule update --init' to download it:
+        ")
+
+        execute_process(COMMAND git submodule update --init)
+    endif()
+endif()
+
 ###########################################################
 # Convenience macros
 ###########################################################
diff --git a/third_party/libbacktrace/src b/third_party/libbacktrace/src
new file mode 160000
index 0000000..5a99ff7
--- /dev/null
+++ b/third_party/libbacktrace/src
@@ -0,0 +1 @@
+Subproject commit 5a99ff7fed66b8ea8f09c9805c138524a7035ece