Skip to content

Conversation

@da-viper
Copy link
Contributor

@da-viper da-viper commented Oct 21, 2025

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

Fixes #116040

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

llvmbot commented Oct 21, 2025

@llvm/pr-subscribers-lldb

Author: Ebuka Ezike (da-viper)

Changes

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


Full diff: https://github.com/llvm/llvm-project/pull/164462.diff

1 Files Affected:

  • (modified) lldb/packages/Python/lldbsuite/test/make/Makefile.rules (+5)
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

@da-viper da-viper changed the title [lldb][test] Do not link to the system stdlib [lldb][test] When an external stdlib is specified do not link to the system stdlib Oct 21, 2025
endif

# If `-nostdlib++` is not passed, clang will link to the system's stdlib.
ifeq ($(LDC), clang)
Copy link
Member

@Michael137 Michael137 Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this. Clang, GCC and clang-cl are all aware of this option

Suggested change
ifeq ($(LDC), clang)

Copy link
Member

@Michael137 Michael137 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. This should fix the immediate issue of accidentally linking against libstdc++ in the DAP tests. We should also add the flag to the USE_LIBCPP codepath as @dzhidzhoev pointed out, but I don't mind doing that in a separate PR. I was going to do a minor cleanup of this logic in a follow-up PR, and might include that in those changes.

Could add Fixes https://github.com/llvm/llvm-project/issues/116040 to the PR description before merging?

@Michael137
Copy link
Member

Michael137 commented Oct 28, 2025

Ignore the AArch64 CI failure. It has been unintentionally running on PRs as of late.

@da-viper da-viper requested a review from dzhidzhoev October 28, 2025 12:18
@da-viper da-viper merged commit ec55aa4 into llvm:main Oct 28, 2025
10 checks passed
Lukacma pushed a commit to Lukacma/llvm-project that referenced this pull request Oct 29, 2025
…system stdlib (llvm#164462)

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

Fixes llvm#116040
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[lldb-dap] TestDAP_exception_cpp test flakey

4 participants