[lldb] Change most tests to build with system libc++ on Darwin (#190034)
Today, on Darwin platforms, almost every test binary in our test suite loads two copies of libc++, libc++abi, and libunwind. This is because each of the test binaries explicitly link against a just-built libc++ (which is explicitly required on Darwin right now) but we don't take the correct steps to replace the system libc++. Doing so is unnecessary and potentially error-prone, so most tests should link against the system libc++ where possible. Background: The lldb test suite has a collection of tests that rely on libc++ explicitly. The two biggest categories are data formatter tests (which make sure that we can correctly display values for std types) and import-std-module tests (which test that we can import the libc++ std module). To make sure these tests are run, we require a just-built libc++ to be used. All of the test binaries link against the just-built libc++, so it gets loaded. However, when any system library tries to load libc++, it attempts to load the system one. dyld checks loaded libraries against the request to load a new one using the full path, meaning anyone linking against `/usr/lib/libc++.1.dylib` will get it no matter what other libc++ dylib is already loaded. The proper way to handle this is using `DYLD_LIBRARY_PATH`, which switches dyld to checking the leaf name of a dylib instead of the full path. In theory this works, but we run into an issue where the system libc++ has additional symbols and many system libraries fail to load. Louis Dionne added stubs in libc++abi for these missing symbols, meaning it would be possible to make this scenario work. This may be useful for the existing libc++ tests.
This commit is contained in:
parent
8e1ea8af38
commit
014d5d51e1
@ -441,6 +441,12 @@ ifeq (1, $(USE_SYSTEM_STDLIB))
|
||||
endif
|
||||
|
||||
ifeq (,$(filter 1, $(USE_LIBSTDCPP) $(USE_LIBCPP) $(USE_SYSTEM_STDLIB)))
|
||||
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)),)
|
||||
@ -455,6 +461,7 @@ ifeq (,$(filter 1, $(USE_LIBSTDCPP) $(USE_LIBCPP) $(USE_SYSTEM_STDLIB)))
|
||||
USE_SYSTEM_STDLIB := 1
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq (1,$(USE_LIBSTDCPP))
|
||||
# Clang requires an extra flag: -stdlib=libstdc++
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user