fdeazeve created this revision.
Herald added a project: All.
fdeazeve requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This commit improves upon cc0b5ebf7fc8 
<https://reviews.llvm.org/rGcc0b5ebf7fc8beb8fa907730e2d8f52d4c31bdc7>, which 
added support for
specifying which libcxx to use when testing LLDB. That patch honored
requests by tests that had `USE_LIBCPP=1` defined in their makefiles.
Now, we also use a non-default libcxx if all conditions below are true:

1. The test is not explicitly requesting the use of libstdcpp

(USE_LIBSTDCPP=1).

2. The test is not explicitly requesting the use of the system's

library (USE_SYSTEM_STDLIB=1).

3. A path to libcxx was either provided by the user through CMake flags

or libcxx was built together with LLDB.

Condition (2) is new and introduced in this patch in order to support
tests that are either:

- Cross-platform (such as API/macosx/macCatalyst and

API/tools/lldb-server). The just-built libcxx is usually not built for
platforms other than the host's.

- Cross-language (such as API/lang/objc/exceptions). In this case, the

Objective C runtime throws an exceptions that always goes through the
system's libcxx, instead of the just built libcxx. Fixing this would
require either changing the install-name of the just built libcxx in Mac
systems, or tuning the DYLD_LIBRARY_PATH variable at runtime.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132940

Files:
  lldb/packages/Python/lldbsuite/test/make/Makefile.rules
  lldb/test/API/lang/objc/exceptions/Makefile
  lldb/test/API/macosx/macCatalyst/Makefile
  lldb/test/API/tools/lldb-server/Makefile


Index: lldb/test/API/tools/lldb-server/Makefile
===================================================================
--- lldb/test/API/tools/lldb-server/Makefile
+++ lldb/test/API/tools/lldb-server/Makefile
@@ -2,5 +2,6 @@
 ENABLE_THREADS := YES
 CXX_SOURCES := main.cpp
 MAKE_DSYM :=NO
+USE_SYSTEM_STDLIB := 1
 
 include Makefile.rules
Index: lldb/test/API/macosx/macCatalyst/Makefile
===================================================================
--- lldb/test/API/macosx/macCatalyst/Makefile
+++ lldb/test/API/macosx/macCatalyst/Makefile
@@ -3,6 +3,8 @@
 override TRIPLE := $(ARCH)-apple-ios13.1-macabi
 CFLAGS_EXTRAS := -target $(TRIPLE)
 
+USE_SYSTEM_STDLIB := 1
+
 # FIXME: rdar://problem/54986190
 # There is a Clang driver change missing on llvm.org.
 override CC=xcrun clang
Index: lldb/test/API/lang/objc/exceptions/Makefile
===================================================================
--- lldb/test/API/lang/objc/exceptions/Makefile
+++ lldb/test/API/lang/objc/exceptions/Makefile
@@ -2,7 +2,7 @@
 
 CFLAGS_EXTRAS := -w
 
-
+USE_SYSTEM_STDLIB := 1
 
 LD_EXTRAS := -framework Foundation
 include Makefile.rules
Index: lldb/packages/Python/lldbsuite/test/make/Makefile.rules
===================================================================
--- lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -378,6 +378,16 @@
 #----------------------------------------------------------------------
 # C++ standard library options
 #----------------------------------------------------------------------
