[Lldb-commits] [lldb] [lldb][test] When an external stdlib is specified do not link to the system stdlib (PR #164462)

Ebuka Ezike via lldb-commits lldb-commits at lists.llvm.org
Tue Oct 28 05:17:27 PDT 2025


https://github.com/da-viper updated https://github.com/llvm/llvm-project/pull/164462

>From 2da770c87999871d160d6c86d4e2b3de9b79c536 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <yerimyah1 at gmail.com>
Date: Tue, 21 Oct 2025 18:23:43 +0100
Subject: [PATCH 1/2] [lldb][test] Do not link to the system stdlib

On linux if you specify the an external libc++ and clang will still link to the system's libc++.
This patch fixes that.
---
 lldb/packages/Python/lldbsuite/test/make/Makefile.rules | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index e72ffd1f030ec..1676fb3d4520c 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -386,6 +386,11 @@ ifeq (,$(filter 1, $(USE_LIBSTDCPP) $(USE_LIBCPP) $(USE_SYSTEM_STDLIB)))
     ifneq "$(LIBCPP_INCLUDE_TARGET_DIR)" ""
       CXXFLAGS += -cxx-isystem $(LIBCPP_INCLUDE_TARGET_DIR)
     endif
+
+	# If `-nostdlib++` is not passed, clang will link to the system's stdlib.
+	ifeq ($(LDC), clang)
+		LDFLAGS += -nostdlib++ -nostdinc++
+	endif
     LDFLAGS += -L$(LIBCPP_LIBRARY_DIR) -Wl,-rpath,$(LIBCPP_LIBRARY_DIR) -lc++
   else
     USE_SYSTEM_STDLIB := 1

>From 30065d24d7f01cc1c0acb9db01efd5fb6625a8e6 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <yerimyah1 at gmail.com>
Date: Tue, 28 Oct 2025 12:17:11 +0000
Subject: [PATCH 2/2] Add review changes

---
 lldb/packages/Python/lldbsuite/test/make/Makefile.rules | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index 1676fb3d4520c..09939e29e5b75 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -388,10 +388,7 @@ ifeq (,$(filter 1, $(USE_LIBSTDCPP) $(USE_LIBCPP) $(USE_SYSTEM_STDLIB)))
     endif
 
 	# If `-nostdlib++` is not passed, clang will link to the system's stdlib.
-	ifeq ($(LDC), clang)
-		LDFLAGS += -nostdlib++ -nostdinc++
-	endif
-    LDFLAGS += -L$(LIBCPP_LIBRARY_DIR) -Wl,-rpath,$(LIBCPP_LIBRARY_DIR) -lc++
+    LDFLAGS += -nostdlib++ -L$(LIBCPP_LIBRARY_DIR) -Wl,-rpath,$(LIBCPP_LIBRARY_DIR) -lc++
   else
     USE_SYSTEM_STDLIB := 1
   endif
@@ -412,7 +409,8 @@ ifeq (1,$(USE_LIBCPP))
 		ifneq "$(LIBCPP_INCLUDE_TARGET_DIR)" ""
 				CXXFLAGS += -cxx-isystem $(LIBCPP_INCLUDE_TARGET_DIR)
 		endif
-		LDFLAGS += -L$(LIBCPP_LIBRARY_DIR) -Wl,-rpath,$(LIBCPP_LIBRARY_DIR) -lc++
+		# If `-nostdlib++` is not passed, clang will link to the system's stdlib.
+		LDFLAGS += -nostdlib++ -L$(LIBCPP_LIBRARY_DIR) -Wl,-rpath,$(LIBCPP_LIBRARY_DIR) -lc++
 	else
 		ifeq "$(OS)" "Android"
 				# Nothing to do, this is already handled in



More information about the lldb-commits mailing list