diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules --- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules +++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules @@ -378,6 +378,16 @@ #---------------------------------------------------------------------- # C++ standard library options #---------------------------------------------------------------------- +ifneq ($(and $(USE_LIBSTDCPP), $(USE_LIBCPP)),) + $(error Libcxx 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 a 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 #---------------------------------------------------------------------- diff --git a/lldb/test/API/lang/objc/exceptions/Makefile b/lldb/test/API/lang/objc/exceptions/Makefile --- a/lldb/test/API/lang/objc/exceptions/Makefile +++ b/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 diff --git a/lldb/test/API/macosx/macCatalyst/Makefile b/lldb/test/API/macosx/macCatalyst/Makefile --- a/lldb/test/API/macosx/macCatalyst/Makefile +++ b/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 diff --git a/lldb/test/API/tools/lldb-server/Makefile b/lldb/test/API/tools/lldb-server/Makefile --- a/lldb/test/API/tools/lldb-server/Makefile +++ b/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