+ifneq ($(and $(USE_LIBSTDCPP), $(USE_LIBCPP)),)
+       $(error Libcpp and Libstdc++ cannot be used together)
+endif
+
+ifeq (1, $(USE_SYSTEM_STDLIB))
+       ifneq ($(or $(USE_LIBSTDCPP), $(USE_LIBCPP)),)
+               $(error Cannot use system's library and custom library together)
+       endif
+endif
+
 ifeq (1,$(USE_LIBSTDCPP))
        # Clang requires an extra flag: -stdlib=libstdc++
        ifneq (,$(findstring clang,$(CC)))
@@ -406,6 +416,15 @@
        endif
 endif
 
+# If no explicit request was made, but we have paths to a custom libcxx, use
+# them.
+ifeq ($(or $(USE_LIBSTDCPP), $(USE_LIBCPP), $(USE_SYSTEM_STDLIB)),)
+       ifneq ($(and $(LIBCPP_INCLUDE_DIR), $(LIBCPP_LIBRARY_DIR)),)
+               CXXFLAGS += -nostdlib++ -nostdinc++ -cxx-isystem 
$(LIBCPP_INCLUDE_DIR)
+               LDFLAGS += -L$(LLVM_LIBS_DIR) -Wl,-rpath,$(LIBCPP_LIBRARY_DIR) 
-lc++
+       endif
+endif
+
 #----------------------------------------------------------------------
 # Additional system libraries
 #----------------------------------------------------------------------


Index: lldb/test/API/tools/lldb-server/Makefile
===================================================================
--- lldb/test/API/tools/lldb-server/Makefile
+++ lldb/test/API/tools/lldb-server/Makefile
@@ -2,5 +2,6 @@
 ENABLE_THREADS := YES
 CXX_SOURCES := main.cpp
 MAKE_DSYM :=NO
+USE_SYSTEM_STDLIB := 1
 
 include Makefile.rules
Index: lldb/test/API/macosx/macCatalyst/Makefile
===================================================================
--- lldb/test/API/macosx/macCatalyst/Makefile
+++ lldb/test/API/macosx/macCatalyst/Makefile
@@ -3,6 +3,8 @@
 override TRIPLE := $(ARCH)-apple-ios13.1-macabi
 CFLAGS_EXTRAS := -target $(TRIPLE)
 
+USE_SYSTEM_STDLIB := 1
+
 # FIXME: rdar://problem/54986190
 # There is a Clang driver change missing on llvm.org.
 override CC=xcrun clang
Index: lldb/test/API/lang/objc/exceptions/Makefile
===================================================================
--- lldb/test/API/lang/objc/exceptions/Makefile
+++ lldb/test/API/lang/objc/exceptions/Makefile
@@ -2,7 +2,7 @@
 
 CFLAGS_EXTRAS := -w
 
-
+USE_SYSTEM_STDLIB := 1
 
 LD_EXTRAS := -framework Foundation
 include Makefile.rules
Index: lldb/packages/Python/lldbsuite/test/make/Makefile.rules
===================================================================
--- lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -378,6 +378,16 @@
 #----------------------------------------------------------------------
 # C++ standard library options
 #----------------------------------------------------------------------
+ifneq ($(and $(USE_LIBSTDCPP), $(USE_LIBCPP)),)
+	$(error Libcpp and Libstdc++ cannot be used together)
+endif
+
+ifeq (1, $(USE_SYSTEM_STDLIB))
+	ifneq ($(or $(USE_LIBSTDCPP), $(USE_LIBCPP)),)
+		$(error Cannot use system's library and custom library together)
+	endif
+endif
+
 ifeq (1,$(USE_LIBSTDCPP))
 	# Clang requires an extra flag: -stdlib=libstdc++
 	ifneq (,$(findstring clang,$(CC)))
@@ -406,6 +416,15 @@
 	endif
 endif
 
+# If no explicit request was made, but we have paths to a custom libcxx, use
+# them.
+ifeq ($(or $(USE_LIBSTDCPP), $(USE_LIBCPP), $(USE_SYSTEM_STDLIB)),)
+	ifneq ($(and $(LIBCPP_INCLUDE_DIR), $(LIBCPP_LIBRARY_DIR)),)
+		CXXFLAGS += -nostdlib++ -nostdinc++ -cxx-isystem $(LIBCPP_INCLUDE_DIR)
+		LDFLAGS += -L$(LLVM_LIBS_DIR) -Wl,-rpath,$(LIBCPP_LIBRARY_DIR) -lc++
+	endif
+endif
+
 #----------------------------------------------------------------------
 # Additional system libraries
 #----------------------------------------------------------------------
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
  • [Lldb-commits]... Felipe de Azevedo Piovezan via Phabricator via lldb-commits
    • [Lldb-com... Felipe de Azevedo Piovezan via Phabricator via lldb-commits
    • [Lldb-com... Felipe de Azevedo Piovezan via Phabricator via lldb-commits
    • [Lldb-com... Jonas Devlieghere via Phabricator via lldb-commits
    • [Lldb-com... Pavel Labath via Phabricator via lldb-commits
    • [Lldb-com... Felipe de Azevedo Piovezan via Phabricator via lldb-commits
    • [Lldb-com... Pavel Labath via Phabricator via lldb-commits
    • [Lldb-com... Felipe de Azevedo Piovezan via Phabricator via lldb-commits
    • [Lldb-com... Felipe de Azevedo Piovezan via Phabricator via lldb-commits
    • [Lldb-com... Pavel Labath via Phabricator via lldb-commits
    • [Lldb-com... Felipe de Azevedo Piovezan via Phabricator via lldb-commits

Reply via email to