[libcxx-commits] [PATCH] D97294: [libcxx] [test] Add a MinGW target

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Feb 23 07:24:19 PST 2021

mstorsjo created this revision.
mstorsjo added reviewers: libc++, rnk.
Herald added a subscriber: arichardson.
mstorsjo requested review of this revision.
Herald added a project: libc++.
Herald added 1 blocking reviewer(s): libc++.

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).

  rG LLVM Github Monorepo



Index: libcxx/utils/libcxx/test/target_info.py
--- libcxx/utils/libcxx/test/target_info.py
+++ libcxx/utils/libcxx/test/target_info.py
@@ -27,6 +27,9 @@
     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 @@
     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)
Index: libcxx/utils/libcxx/test/config.py
--- libcxx/utils/libcxx/test/config.py
+++ libcxx/utils/libcxx/test/config.py
@@ -109,7 +109,7 @@
     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'
@@ -382,9 +382,12 @@
         # 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']

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97294.325782.patch
Type: text/x-patch
Size: 2157 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210223/0e89bd97/attachment.bin>

More information about the libcxx-commits mailing list