[Lldb-commits] [lldb] [lldb] Support building the Host library under Emscripten (PR #223169)
Anutosh Bhat via lldb-commits
lldb-commits at lists.llvm.org
Sat Sep 12 19:43:26 PDT 2026
https://github.com/anutosh491 updated https://github.com/llvm/llvm-project/pull/223169
>From 8e11de79b6f77ce851091621d60d5b6cf7362680 Mon Sep 17 00:00:00 2001
From: anutosh491 <andersonbhat491 at gmail.com>
Date: Sat, 12 Sep 2026 22:38:50 +0530
Subject: [PATCH 1/2] [lldb] Initialize the host platform under Emscripten
---
lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
index 799fe5eec29bcf..81ac8f0615e0e6 100644
--- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
+++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
@@ -102,7 +102,7 @@ void PlatformLinux::Initialize() {
PlatformPOSIX::Initialize();
if (g_initialize_count++ == 0) {
-#if defined(__linux__) && !defined(__ANDROID__)
+#if (defined(__linux__) || defined(__EMSCRIPTEN__)) && !defined(__ANDROID__)
PlatformSP default_platform_sp(new PlatformLinux(true));
default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture());
Platform::SetHostPlatform(default_platform_sp);
>From 849d3df8eb9dd126c5748886fd856c254a6b34f6 Mon Sep 17 00:00:00 2001
From: anutosh491 <andersonbhat491 at gmail.com>
Date: Sun, 13 Sep 2026 01:22:09 +0530
Subject: [PATCH 2/2] [lldb] Add HostInfoEmscripten
---
lldb/include/lldb/Host/HostInfo.h | 5 +++-
.../lldb/Host/emscripten/HostInfoEmscripten.h | 29 +++++++++++++++++++
lldb/source/Host/CMakeLists.txt | 6 ++--
.../Host/emscripten/HostInfoEmscripten.cpp | 17 +++++++++++
4 files changed, 54 insertions(+), 3 deletions(-)
create mode 100644 lldb/include/lldb/Host/emscripten/HostInfoEmscripten.h
create mode 100644 lldb/source/Host/emscripten/HostInfoEmscripten.cpp
diff --git a/lldb/include/lldb/Host/HostInfo.h b/lldb/include/lldb/Host/HostInfo.h
index 0f7ec0e0aa0d24..46973edaf8c75e 100644
--- a/lldb/include/lldb/Host/HostInfo.h
+++ b/lldb/include/lldb/Host/HostInfo.h
@@ -35,7 +35,10 @@
#if defined(_WIN32)
#include "lldb/Host/windows/HostInfoWindows.h"
#define HOST_INFO_TYPE HostInfoWindows
-#elif defined(__linux__) || defined(__EMSCRIPTEN__)
+#elif defined(__EMSCRIPTEN__)
+#include "lldb/Host/emscripten/HostInfoEmscripten.h"
+#define HOST_INFO_TYPE HostInfoEmscripten
+#elif defined(__linux__)
#if defined(__ANDROID__)
#include "lldb/Host/android/HostInfoAndroid.h"
#define HOST_INFO_TYPE HostInfoAndroid
diff --git a/lldb/include/lldb/Host/emscripten/HostInfoEmscripten.h b/lldb/include/lldb/Host/emscripten/HostInfoEmscripten.h
new file mode 100644
index 00000000000000..8c1cdcf58765bb
--- /dev/null
+++ b/lldb/include/lldb/Host/emscripten/HostInfoEmscripten.h
@@ -0,0 +1,29 @@
+//===-- HostInfoEmscripten.h -----------------------------------*- C++ -*-===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_HOST_EMSCRIPTEN_HOSTINFOEMSCRIPTEN_H
+#define LLDB_HOST_EMSCRIPTEN_HOSTINFOEMSCRIPTEN_H
+
+#include "lldb/Host/posix/HostInfoPosix.h"
+#include "lldb/Utility/FileSpec.h"
+
+namespace lldb_private {
+
+class HostInfoEmscripten : public HostInfoPosix {
+ friend class HostInfoBase;
+
+public:
+ static void Initialize();
+ static void Terminate();
+
+ static FileSpec GetProgramFileSpec();
+};
+
+} // namespace lldb_private
+
+#endif // LLDB_HOST_EMSCRIPTEN_HOSTINFOEMSCRIPTEN_H
diff --git a/lldb/source/Host/CMakeLists.txt b/lldb/source/Host/CMakeLists.txt
index ebcad8f63e4f3d..ef99c79deab820 100644
--- a/lldb/source/Host/CMakeLists.txt
+++ b/lldb/source/Host/CMakeLists.txt
@@ -135,8 +135,10 @@ else()
set_property(SOURCE macosx/Host.mm APPEND PROPERTY
COMPILE_DEFINITIONS "NO_XPC_SERVICES=1")
endif()
-
-
+ elseif (CMAKE_SYSTEM_NAME MATCHES "Emscripten")
+ add_host_subdirectory(emscripten
+ emscripten/HostInfoEmscripten.cpp
+ )
elseif (CMAKE_SYSTEM_NAME MATCHES "Linux|Android")
add_host_subdirectory(linux
linux/AbstractSocket.cpp
diff --git a/lldb/source/Host/emscripten/HostInfoEmscripten.cpp b/lldb/source/Host/emscripten/HostInfoEmscripten.cpp
new file mode 100644
index 00000000000000..10f0e2fc1dc4ab
--- /dev/null
+++ b/lldb/source/Host/emscripten/HostInfoEmscripten.cpp
@@ -0,0 +1,17 @@
+//===-- HostInfoEmscripten.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/emscripten/HostInfoEmscripten.h"
+
+using namespace lldb_private;
+
+void HostInfoEmscripten::Initialize() { HostInfoPosix::Initialize(); }
+
+void HostInfoEmscripten::Terminate() { HostInfoBase::Terminate(); }
+
+FileSpec HostInfoEmscripten::GetProgramFileSpec() { return {}; }
More information about the lldb-commits
mailing list