[libcxx] [test] Add a MinGW target

This can't easily be autodetected (unless LIBCXX_TARGET_TRIPLE is
specified, or unless we query what the compiler's default target is,
which only is supported by clang), but can be chosen manually via
LIBCXX_TARGET_INFO.

This chooses mingw style lib naming, and uses -nostdlibc++ instead
of -nodefaultlib -nostdlib (as the latter requires specifying a lot of
details manually - this is done in the cmake config though).

Differential Revision: https://reviews.llvm.org/D97294
This commit is contained in:
Martin Storsjö 2020-10-22 21:33:10 +03:00
parent 72fe14d40a
commit fb2e4f5401
2 changed files with 16 additions and 3 deletions

View File

@ -109,7 +109,7 @@ class Configuration(object):
def make_static_lib_name(self, name):
"""Return the full filename for the specified library name"""
if self.target_info.is_windows():
if self.target_info.is_windows() and not self.target_info.is_mingw():
assert name == 'c++' # Only allow libc++ to use this function for now.
return 'lib' + name + '.lib'
else:
@ -382,9 +382,12 @@ class Configuration(object):
# Configure libraries
if self.cxx_stdlib_under_test == 'libc++':
self.cxx.link_flags += ['-nodefaultlibs']
if self.target_info.is_mingw():
self.cxx.link_flags += ['-nostdlib++']
else:
self.cxx.link_flags += ['-nodefaultlibs']
# FIXME: Handle MSVCRT as part of the ABI library handling.
if self.target_info.is_windows():
if self.target_info.is_windows() and not self.target_info.is_mingw():
self.cxx.link_flags += ['-nostdlib']
self.configure_link_flags_cxx_library()
self.configure_link_flags_abi_library()

View File

@ -27,6 +27,9 @@ class DefaultTargetInfo(object):
def is_windows(self):
return self.platform() == 'win32'
def is_mingw(self):
return False
def is_darwin(self):
return self.platform() == 'darwin'
@ -184,6 +187,13 @@ class WindowsLocalTI(DefaultTargetInfo):
def __init__(self, full_config):
super(WindowsLocalTI, self).__init__(full_config)
class MingwLocalTI(WindowsLocalTI):
def __init__(self, full_config):
super(MingwLocalTI, self).__init__(full_config)
def is_mingw(self):
return True
def make_target_info(full_config):
default = "libcxx.test.target_info.LocalTI"
info_str = full_config.get_lit_conf('target_info', default)