diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules index f7f6e48f71e5..6c197a2317bf 100644 --- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules +++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules @@ -441,18 +441,25 @@ ifeq (1, $(USE_SYSTEM_STDLIB)) endif ifeq (,$(filter 1, $(USE_LIBSTDCPP) $(USE_LIBCPP) $(USE_SYSTEM_STDLIB))) - # If no explicit C++ library request was made, but we have paths to a custom libcxx, use - # them. Otherwise, use the system library by default. - ifneq ($(and $(LIBCPP_INCLUDE_DIR), $(LIBCPP_LIBRARY_DIR)),) - CXXFLAGS += -nostdlib++ -nostdinc++ -cxx-isystem $(LIBCPP_INCLUDE_DIR) - 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. - LDFLAGS += -nostdlib++ -L$(LIBCPP_LIBRARY_DIR) -Wl,-rpath,$(LIBCPP_LIBRARY_DIR) -lc++ - else + ifeq "$(OS)" "Darwin" + # If no explicit C++ library request was made, default to the system + # libc++. Testing a custom libc++ correctly on apple platforms is difficult + # and the apppropriate use cases are limited. USE_SYSTEM_STDLIB := 1 + else + # If no explicit C++ library request was made, but we have paths to a custom libcxx, use + # them. Otherwise, use the system library by default. + ifneq ($(and $(LIBCPP_INCLUDE_DIR), $(LIBCPP_LIBRARY_DIR)),) + CXXFLAGS += -nostdlib++ -nostdinc++ -cxx-isystem $(LIBCPP_INCLUDE_DIR) + 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. + LDFLAGS += -nostdlib++ -L$(LIBCPP_LIBRARY_DIR) -Wl,-rpath,$(LIBCPP_LIBRARY_DIR) -lc++ + else + USE_SYSTEM_STDLIB := 1 + endif endif endif