[Lldb-commits] [lldb] [lldb][test] Do not link to the system stdlib (PR #164462)

Ebuka Ezike via lldb-commits lldb-commits at lists.llvm.org
Tue Oct 21 10:26:15 PDT 2025


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

On linux if you specify the an external libc++ and clang will still link to the system's libc++. This patch fixes that.

>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] [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



More information about the lldb-commits mailing list