Skip to content

Commit ff1d02d

Browse files
committed
Build LLDB as part of wasi-sdk
This is intended to provide a known-good build of LLDB with wasm plugin support which can exist alongside the rest of the LLVM distribution provided by wasi-sdk. To make LLDB reasonably usable it additionally needs libedit for the CLI, so that's setup/installed here too.
1 parent a64d51d commit ff1d02d

File tree

2 files changed

+64
-1
lines changed

2 files changed

+64
-1
lines changed

ci/docker/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ RUN dnf install -y \
1212
python3 \
1313
git \
1414
unzip \
15-
cmake
15+
cmake \
16+
ncurses-devel
1617

1718
COPY ./install-ccache.sh .
1819
RUN ./install-ccache.sh

cmake/wasi-sdk-toolchain.cmake

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ set(LLVM_CMAKE_FLAGS "" CACHE STRING "Extra cmake flags to pass to LLVM's build"
55
set(RUST_TARGET "" CACHE STRING "Target to build Rust code for, if not the host")
66
set(WASI_SDK_ARTIFACT "" CACHE STRING "Name of the wasi-sdk artifact being produced")
77

8+
set(LLDB_DEFAULT ON)
9+
# Currently LLDB effectively requires libedit to be usable, and building libedit
10+
# on Windows isn't easy due to usage of `./configure`. Disable LLDB entirely on
11+
# Windows for now.
12+
if(WIN32)
13+
set(LLDB_DEFAULT OFF)
14+
endif()
15+
option(LLDB "Include a build of LLDB" ${LLDB_DEFAULT})
16+
817
string(REGEX REPLACE "[ ]+" ";" llvm_cmake_flags_list "${LLVM_CMAKE_FLAGS}")
918

1019
set(wasi_tmp_install ${CMAKE_CURRENT_BINARY_DIR}/install)
@@ -72,6 +81,58 @@ if(NOT WIN32)
7281
list(APPEND tools LLVM clang-cpp)
7382
endif()
7483

84+
# Configure/add LLDB if requested.
85+
#
86+
# Note that LLDB depends on `libedit` which is more-or-less required to get a
87+
# reasonable command-line experience, so this is built custom here to ensure
88+
# that it's available for LLDB.
89+
if(LLDB)
90+
include(ProcessorCount)
91+
ProcessorCount(nproc)
92+
find_program(MAKE_EXECUTABLE make REQUIRED)
93+
94+
ExternalProject_Add(libedit
95+
URL https://thrysoee.dk/editline/libedit-20251016-3.1.tar.gz
96+
URL_HASH SHA256=21362b00653bbfc1c71f71a7578da66b5b5203559d43134d2dd7719e313ce041
97+
98+
# Without this the build system tries to find and use `aclocal-1.18` where
99+
# with this it doesn't so turn this on.
100+
DOWNLOAD_EXTRACT_TIMESTAMP ON
101+
102+
CONFIGURE_COMMAND
103+
<SOURCE_DIR>/configure
104+
--prefix=${CMAKE_INSTALL_PREFIX}
105+
--enable-pic
106+
--disable-examples
107+
CC=${CMAKE_C_COMPILER}
108+
BUILD_COMMAND
109+
${MAKE_EXECUTABLE} -j${nproc}
110+
111+
USES_TERMINAL_CONFIGURE ON
112+
USES_TERMINAL_BUILD ON
113+
USES_TERMINAL_INSTALL ON
114+
)
115+
116+
list(APPEND projects lldb)
117+
list(APPEND tools lldb liblldb)
118+
list(APPEND default_cmake_args
119+
-DLLDB_INCLUDE_TESTS=OFF
120+
-DLLDB_INCLUDE_UNITTESTS=OFF
121+
-DLLDB_ENABLE_SWIG=OFF
122+
-DLLDB_ENABLE_CURSES=OFF
123+
-DLLDB_ENABLE_LZMA=OFF
124+
-DLLDB_ENABLE_LUA=OFF
125+
-DLLDB_ENABLE_PYTHON=OFF
126+
-DLLDB_ENABLE_LIBXML2=OFF
127+
-DLLDB_ENABLE_FBSDVMCORE=OFF
128+
-DLLDB_ENABLE_LINUXPTY=OFF
129+
-DLLDB_ENABLE_LIBEDIT=ON
130+
-DLibEdit_ROOT=${CMAKE_INSTALL_PREFIX}
131+
)
132+
else()
133+
add_custom_target(libedit)
134+
endif()
135+
75136
list(TRANSFORM tools PREPEND --target= OUTPUT_VARIABLE build_targets)
76137
list(TRANSFORM tools PREPEND --target=install- OUTPUT_VARIABLE install_targets)
77138

@@ -109,6 +170,7 @@ ExternalProject_Add(llvm-build
109170
)
110171

111172
add_custom_target(build ALL DEPENDS llvm-build)
173+
ExternalProject_Add_StepDependencies(llvm-build configure libedit)
112174

113175
# Installation target for this outer project for installing the toolchain to the
114176
# system.

0 commit comments

Comments
 (0)