Skip to content

Commit 4c20436

Browse files
[swift] Add Swift support to LLDB for WebAssembly
1 parent d588930 commit 4c20436

File tree

10 files changed

+50
-3
lines changed

10 files changed

+50
-3
lines changed

.gitmodules

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
gclient-condition = build_with_chromium == False
55
[submodule "extensions/cxx_debugging/third_party/llvm/src"]
66
path = extensions/cxx_debugging/third_party/llvm/src
7-
url = https://chromium.googlesource.com/external/github.com/llvm/llvm-project
7+
url = https://github.com/kateinoigakukun/llvm-project.git
88
gclient-condition = checkout_cxx_debugging_extension_deps == True
99
[submodule "extensions/cxx_debugging/third_party/lldb-eval/src"]
1010
path = extensions/cxx_debugging/third_party/lldb-eval/src
11-
url = https://chromium.googlesource.com/external/github.com/google/lldb-eval
11+
url = https://github.com/kateinoigakukun/lldb-eval.git
1212
gclient-condition = checkout_cxx_debugging_extension_deps == True
1313
[submodule "buildtools"]
1414
path = buildtools
@@ -26,3 +26,6 @@
2626
path = third_party/inspector_protocol
2727
url = https://chromium.googlesource.com/deps/inspector_protocol
2828
gclient-condition = build_with_chromium == False
29+
[submodule "extensions/cxx_debugging/third_party/swift/src"]
30+
path = extensions/cxx_debugging/third_party/swift/src
31+
url = https://github.com/kateinoigakukun/swift.git

extensions/cxx_debugging/CMakeLists.txt

+11
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,20 @@ endif()
8181
if (CXX_DEBUGGING_BUILD_WASM)
8282
set(LLVM_ENABLE_RTTI "ON" CACHE STRING "")
8383
set(LLVM_ENABLE_THREADS "OFF" CACHE STRING "")
84+
set(LLVM_ENABLE_LIBEDIT "OFF" CACHE STRING "")
85+
86+
set(LLVM_EXTERNAL_SWIFT_SOURCE_DIR "${THIRD_PARTY_DIR}/swift/src" CACHE STRING "")
87+
set(LLVM_EXTERNAL_PROJECTS "swift" CACHE STRING "")
88+
set(SWIFT_ENABLE_DISPATCH "OFF" CACHE STRING "")
89+
set(SWIFT_BUILD_SOURCEKIT "OFF" CACHE STRING "")
90+
set(SWIFT_HOST_VARIANT_SDK "EMSCRIPTEN" CACHE STRING "")
91+
set(SWIFT_HOST_VARIANT_ARCH "wasm32" CACHE STRING "")
92+
set(SWIFT_INCLUDE_TESTS "OFF" CACHE STRING "")
93+
add_compile_options(-fdeclspec)
8494
else()
8595
set(LLVM_ON_WIN32 0)
8696
set(LLVM_ON_UNIX 1)
97+
set(LLDB_ENABLE_SWIFT_SUPPORT "OFF" CACHE STRING "")
8798
endif()
8899

89100

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
set(cmark-gfm_FOUND TRUE)
2+
set(cmark-gfm_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/include")
3+
set(cmark-gfm_LIBRARIES)
4+
5+
add_library(libcmark-gfm INTERFACE)

extensions/cxx_debugging/src/SymbolsBackend.cc

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include "WasmVendorPlugins.h"
1313

1414
#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
15+
#include "Plugins/Language/Swift/SwiftLanguage.h"
16+
#include "Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.h"
1517
#include "Plugins/ObjectFile/wasm/ObjectFileWasm.h"
1618
#include "Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h"
1719
#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
@@ -33,6 +35,8 @@ struct DefaultPluginsContext
3335
lldb_private::FileSystem,
3436
lldb_private::CPlusPlusLanguage,
3537
lldb_private::TypeSystemClang,
38+
lldb_private::SwiftLanguage,
39+
lldb_private::TypeSystemSwiftTypeRef,
3640
lldb_private::wasm::ObjectFileWasm,
3741
lldb_private::wasm::SymbolVendorWasm,
3842
symbols_backend::WasmProcess,

extensions/cxx_debugging/src/SymbolsBackend.cc.in

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include "WasmVendorPlugins.h"
1313

1414
#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
15+
#include "Plugins/Language/Swift/SwiftLanguage.h"
16+
#include "Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.h"
1517
#include "Plugins/ObjectFile/wasm/ObjectFileWasm.h"
1618
#include "Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h"
1719
#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
@@ -33,6 +35,8 @@ struct DefaultPluginsContext
3335
lldb_private::FileSystem,
3436
lldb_private::CPlusPlusLanguage,
3537
lldb_private::TypeSystemClang,
38+
lldb_private::SwiftLanguage,
39+
lldb_private::TypeSystemSwiftTypeRef,
3640
lldb_private::wasm::ObjectFileWasm,
3741
lldb_private::wasm::SymbolVendorWasm,
3842
symbols_backend::WasmProcess,
Submodule src updated 581 files
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
file://config/owner/INFRA_OWNERS
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Name: The Swift Programming Language
2+
Short Name: swift
3+
URL: https://github.com/swiftlang/swift
4+
Version: N/A
5+
Date: TODO
6+
Revision: TODO
7+
License: Apache 2.0 with LLVM Exceptions
8+
License File: src/LICENSE.TXT
9+
Shipped: no
10+
Security Critical: no
11+
Description: The Swift project produces a compiler, standard library, and other tools for developing software in the Swift programming language. In order to achieve ABI stability and debuggability, programs produced by the Swift compiler contain type layout information in its own metadata sections instead of the standard DWARF format. This metadata is used by both the Swift runtime and LLDB to inspect objects at runtime.
12+
13+
In the DevTools debugging extension, a part of the Swift project is used to read such metadata through LLDB's Swift language plugin.
Submodule src added at 22c48b6

extensions/cxx_debugging/tools/bootstrap.py

+5
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,17 @@ def stage2(source_dir, stage1_dir, OPTIONS):
123123
}
124124
cmake_args = [
125125
OPTIONS.cmake, OPTIONS.extension_source, *CMAKE_DEFAULTS,
126+
# ABI check must be turned off when building with -DNDEBUG
127+
'-DLLVM_ABI_BREAKING_CHECKS=FORCE_OFF',
126128
'-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=-O1 -g -DNDEBUG',
127129
'-DCMAKE_C_FLAGS_RELWITHDEBINFO=-O1 -g -DNDEBUG',
128130
'-DCMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO=-O1 -g -DNDEBUG -gseparate-dwarf',
129131
'-DCMAKE_CXX_FLAGS_DEBUG=-O0 -g -DNDEBUG',
130132
'-DCMAKE_EXE_LINKER_FLAGS_DEBUG=-O0 -g -gseparate-dwarf',
133+
'-DCMAKE_EXE_LINKER_FLAGS=-sERROR_ON_UNDEFINED_SYMBOLS=0',
131134
'-DHAVE_POSIX_REGEX=0', '-Derrc_exit_code=0',
135+
'-DHAVE_SIGALTSTACK=0',
136+
'-Dcmark-gfm_DIR={}'.format(os.path.join(source_dir, 'ports')),
132137
'-Derrc_exit_code__TRYRUN_OUTPUT=0',
133138
'-DCMAKE_BUILD_TYPE={build_type}'.format(**cmake_settings),
134139
'-DCMAKE_TOOLCHAIN_FILE={toolchain_file}'.format(**cmake_settings),

0 commit comments

Comments
 (0)