[libcxx] r291072 - Get test-suite configuring on Windows with clang-cl

Shoaib Meenai via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 12 00:17:38 PST 2017


What was the rationale for forcing the use of lld? Were errors encountered
with link? It's slightly annoying to have the extra dependency; I don't have
lld built on my Windows box, for example, and while I could do so, I've also
found link to work fine in my testing.

On 1/4/17, 7:57 PM, "cfe-commits on behalf of Eric Fiselier via cfe-commits" <cfe-commits-bounces at lists.llvm.org on behalf of cfe-commits at lists.llvm.org> wrote:

    Author: ericwf
    Date: Wed Jan  4 21:57:40 2017
    New Revision: 291072
    
    URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D291072-26view-3Drev&d=DgIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=jS0vP-p0BnF2TFo1eVjVMYDQAs59MFAk7Df_s6nplms&s=cUS_8mdoEB_rXOeiVb12wPPxI4SMXpq9A_cY9hOGe2g&e= 
    Log:
    Get test-suite configuring on Windows with clang-cl
    
    This patch gets the test suite "working" on Windows, although
    none of the tests pass.
    
    In order to reuse the existing configuration, which uses UNIX
    style flags not accepted by clang-cl, this patch only works with clang++.
    When clang-cl is specified the test harness secretly looks for
    clang++ and then it configures it using the INCLUDE and LIB enviroment
    variables.
    
    This is very much a work in progress.
    
    Modified:
        libcxx/trunk/test/libcxx/test/config.py
    
    Modified: libcxx/trunk/test/libcxx/test/config.py
    URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_libcxx_trunk_test_libcxx_test_config.py-3Frev-3D291072-26r1-3D291071-26r2-3D291072-26view-3Ddiff&d=DgIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=jS0vP-p0BnF2TFo1eVjVMYDQAs59MFAk7Df_s6nplms&s=VifHtrNoBswm5JlmYYAj81SdYnWxg3XJxLzZsaw9vrs&e= 
    ==============================================================================
    --- libcxx/trunk/test/libcxx/test/config.py (original)
    +++ libcxx/trunk/test/libcxx/test/config.py Wed Jan  4 21:57:40 2017
    @@ -57,7 +57,9 @@ class Configuration(object):
         def __init__(self, lit_config, config):
             self.lit_config = lit_config
             self.config = config
    +        self.is_windows = platform.system() == 'Windows'
             self.cxx = None
    +        self.cxx_is_clang_cl = None
             self.cxx_stdlib_under_test = None
             self.project_obj_root = None
             self.libcxx_src_root = None
    @@ -95,6 +97,13 @@ class Configuration(object):
             self.lit_config.fatal(
                 "parameter '{}' should be true or false".format(name))
     
    +    def make_static_lib_name(self, name):
    +        """Return the full filename for the specified library name"""
    +        if self.is_windows:
    +            return name + '.lib'
    +        else:
    +            return 'lib' + name + '.a'
    +
         def configure(self):
             self.configure_executor()
             self.configure_target_info()
    @@ -171,20 +180,25 @@ class Configuration(object):
         def configure_cxx(self):
             # Gather various compiler parameters.
             cxx = self.get_lit_conf('cxx_under_test')
    -
    +        self.cxx_is_clang_cl = cxx is not None and \
    +                               os.path.basename(cxx) == 'clang-cl.exe'
             # If no specific cxx_under_test was given, attempt to infer it as
             # clang++.
    -        if cxx is None:
    +        if cxx is None or self.cxx_is_clang_cl:
                 clangxx = lit.util.which('clang++',
                                          self.config.environment['PATH'])
                 if clangxx:
                     cxx = clangxx
                     self.lit_config.note(
                         "inferred cxx_under_test as: %r" % cxx)
    +            elif self.cxx_is_clang_cl:
    +                self.lit_config.fatal('Failed to find clang++ substitution for'
    +                                      ' clang-cl')
             if not cxx:
                 self.lit_config.fatal('must specify user parameter cxx_under_test '
                                       '(e.g., --param=cxx_under_test=clang++)')
    -        self.cxx = CXXCompiler(cxx)
    +        self.cxx = CXXCompiler(cxx) if not self.cxx_is_clang_cl else \
    +                   self._configure_clang_cl(cxx)
             cxx_type = self.cxx.type
             if cxx_type is not None:
                 assert self.cxx.version is not None
    @@ -194,6 +208,25 @@ class Configuration(object):
                 self.config.available_features.add('%s-%s.%s' % (
                     cxx_type, maj_v, min_v))
     
    +    def _configure_clang_cl(self, clang_path):
    +        assert self.cxx_is_clang_cl
    +        # FIXME: don't hardcode the target
    +        flags = ['-fms-compatibility-version=19.00',
    +                 '--target=i686-unknown-windows']
    +        compile_flags = []
    +        link_flags = ['-fuse-ld=lld']
    +        if 'INCLUDE' in os.environ:
    +            compile_flags += ['-isystem %s' % p.strip()
    +                              for p in os.environ['INCLUDE'].split(';')
    +                              if p.strip()]
    +        if 'LIB' in os.environ:
    +            link_flags += ['-L%s' % p.strip()
    +                           for p in os.environ['LIB'].split(';') if p.strip()]
    +        return CXXCompiler(clang_path, flags=flags,
    +                           compile_flags=compile_flags,
    +                           link_flags=link_flags)
    +
    +
         def configure_src_root(self):
             self.libcxx_src_root = self.get_lit_conf(
                 'libcxx_src_root', os.path.dirname(self.config.test_source_root))
    @@ -400,7 +433,8 @@ class Configuration(object):
     
         def configure_compile_flags_header_includes(self):
             support_path = os.path.join(self.libcxx_src_root, 'test/support')
    -        if self.cxx_stdlib_under_test != 'libstdc++':
    +        if self.cxx_stdlib_under_test != 'libstdc++' and \
    +           not self.is_windows:
                 self.cxx.compile_flags += [
                     '-include', os.path.join(support_path, 'nasty_macros.hpp')]
             self.configure_config_site_header()
    @@ -459,6 +493,8 @@ class Configuration(object):
             # Transform each macro name into the feature name used in the tests.
             # Ex. _LIBCPP_HAS_NO_THREADS -> libcpp-has-no-threads
             for m in feature_macros:
    +            if m == '_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS':
    +                continue
                 if m == '_LIBCPP_ABI_VERSION':
                     self.config.available_features.add('libcpp-abi-version-v%s'
                         % feature_macros[m])
    @@ -558,15 +594,16 @@ class Configuration(object):
             if not self.use_system_cxx_lib:
                 if self.cxx_library_root:
                     self.cxx.link_flags += ['-L' + self.cxx_library_root]
    -            if self.cxx_runtime_root:
    +            if self.cxx_runtime_root and not self.is_windows:
                     self.cxx.link_flags += ['-Wl,-rpath,' + self.cxx_runtime_root]
     
         def configure_link_flags_abi_library_path(self):
             # Configure ABI library paths.
             self.abi_library_root = self.get_lit_conf('abi_library_path')
             if self.abi_library_root:
    -            self.cxx.link_flags += ['-L' + self.abi_library_root,
    -                                    '-Wl,-rpath,' + self.abi_library_root]
    +            self.cxx.link_flags += ['-L' + self.abi_library_root]
    +            if not self.is_windows:
    +                self.cxx.link_flags += ['-Wl,-rpath,' + self.abi_library_root]
     
         def configure_link_flags_cxx_library(self):
             libcxx_experimental = self.get_lit_bool('enable_experimental', default=False)
    @@ -579,7 +616,10 @@ class Configuration(object):
             else:
                 cxx_library_root = self.get_lit_conf('cxx_library_root')
                 if cxx_library_root:
    -                abs_path = os.path.join(cxx_library_root, 'libc++.a')
    +                libname = self.make_static_lib_name('c++')
    +                abs_path = os.path.join(cxx_library_root, libname)
    +                assert os.path.exists(abs_path) and \
    +                       "static libc++ library does not exist"
                     self.cxx.link_flags += [abs_path]
                 else:
                     self.cxx.link_flags += ['-lc++']
    @@ -598,7 +638,8 @@ class Configuration(object):
                     else:
                         cxxabi_library_root = self.get_lit_conf('abi_library_path')
                         if cxxabi_library_root:
    -                        abs_path = os.path.join(cxxabi_library_root, 'libc++abi.a')
    +                        libname = self.make_static_lib_name('c++abi')
    +                        abs_path = os.path.join(cxxabi_library_root, libname)
                             self.cxx.link_flags += [abs_path]
                         else:
                             self.cxx.link_flags += ['-lc++abi']
    
    
    _______________________________________________
    cfe-commits mailing list
    cfe-commits at lists.llvm.org
    https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_cfe-2Dcommits&d=DgIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=jS0vP-p0BnF2TFo1eVjVMYDQAs59MFAk7Df_s6nplms&s=0bJPrzT8cGOR-4NThzsZY0hJjgj8ZN6uI7u17ZnekqY&e= 
    



More information about the cfe-commits mailing list