From: Louis Dionne Date: Fri, 17 Apr 2020 18:00:39 +0000 (-0400) Subject: [libc++] Translate compiler-identification Lit features to the new DSL X-Git-Tag: llvmorg-12-init~7054 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=db015fdd2061714224f0ba46a10db28e90df8f7d;p=platform%2Fupstream%2Fllvm.git [libc++] Translate compiler-identification Lit features to the new DSL --- diff --git a/libcxx/utils/libcxx/test/config.py b/libcxx/utils/libcxx/test/config.py index 5713c5e..dad4496 100644 --- a/libcxx/utils/libcxx/test/config.py +++ b/libcxx/utils/libcxx/test/config.py @@ -221,16 +221,6 @@ class Configuration(object): '(e.g., --param=cxx_under_test=clang++)') self.cxx = CXXCompiler(self, 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 - maj_v, min_v, patch_v = self.cxx.version - self.config.available_features.add(cxx_type) - self.config.available_features.add('%s-%s' % (cxx_type, maj_v)) - self.config.available_features.add('%s-%s.%s' % ( - cxx_type, maj_v, min_v)) - self.config.available_features.add('%s-%s.%s.%s' % ( - cxx_type, maj_v, min_v, patch_v)) self.cxx.compile_env = dict(os.environ) # 'CCACHE_CPP2' prevents ccache from stripping comments while # preprocessing. This is required to prevent stripping of '-verify' diff --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py index 091fffa..7bdb921 100644 --- a/libcxx/utils/libcxx/test/features.py +++ b/libcxx/utils/libcxx/test/features.py @@ -9,6 +9,10 @@ from libcxx.test.dsl import * import sys +_isClang = lambda cfg: '__clang__' in compilerMacros(cfg) and '__apple_build_version__' not in compilerMacros(cfg) +_isAppleClang = lambda cfg: '__apple_build_version__' in compilerMacros(cfg) +_isGCC = lambda cfg: '__GNUC__' in compilerMacros(cfg) and '__clang__' not in compilerMacros(cfg) + features = [ Feature(name='fcoroutines-ts', compileFlag='-fcoroutines-ts', when=lambda cfg: hasCompileFlag(cfg, '-fcoroutines-ts') and @@ -27,4 +31,19 @@ features = [ sys.platform.lower().strip() == 'darwin'), # TODO: this doesn't handle cross-compiling to Apple platforms. Feature(name='objective-c++', when=lambda cfg: hasCompileFlag(cfg, '-xobjective-c++ -fobjc-arc')), Feature(name='diagnose-if-support', when=lambda cfg: hasCompileFlag(cfg, '-Wuser-defined-warnings'), compileFlag='-Wuser-defined-warnings'), + + Feature(name='apple-clang', when=_isAppleClang), + Feature(name=lambda cfg: 'apple-clang-{__clang_major__}'.format(**compilerMacros(cfg)), when=_isAppleClang), + Feature(name=lambda cfg: 'apple-clang-{__clang_major__}.{__clang_minor__}'.format(**compilerMacros(cfg)), when=_isAppleClang), + Feature(name=lambda cfg: 'apple-clang-{__clang_major__}.{__clang_minor__}.{__clang_patchlevel__}'.format(**compilerMacros(cfg)), when=_isAppleClang), + + Feature(name='clang', when=_isClang), + Feature(name=lambda cfg: 'clang-{__clang_major__}'.format(**compilerMacros(cfg)), when=_isClang), + Feature(name=lambda cfg: 'clang-{__clang_major__}.{__clang_minor__}'.format(**compilerMacros(cfg)), when=_isClang), + Feature(name=lambda cfg: 'clang-{__clang_major__}.{__clang_minor__}.{__clang_patchlevel__}'.format(**compilerMacros(cfg)), when=_isClang), + + Feature(name='gcc', when=_isGCC), + Feature(name=lambda cfg: 'gcc-{__GNUC__}'.format(**compilerMacros(cfg)), when=_isGCC), + Feature(name=lambda cfg: 'gcc-{__GNUC__}.{__GNUC_MINOR__}'.format(**compilerMacros(cfg)), when=_isGCC), + Feature(name=lambda cfg: 'gcc-{__GNUC__}.{__GNUC_MINOR__}.{__GNUC_PATCHLEVEL__}'.format(**compilerMacros(cfg)), when=_isGCC), ]