diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index d9d81d68b..464756250 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -231,10 +231,11 @@ class PGICCompiler(PGICompiler, CCompiler): class ElbrusCCompiler(GnuCCompiler, ElbrusCompiler): def __init__(self, exelist, version, for_machine: MachineChoice, - is_cross, info: 'MachineInfo', exe_wrapper=None, defines=None, **kwargs): + is_cross, info: 'MachineInfo', exe_wrapper=None, + defines=None, **kwargs): GnuCCompiler.__init__(self, exelist, version, for_machine, is_cross, info, exe_wrapper, defines, **kwargs) - ElbrusCompiler.__init__(self, defines) + ElbrusCompiler.__init__(self) # It does support some various ISO standards and c/gnu 90, 9x, 1x in addition to those which GNU CC supports. def get_options(self): diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index a09c6112e..443a9ee18 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -325,7 +325,7 @@ class ElbrusCPPCompiler(GnuCPPCompiler, ElbrusCompiler): GnuCPPCompiler.__init__(self, exelist, version, for_machine, is_cross, info, exe_wrapper, defines, **kwargs) - ElbrusCompiler.__init__(self, defines) + ElbrusCompiler.__init__(self) # It does not support c++/gnu++ 17 and 1z, but still does support 0x, 1y, and gnu++98. def get_options(self): @@ -351,6 +351,19 @@ class ElbrusCPPCompiler(GnuCPPCompiler, ElbrusCompiler): extra_args=extra_args, dependencies=dependencies) + # Elbrus C++ compiler does not support RTTI, so don't check for it. + def get_option_compile_args(self, options): + args = [] + std = options['cpp_std'] + if std.value != 'none': + args.append(self._find_best_cpp_std(std.value)) + + non_msvc_eh_options(options['cpp_eh'].value, args) + + if options['cpp_debugstl'].value: + args.append('-D_GLIBCXX_DEBUG=1') + return args + class IntelCPPCompiler(IntelGnuLikeCompiler, CPPCompiler): def __init__(self, exelist, version, for_machine: MachineChoice, diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py index 73a8e241a..a83c17f4e 100644 --- a/mesonbuild/compilers/fortran.py +++ b/mesonbuild/compilers/fortran.py @@ -215,7 +215,7 @@ class ElbrusFortranCompiler(GnuFortranCompiler, ElbrusCompiler): GnuFortranCompiler.__init__(self, exelist, version, for_machine, is_cross, info, exe_wrapper, defines, **kwargs) - ElbrusCompiler.__init__(self, defines) + ElbrusCompiler.__init__(self) class G95FortranCompiler(FortranCompiler): diff --git a/mesonbuild/compilers/mixins/elbrus.py b/mesonbuild/compilers/mixins/elbrus.py index 87bf52a2f..db743d806 100644 --- a/mesonbuild/compilers/mixins/elbrus.py +++ b/mesonbuild/compilers/mixins/elbrus.py @@ -20,6 +20,7 @@ import subprocess import re from .gnu import GnuLikeCompiler +from .gnu import gnu_optimization_args from ...mesonlib import Popen_safe if T.TYPE_CHECKING: @@ -29,7 +30,7 @@ if T.TYPE_CHECKING: class ElbrusCompiler(GnuLikeCompiler): # Elbrus compiler is nearly like GCC, but does not support # PCH, LTO, sanitizers and color output as of version 1.21.x. - def __init__(self, defines: T.Dict[str, str]): + def __init__(self): super().__init__() self.id = 'lcc' self.base_options = ['b_pgo', 'b_coverage', @@ -70,3 +71,13 @@ class ElbrusCompiler(GnuLikeCompiler): if line.lstrip().startswith('--sys_include'): includes.append(re.sub(r'\s*\\$', '', re.sub(r'^\s*--sys_include\s*', '', line))) return includes + + def get_optimization_args(self, optimization_level: str) -> T.List[str]: + return gnu_optimization_args[optimization_level] + + def get_pch_suffix(self) -> str: + # Actually it's not supported for now, but probably will be supported in future + return 'pch' + + def openmp_flags(self) -> T.List[str]: + return ['-fopenmp'] diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 58c9e996b..ef9480b69 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -586,11 +586,19 @@ class Environment: self.default_objcpp = ['c++', 'g++'] self.default_cs = ['csc', 'mcs'] else: - self.default_c = ['cc', 'gcc', 'clang', 'pgcc', 'icc'] - self.default_cpp = ['c++', 'g++', 'clang++', 'pgc++', 'icpc'] + if platform.machine().lower() == 'e2k': + # There are no objc or objc++ compilers for Elbrus, + # and there's no clang which can build binaries for host. + self.default_c = ['cc', 'gcc', 'lcc'] + self.default_cpp = ['c++', 'g++', 'l++'] + self.default_objc = [] + self.default_objcpp = [] + else: + self.default_c = ['cc', 'gcc', 'clang', 'pgcc', 'icc'] + self.default_cpp = ['c++', 'g++', 'clang++', 'pgc++', 'icpc'] + self.default_objc = ['cc', 'gcc', 'clang'] + self.default_objcpp = ['c++', 'g++', 'clang++'] self.default_fortran = ['gfortran', 'flang', 'pgfortran', 'ifort', 'g95'] - self.default_objc = ['cc', 'gcc', 'clang'] - self.default_objcpp = ['c++', 'g++', 'clang++'] self.default_cs = ['mcs', 'csc'] self.default_d = ['ldc2', 'ldc', 'gdc', 'dmd'] self.default_java = ['javac'] @@ -939,6 +947,7 @@ class Environment: cls = GnuCCompiler if lang == 'c' else GnuCPPCompiler linker = self._guess_nix_linker(compiler, cls, for_machine) + return cls( ccache + compiler, version, for_machine, is_cross, info, exe_wrap, defines, full_version=full_version, @@ -1258,7 +1267,7 @@ class Environment: popen_exceptions[' '.join(compiler + arg)] = e continue version = search_version(out) - if 'Free Software Foundation' in out or ('e2k' in out and 'lcc' in out): + if 'Free Software Foundation' in out: defines = self.get_gnu_compiler_defines(compiler) if not defines: popen_exceptions[' '.join(compiler)] = 'no pre-processor defines' diff --git a/run_unittests.py b/run_unittests.py index ae12f4e9c..ff9dbd673 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -2290,7 +2290,7 @@ class AllPlatformTests(BasePlatformTests): ar = mesonbuild.linkers.ArLinker lib = mesonbuild.linkers.VisualStudioLinker langs = [('c', 'CC'), ('cpp', 'CXX')] - if not is_windows(): + if not is_windows() and platform.machine().lower() != 'e2k': langs += [('objc', 'OBJC'), ('objcpp', 'OBJCXX')] testdir = os.path.join(self.unit_test_dir, '5 compiler detection') env = get_fake_env(testdir, self.builddir, self.prefix) @@ -3087,7 +3087,9 @@ int main(int argc, char **argv) { pass try: env.detect_fortran_compiler(MachineChoice.HOST) - langs.append('fortran') + if is_windows() or platform.machine().lower() != 'e2k': + # Elbrus Fortran compiler can't generate debug information + langs.append('fortran') except EnvironmentException: pass try: