[Lldb-commits] [lldb] 1c1edc2 - [lldb] Support building lldbHost under Emscripten (#223206)
via lldb-commits
lldb-commits at lists.llvm.org
Wed Sep 16 00:17:12 PDT 2026
Author: Anutosh Bhat
Date: 2026-09-16T07:17:07Z
New Revision: 1c1edc2d34e181ac8cdd5aa81e218464e1e2a642
URL: https://github.com/llvm/llvm-project/commit/1c1edc2d34e181ac8cdd5aa81e218464e1e2a642
DIFF: https://github.com/llvm/llvm-project/commit/1c1edc2d34e181ac8cdd5aa81e218464e1e2a642.diff
LOG: [lldb] Support building lldbHost under Emscripten (#223206)
This builds on the new `HostInfoEmscripten` and `PlatformEmscripten`
support.
Emscripten provides many POSIX APIs, but it does not support `fork` or
native host process management. This patch allows `lldbHost` to build
under Emscripten without treating it as Linux.
It:
- avoids building the `ProcessLauncherPosixFork` implementation;
- adds a small Emscripten Host implementation;
- reports process enumeration, process lookup, launching and shell
expansion as unsupported.
The remaining generic POSIX Host functionality continues to be used.
This is enough for the current libLLDB and SB API experiment, while live
process debugging will be handled separately once we have an in-browser
execution backend.
Added:
lldb/source/Host/emscripten/Host.cpp
Modified:
lldb/source/Host/CMakeLists.txt
lldb/source/Host/common/Host.cpp
Removed:
################################################################################
diff --git a/lldb/source/Host/CMakeLists.txt b/lldb/source/Host/CMakeLists.txt
index ef99c79deab82..45821aa410912 100644
--- a/lldb/source/Host/CMakeLists.txt
+++ b/lldb/source/Host/CMakeLists.txt
@@ -111,10 +111,15 @@ else()
posix/LockFilePosix.cpp
posix/MainLoopPosix.cpp
posix/PipePosix.cpp
- posix/ProcessLauncherPosixFork.cpp
posix/Support.cpp
)
+ if (NOT EMSCRIPTEN)
+ add_host_subdirectory(posix
+ posix/ProcessLauncherPosixFork.cpp
+ )
+ endif()
+
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_subdirectory(macosx/objcxx)
set(LLDBObjCLibs lldbHostMacOSXObjCXX)
@@ -137,6 +142,7 @@ else()
endif()
elseif (CMAKE_SYSTEM_NAME MATCHES "Emscripten")
add_host_subdirectory(emscripten
+ emscripten/Host.cpp
emscripten/HostInfoEmscripten.cpp
)
elseif (CMAKE_SYSTEM_NAME MATCHES "Linux|Android")
diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp
index c4e1500fe68ab..fdf17db53ec3e 100644
--- a/lldb/source/Host/common/Host.cpp
+++ b/lldb/source/Host/common/Host.cpp
@@ -67,7 +67,7 @@
#if defined(_WIN32)
#include "lldb/Host/windows/ConnectionGenericFileWindows.h"
#include "lldb/Host/windows/ProcessLauncherWindows.h"
-#else
+#elif !defined(__EMSCRIPTEN__)
#include "lldb/Host/posix/ProcessLauncherPosixFork.h"
#endif
@@ -581,7 +581,7 @@ Status Host::RunShellCommand(llvm::StringRef shell_path, const Args &args,
// The functions below implement process launching for non-Apple-based
// platforms
-#if !defined(__APPLE__)
+#if !defined(__APPLE__) && !defined(__EMSCRIPTEN__)
Status Host::LaunchProcess(ProcessLaunchInfo &launch_info) {
std::unique_ptr<ProcessLauncher> delegate_launcher;
#if defined(_WIN32)
@@ -600,7 +600,7 @@ Status Host::LaunchProcess(ProcessLaunchInfo &launch_info) {
return error;
}
-#endif // !defined(__APPLE__)
+#endif // !defined(__APPLE__) && !defined(__EMSCRIPTEN__)
#ifndef _WIN32
void Host::Kill(lldb::pid_t pid, int signo) { ::kill(pid, signo); }
diff --git a/lldb/source/Host/emscripten/Host.cpp b/lldb/source/Host/emscripten/Host.cpp
new file mode 100644
index 0000000000000..005a2f83f4ec7
--- /dev/null
+++ b/lldb/source/Host/emscripten/Host.cpp
@@ -0,0 +1,29 @@
+//===-- Host.cpp ---------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Host/Host.h"
+#include "lldb/Utility/Status.h"
+
+using namespace lldb_private;
+
+uint32_t Host::FindProcessesImpl(const ProcessInstanceInfoMatch &,
+ ProcessInstanceInfoList &) {
+ return 0;
+}
+
+bool Host::GetProcessInfo(lldb::pid_t, ProcessInstanceInfo &) { return false; }
+
+Status Host::LaunchProcess(ProcessLaunchInfo &) {
+ return Status::FromErrorString(
+ "launching a host process is not supported under Emscripten");
+}
+
+Status Host::ShellExpandArguments(ProcessLaunchInfo &) {
+ return Status::FromErrorString(
+ "shell expansion is not supported under Emscripten");
+}
More information about the lldb-commits
mailing list