Skip to content

Commit fb2e4f5

Browse files
committed
[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
1 parent 72fe14d commit fb2e4f5

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

libcxx/utils/libcxx/test/config.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def check_value(value, var_name):
109109

110110
def make_static_lib_name(self, name):
111111
"""Return the full filename for the specified library name"""
112-
if self.target_info.is_windows():
112+
if self.target_info.is_windows() and not self.target_info.is_mingw():
113113
assert name == 'c++' # Only allow libc++ to use this function for now.
114114
return 'lib' + name + '.lib'
115115
else:
@@ -382,9 +382,12 @@ def configure_link_flags(self):
382382

383383
# Configure libraries
384384
if self.cxx_stdlib_under_test == 'libc++':
385-
self.cxx.link_flags += ['-nodefaultlibs']
385+
if self.target_info.is_mingw():
386+
self.cxx.link_flags += ['-nostdlib++']
387+
else:
388+
self.cxx.link_flags += ['-nodefaultlibs']
386389
# FIXME: Handle MSVCRT as part of the ABI library handling.
387-
if self.target_info.is_windows():
390+
if self.target_info.is_windows() and not self.target_info.is_mingw():
388391
self.cxx.link_flags += ['-nostdlib']
389392
self.configure_link_flags_cxx_library()
390393
self.configure_link_flags_abi_library()

libcxx/utils/libcxx/test/target_info.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ def platform(self):
2727
def is_windows(self):
2828
return self.platform() == 'win32'
2929

30+
def is_mingw(self):
31+
return False
32+
3033
def is_darwin(self):
3134
return self.platform() == 'darwin'
3235

@@ -184,6 +187,13 @@ class WindowsLocalTI(DefaultTargetInfo):
184187
def __init__(self, full_config):
185188
super(WindowsLocalTI, self).__init__(full_config)
186189

190+
class MingwLocalTI(WindowsLocalTI):
191+
def __init__(self, full_config):
192+
super(MingwLocalTI, self).__init__(full_config)
193+
194+
def is_mingw(self):
195+
return True
196+
187197
def make_target_info(full_config):
188198
default = "libcxx.test.target_info.LocalTI"
189199
info_str = full_config.get_lit_conf('target_info', default)

0 commit comments

Comments
 (0)