https://github.com/dzhidzhoev created 
https://github.com/llvm/llvm-project/pull/99589

This commit fixes an undefined reference linking problem with cross-compilation 
and remote testing on Linux host-Linux target configuration, that occurs when 
libcxx is linked statically.

Many tests fail with errors similar to that:
```
ERROR: test_with_run_command 
(TestValueObjectRecursion.ValueObjectRecursionTestCase.test_with_run_command)
   Test that deeply nested ValueObjects still work.
----------------------------------------------------------------------
Error when building test subject.

ld.lld: error: undefined symbol: __gxx_personality_v0
>>> referenced by main.cpp
>>>               main.o:(DW.ref.__gxx_personality_v0)

ld.lld: error: undefined symbol: __cxa_allocate_exception
>>> referenced by new_helpers.cpp
>>>               new_helpers.cpp.o:(std::__throw_bad_alloc()) in archive 
>>> /home/parallels/llvm-build-release/./lib/aarch64-unknown-linux-gnu/libc++.a

ld.lld: error: undefined symbol: std::bad_alloc::bad_alloc()
>>> referenced by new_helpers.cpp
>>>               new_helpers.cpp.o:(std::__throw_bad_alloc()) in archive 
>>> /home/parallels/llvm-build-release/./lib/aarch64-unknown-linux-gnu/libc++.a

ld.lld: error: undefined symbol: typeinfo for std::bad_alloc
>>> referenced by new_helpers.cpp
>>>               new_helpers.cpp.o:(std::__throw_bad_alloc()) in archive 
>>> /home/parallels/llvm-build-release/./lib/aarch64-unknown-linux-gnu/libc++.a
>>> referenced by new_helpers.cpp
>>>               new_helpers.cpp.o:(std::__throw_bad_alloc()) in archive 
>>> /home/parallels/llvm-build-release/./lib/aarch64-unknown-linux-gnu/libc++.a

...
```

>From 029115b811c149edb316719d7735cc1b4a850c43 Mon Sep 17 00:00:00 2001
From: Vladislav Dzhidzhoev <vdzhidzh...@accesssoftek.com>
Date: Fri, 19 Jul 2024 02:14:03 +0200
Subject: [PATCH] [lldb][test] Add ABI library to Makefile.rules link flags

This commit fixes an undefined reference linking problem
with cross-compilation and remote testing on Linux host-Linux target
configuration, that occurs when libcxx is linked statically.
---
 lldb/packages/Python/lldbsuite/test/make/Makefile.rules | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules 
b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index 597aa94566c24..092632ecc3a07 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -390,7 +390,7 @@ 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++
+               LDFLAGS += -L$(LIBCPP_LIBRARY_DIR) 
-Wl,-rpath,$(LIBCPP_LIBRARY_DIR) -lc++ -lc++abi
        else
                ifeq "$(OS)" "Android"
                                # Nothing to do, this is already handled in
@@ -413,7 +413,7 @@ ifeq (1, $(USE_SYSTEM_STDLIB))
              $(error "SDKROOT must be set on Darwin to use the system libcxx")
         endif
         CXXFLAGS += -nostdlib++ -nostdinc++ -cxx-isystem 
$(SDKROOT)/usr/include/c++/v1
-        LDFLAGS += -L$(SDKROOT)/usr/lib -Wl,-rpath,$(SDKROOT)/usr/lib -lc++
+        LDFLAGS += -L$(SDKROOT)/usr/lib -Wl,-rpath,$(SDKROOT)/usr/lib -lc++ 
-lc++abi
     endif
 endif
 
@@ -425,7 +425,7 @@ ifeq ($(or $(USE_LIBSTDCPP), $(USE_LIBCPP), 
$(USE_SYSTEM_STDLIB)),)
                ifneq "$(LIBCPP_INCLUDE_TARGET_DIR)" ""
                                CXXFLAGS += -cxx-isystem 
$(LIBCPP_INCLUDE_TARGET_DIR)
                endif
-               LDFLAGS += -L$(LIBCPP_LIBRARY_DIR) 
-Wl,-rpath,$(LIBCPP_LIBRARY_DIR) -lc++
+               LDFLAGS += -L$(LIBCPP_LIBRARY_DIR) 
-Wl,-rpath,$(LIBCPP_LIBRARY_DIR) -lc++ -lc++abi
        endif
 endif
 

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to