From 238d1a37a0eed2a473950e335d44ba5d65217192 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Mon, 20 Feb 2017 04:55:05 +0530 Subject: Factor out common code in compiler detection This was being duplicated across C/C++/ObjC/ObjC++/Fortran and hence was behaving slightly differently in each. --- mesonbuild/environment.py | 182 +++++++++++++++++----------------------------- 1 file changed, 65 insertions(+), 117 deletions(-) (limited to 'mesonbuild') diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index cbfa3ec..5d8c0dc 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -367,10 +367,13 @@ class Environment: # We ignore Cygwin for now, and treat it as a standard GCC return GCC_STANDARD - def detect_c_compiler(self, want_cross): - evar = 'CC' + def _get_compilers(self, lang, evar, want_cross): + ''' + The list of compilers is detected in the exact same way for + C, C++, ObjC, ObjC++, Fortran so consolidate it here. + ''' if self.is_cross_build() and want_cross: - compilers = mesonlib.stringintlistify(self.cross_info.config['binaries']['c']) + compilers = mesonlib.stringlistify(self.cross_info.config['binaries'][lang]) ccache = [] is_cross = True if self.cross_info.need_exe_wrapper(): @@ -383,11 +386,23 @@ class Environment: is_cross = False exe_wrap = None else: - compilers = self.default_c + compilers = getattr(self, 'default_' + lang) ccache = self.detect_ccache() is_cross = False exe_wrap = None + return compilers, ccache, is_cross, exe_wrap + + def _handle_compiler_exceptions(self, exceptions, compilers): + errmsg = 'Unknown compiler(s): ' + str(compilers) + if exceptions: + errmsg += '\nThe follow exceptions were encountered:' + for (c, e) in exceptions.items(): + errmsg += '\nRunning "{0}" gave "{1}"'.format(c, e) + raise EnvironmentException(errmsg) + + def detect_c_compiler(self, want_cross): popen_exceptions = {} + compilers, ccache, is_cross, exe_wrap = self._get_compilers('c', 'CC', want_cross) for compiler in compilers: if isinstance(compiler, str): compiler = [compiler] @@ -425,33 +440,13 @@ class Environment: # TODO: add microsoft add check OSX inteltype = ICC_STANDARD return IntelCCompiler(ccache + compiler, version, inteltype, is_cross, exe_wrap) - errmsg = 'Unknown compiler(s): ' + str(compilers) - if popen_exceptions: - errmsg += '\nThe follow exceptions were encountered:' - for (c, e) in popen_exceptions.items(): - errmsg += '\nRunning "{0}" gave "{1}"'.format(c, e) - raise EnvironmentException(errmsg) + self._handle_compiler_exceptions(popen_exceptions, compilers) def detect_fortran_compiler(self, want_cross): - evar = 'FC' - if self.is_cross_build() and want_cross: - compilers = meson.stringlistify(self.cross_info['fortran']) - is_cross = True - if self.cross_info.need_exe_wrapper(): - exe_wrap = self.cross_info.get('exe_wrapper', None) - else: - exe_wrap = [] - elif evar in os.environ: - compilers = os.environ[evar].split() - is_cross = False - exe_wrap = None - else: - compilers = self.default_fortran - is_cross = False - exe_wrap = None popen_exceptions = {} + compilers, ccache, is_cross, exe_wrap = self._get_compilers('fortran', 'FC', want_cross) for compiler in compilers: - if not isinstance(compiler, list): + if isinstance(compiler, str): compiler = [compiler] for arg in ['--version', '-V']: try: @@ -492,12 +487,7 @@ class Environment: if 'NAG Fortran' in err: return NAGFortranCompiler(compiler, version, is_cross, exe_wrap) - errmsg = 'Unknown compiler(s): ' + str(compilers) - if popen_exceptions: - errmsg += '\nThe follow exceptions were encountered:' - for (c, e) in popen_exceptions.items(): - errmsg += '\nRunning "{0}" gave "{1}"'.format(c, e) - raise EnvironmentException(errmsg) + self._handle_compiler_exceptions(popen_exceptions, compilers) def get_scratch_dir(self): return self.scratch_dir @@ -507,26 +497,8 @@ class Environment: return os.path.join(path, 'depfixer.py') def detect_cpp_compiler(self, want_cross): - evar = 'CXX' - if self.is_cross_build() and want_cross: - compilers = mesonlib.stringlistify(self.cross_info.config['binaries']['cpp']) - ccache = [] - is_cross = True - if self.cross_info.need_exe_wrapper(): - exe_wrap = self.cross_info.config['binaries'].get('exe_wrapper', None) - else: - exe_wrap = [] - elif evar in os.environ: - compilers = shlex.split(os.environ[evar]) - ccache = [] - is_cross = False - exe_wrap = None - else: - compilers = self.default_cpp - ccache = self.detect_ccache() - is_cross = False - exe_wrap = None popen_exceptions = {} + compilers, ccache, is_cross, exe_wrap = self._get_compilers('cpp', 'CXX', want_cross) for compiler in compilers: if isinstance(compiler, str): compiler = [compiler] @@ -562,61 +534,51 @@ class Environment: # TODO: add microsoft add check OSX inteltype = ICC_STANDARD return IntelCPPCompiler(ccache + compiler, version, inteltype, is_cross, exe_wrap) - errmsg = 'Unknown compiler(s): "' + ', '.join(compilers) + '"' - if popen_exceptions: - errmsg += '\nThe follow exceptions were encountered:' - for (c, e) in popen_exceptions.items(): - errmsg += '\nRunning "{0}" gave "{1}"'.format(c, e) - raise EnvironmentException(errmsg) + self._handle_compiler_exceptions(popen_exceptions, compilers) def detect_objc_compiler(self, want_cross): - if self.is_cross_build() and want_cross: - exelist = mesonlib.stringlistify(self.cross_info['objc']) - is_cross = True - if self.cross_info.need_exe_wrapper(): - exe_wrap = self.cross_info.get('exe_wrapper', None) - else: - exe_wrap = [] - else: - exelist = self.get_objc_compiler_exelist() - is_cross = False - exe_wrap = None - try: - p, out, err = Popen_safe(exelist + ['--version']) - except OSError: - raise EnvironmentException('Could not execute ObjC compiler "%s"' % ' '.join(exelist)) - version = search_version(out) - if 'Free Software Foundation' in out: - defines = self.get_gnu_compiler_defines(exelist) - version = self.get_gnu_version_from_defines(defines) - return GnuObjCCompiler(exelist, version, is_cross, exe_wrap, defines) - if out.startswith('Apple LLVM'): - return ClangObjCCompiler(exelist, version, CLANG_OSX, is_cross, exe_wrap) - raise EnvironmentException('Unknown compiler "' + ' '.join(exelist) + '"') + popen_exceptions = {} + compilers, ccache, is_cross, exe_wrap = self._get_compilers('objc', 'OBJC', want_cross) + for compiler in compilers: + if isinstance(compiler, str): + compiler = [compiler] + try: + p, out, err = Popen_safe(compiler + ['--version']) + except OSError: + popen_exceptions[' '.join(compiler + [arg])] = e + version = search_version(out) + if 'Free Software Foundation' in out: + defines = self.get_gnu_compiler_defines(compiler) + if not defines: + popen_exceptions[compiler] = 'no pre-processor defines' + continue + version = self.get_gnu_version_from_defines(defines) + return GnuObjCCompiler(ccache + compiler, version, is_cross, exe_wrap, defines) + if out.startswith('Apple LLVM'): + return ClangObjCCompiler(ccache + compiler, version, CLANG_OSX, is_cross, exe_wrap) + self._handle_compiler_exceptions(popen_exceptions, compilers) def detect_objcpp_compiler(self, want_cross): - if self.is_cross_build() and want_cross: - exelist = mesonlib.stringlistify(self.cross_info['objcpp']) - is_cross = True - if self.cross_info.need_exe_wrapper(): - exe_wrap = self.cross_info.get('exe_wrapper', None) - else: - exe_wrap = [] - else: - exelist = self.get_objcpp_compiler_exelist() - is_cross = False - exe_wrap = None - try: - p, out, err = Popen_safe(exelist + ['--version']) - except OSError: - raise EnvironmentException('Could not execute ObjC++ compiler "%s"' % ' '.join(exelist)) - version = search_version(out) - if 'Free Software Foundation' in out: - defines = self.get_gnu_compiler_defines(exelist) - return GnuObjCPPCompiler(exelist, version, is_cross, exe_wrap, defines) - if out.startswith('Apple LLVM'): - return ClangObjCPPCompiler(exelist, version, CLANG_OSX, is_cross, exe_wrap) - raise EnvironmentException('Unknown compiler "' + ' '.join(exelist) + '"') + popen_exceptions = {} + compilers, ccache, is_cross, exe_wrap = self._get_compilers('objcpp', 'OBJCXX', want_cross) + for compiler in compilers: + if isinstance(compiler, str): + compiler = [compiler] + try: + p, out, err = Popen_safe(compiler + ['--version']) + except OSError: + popen_exceptions[' '.join(compiler + [arg])] = e + version = search_version(out) + if 'Free Software Foundation' in out: + defines = self.get_gnu_compiler_defines(compiler) + if not defines: + popen_exceptions[compiler] = 'no pre-processor defines' + continue + version = self.get_gnu_version_from_defines(defines) + return GnuObjCPPCompiler(ccache + compiler, version, is_cross, exe_wrap, defines) + if out.startswith('Apple LLVM'): + return ClangObjCPPCompiler(ccache + compiler, version, CLANG_OSX, is_cross, exe_wrap) + self._handle_compiler_exceptions(popen_exceptions, compilers) def detect_java_compiler(self): exelist = ['javac'] @@ -747,20 +709,6 @@ class Environment: cmdlist = [] return cmdlist - def get_objc_compiler_exelist(self): - ccachelist = self.detect_ccache() - evar = 'OBJCC' - if evar in os.environ: - return os.environ[evar].split() - return ccachelist + self.default_objc - - def get_objcpp_compiler_exelist(self): - ccachelist = self.detect_ccache() - evar = 'OBJCXX' - if evar in os.environ: - return os.environ[evar].split() - return ccachelist + self.default_objcpp - def get_source_dir(self): return self.source_dir -- cgit v1.1 From 283d5e623373dc5fa60dc51a21183cc403f3eac0 Mon Sep 17 00:00:00 2001 From: Hase Bastian Date: Mon, 20 Feb 2017 05:00:08 +0530 Subject: Detect (non-Apple) clang as objc/c++ compiler See https://github.com/mesonbuild/meson/pull/1388 --- mesonbuild/environment.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'mesonbuild') diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 5d8c0dc..9fdc7f4 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -556,6 +556,8 @@ class Environment: return GnuObjCCompiler(ccache + compiler, version, is_cross, exe_wrap, defines) if out.startswith('Apple LLVM'): return ClangObjCCompiler(ccache + compiler, version, CLANG_OSX, is_cross, exe_wrap) + if out.startswith('clang'): + return ClangObjCCompiler(ccache + compiler, version, CLANG_STANDARD, is_cross, exe_wrap) self._handle_compiler_exceptions(popen_exceptions, compilers) def detect_objcpp_compiler(self, want_cross): @@ -578,6 +580,8 @@ class Environment: return GnuObjCPPCompiler(ccache + compiler, version, is_cross, exe_wrap, defines) if out.startswith('Apple LLVM'): return ClangObjCPPCompiler(ccache + compiler, version, CLANG_OSX, is_cross, exe_wrap) + if out.startswith('clang'): + return ClangObjCPPCompiler(ccache + compiler, version, CLANG_STANDARD, is_cross, exe_wrap) self._handle_compiler_exceptions(popen_exceptions, compilers) def detect_java_compiler(self): -- cgit v1.1 From 68eea4818df3378a22dc91ffc00d3c750add29ba Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Mon, 20 Feb 2017 05:03:59 +0530 Subject: environment: Use shlex.split() to get AR from the env That way if the path has spaces, it won't get messed up. --- mesonbuild/environment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mesonbuild') diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 9fdc7f4..405be0e 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -680,7 +680,7 @@ class Environment: else: evar = 'AR' if evar in os.environ: - linker = os.environ[evar].strip() + linker = shlex.split(os.environ[evar]) elif isinstance(compiler, VisualStudioCCompiler): linker = self.vs_static_linker else: -- cgit v1.1 From 798c349e35f5f7b740ce83360c7f59188a96bd28 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Mon, 20 Feb 2017 06:45:12 +0530 Subject: Fix compiler exelist in cross-info and the environment https://github.com/mesonbuild/meson/pull/1406 had an incomplete fix for this. The test case caught it. Note: this still doesn't test that setting it in the cross-info works, but it's the same codepath as via the environment so it should be ok. --- mesonbuild/environment.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mesonbuild') diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 405be0e..3021770 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -373,7 +373,7 @@ class Environment: C, C++, ObjC, ObjC++, Fortran so consolidate it here. ''' if self.is_cross_build() and want_cross: - compilers = mesonlib.stringlistify(self.cross_info.config['binaries'][lang]) + compilers = [mesonlib.stringlistify(self.cross_info.config['binaries'][lang])] ccache = [] is_cross = True if self.cross_info.need_exe_wrapper(): @@ -381,7 +381,7 @@ class Environment: else: exe_wrap = [] elif evar in os.environ: - compilers = shlex.split(os.environ[evar]) + compilers = [shlex.split(os.environ[evar])] ccache = [] is_cross = False exe_wrap = None -- cgit v1.1 From 56a8b2a1810b3ec1964c2a2f09e12ff841ac13ef Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Mon, 20 Feb 2017 07:01:25 +0530 Subject: Fix static linker exelist in cross-info and environment https://github.com/mesonbuild/meson/pull/1406 had an incomplete fix for this. The test case caught it. Note: this still doesn't test that setting it in the cross-info works, but it's the same codepath as via the environment so it should be ok. --- mesonbuild/environment.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'mesonbuild') diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 3021770..76b2205 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -677,30 +677,32 @@ class Environment: def detect_static_linker(self, compiler): if compiler.is_cross: linker = self.cross_info.config['binaries']['ar'] + if isinstance(linker, str): + linker = [linker] else: evar = 'AR' if evar in os.environ: linker = shlex.split(os.environ[evar]) elif isinstance(compiler, VisualStudioCCompiler): - linker = self.vs_static_linker + linker = [self.vs_static_linker] else: - linker = self.default_static_linker - basename = os.path.basename(linker).lower() + linker = [self.default_static_linker] + basename = os.path.basename(linker[-1]).lower() if basename == 'lib' or basename == 'lib.exe': arg = '/?' else: arg = '--version' try: - p, out, err = Popen_safe([linker, arg]) + p, out, err = Popen_safe(linker + [arg]) except OSError: - raise EnvironmentException('Could not execute static linker "%s".' % linker) + raise EnvironmentException('Could not execute static linker "%s".' % ' '.join(linker)) if '/OUT:' in out or '/OUT:' in err: - return VisualStudioLinker([linker]) + return VisualStudioLinker(linker) if p.returncode == 0: - return ArLinker([linker]) + return ArLinker(linker) if p.returncode == 1 and err.startswith('usage'): # OSX - return ArLinker([linker]) - raise EnvironmentException('Unknown static linker "%s"' % linker) + return ArLinker(linker) + raise EnvironmentException('Unknown static linker "%s"' % ' '.join(linker)) def detect_ccache(self): try: -- cgit v1.1 From 003e0a0610582020d1b213e0c8d16fe63bc6eabe Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Mon, 20 Feb 2017 07:18:13 +0530 Subject: Use the same function for detection of C and C++ compilers The mechanism is identical which means there's a high likelihood of unintended divergence. In fact, a slight divergence was already there. --- mesonbuild/environment.py | 62 ++++++++++++----------------------------------- 1 file changed, 16 insertions(+), 46 deletions(-) (limited to 'mesonbuild') diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 76b2205..fe89f0e 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -400,9 +400,9 @@ class Environment: errmsg += '\nRunning "{0}" gave "{1}"'.format(c, e) raise EnvironmentException(errmsg) - def detect_c_compiler(self, want_cross): + def _detect_c_or_cpp_compiler(self, lang, evar, want_cross): popen_exceptions = {} - compilers, ccache, is_cross, exe_wrap = self._get_compilers('c', 'CC', want_cross) + compilers, ccache, is_cross, exe_wrap = self._get_compilers(lang, evar, want_cross) for compiler in compilers: if isinstance(compiler, str): compiler = [compiler] @@ -424,24 +424,34 @@ class Environment: continue gtype = self.get_gnu_compiler_type(defines) version = self.get_gnu_version_from_defines(defines) - return GnuCCompiler(ccache + compiler, version, gtype, is_cross, exe_wrap, defines) + cls = GnuCCompiler if lang == 'c' else GnuCPPCompiler + return cls(ccache + compiler, version, gtype, is_cross, exe_wrap, defines) if 'clang' in out: if 'Apple' in out or for_darwin(want_cross, self): cltype = CLANG_OSX else: cltype = CLANG_STANDARD - return ClangCCompiler(ccache + compiler, version, cltype, is_cross, exe_wrap) + cls = ClangCCompiler if lang == 'c' else ClangCPPCompiler + return cls(ccache + compiler, version, cltype, is_cross, exe_wrap) if 'Microsoft' in out or 'Microsoft' in err: # Visual Studio prints version number to stderr but # everything else to stdout. Why? Lord only knows. version = search_version(err) - return VisualStudioCCompiler(compiler, version, is_cross, exe_wrap) + cls = VisualStudioCCompiler if lang == 'c' else VisualStudioCPPCompiler + return cls(compiler, version, is_cross, exe_wrap) if '(ICC)' in out: # TODO: add microsoft add check OSX inteltype = ICC_STANDARD - return IntelCCompiler(ccache + compiler, version, inteltype, is_cross, exe_wrap) + cls = IntelCCompiler if lang == 'c' else IntelCPPCompiler + return cls(ccache + compiler, version, inteltype, is_cross, exe_wrap) self._handle_compiler_exceptions(popen_exceptions, compilers) + def detect_c_compiler(self, want_cross): + return self._detect_c_or_cpp_compiler('c', 'CC', want_cross) + + def detect_cpp_compiler(self, want_cross): + return self._detect_c_or_cpp_compiler('cpp', 'CXX', want_cross) + def detect_fortran_compiler(self, want_cross): popen_exceptions = {} compilers, ccache, is_cross, exe_wrap = self._get_compilers('fortran', 'FC', want_cross) @@ -496,46 +506,6 @@ class Environment: path = os.path.split(__file__)[0] return os.path.join(path, 'depfixer.py') - def detect_cpp_compiler(self, want_cross): - popen_exceptions = {} - compilers, ccache, is_cross, exe_wrap = self._get_compilers('cpp', 'CXX', want_cross) - for compiler in compilers: - if isinstance(compiler, str): - compiler = [compiler] - basename = os.path.basename(compiler[-1]).lower() - if basename == 'cl' or basename == 'cl.exe': - arg = '/?' - else: - arg = '--version' - try: - p, out, err = Popen_safe(compiler + [arg]) - except OSError as e: - popen_exceptions[' '.join(compiler + [arg])] = e - continue - version = search_version(out) - if 'Free Software Foundation' in out: - defines = self.get_gnu_compiler_defines(compiler) - if not defines: - popen_exceptions[compiler] = 'no pre-processor defines' - continue - gtype = self.get_gnu_compiler_type(defines) - version = self.get_gnu_version_from_defines(defines) - return GnuCPPCompiler(ccache + compiler, version, gtype, is_cross, exe_wrap, defines) - if 'clang' in out: - if 'Apple' in out: - cltype = CLANG_OSX - else: - cltype = CLANG_STANDARD - return ClangCPPCompiler(ccache + compiler, version, cltype, is_cross, exe_wrap) - if 'Microsoft' in out or 'Microsoft' in err: - version = search_version(err) - return VisualStudioCPPCompiler(compiler, version, is_cross, exe_wrap) - if '(ICC)' in out: - # TODO: add microsoft add check OSX - inteltype = ICC_STANDARD - return IntelCPPCompiler(ccache + compiler, version, inteltype, is_cross, exe_wrap) - self._handle_compiler_exceptions(popen_exceptions, compilers) - def detect_objc_compiler(self, want_cross): popen_exceptions = {} compilers, ccache, is_cross, exe_wrap = self._get_compilers('objc', 'OBJC', want_cross) -- cgit v1.1 From 69e83d6aed89745bad540295e4a93ef37265e1b3 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Mon, 20 Feb 2017 07:20:18 +0530 Subject: Support passing of options to compilers and linkers If you pass options, the last element in the array won't be the compiler basename, so just check if the basename is in the exelist somewhere. Includes a test. --- mesonbuild/environment.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'mesonbuild') diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index fe89f0e..b184b3f 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -407,8 +407,7 @@ class Environment: if isinstance(compiler, str): compiler = [compiler] try: - basename = os.path.basename(compiler[-1]).lower() - if basename == 'cl' or basename == 'cl.exe': + if 'cl' in compiler or 'cl.exe' in compiler: arg = '/?' else: arg = '--version' @@ -657,8 +656,7 @@ class Environment: linker = [self.vs_static_linker] else: linker = [self.default_static_linker] - basename = os.path.basename(linker[-1]).lower() - if basename == 'lib' or basename == 'lib.exe': + if 'lib' in linker or 'lib.exe' in linker: arg = '/?' else: arg = '--version' -- cgit v1.1 From 8e48f232628a749efe393f92db0302c93d8496ca Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Mon, 20 Feb 2017 08:02:48 +0530 Subject: Detect GCC type on macOS for ObjC/C++ too These compilers are available in MinGW and can be built on macOS. More interestingly, `gcc` is a wrapper around `clang` on macOS, so we will detect the compiler type incorrectly on macOS without this. --- mesonbuild/compilers.py | 16 ++++++---------- mesonbuild/environment.py | 6 ++++-- 2 files changed, 10 insertions(+), 12 deletions(-) (limited to 'mesonbuild') diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py index 30f2608..8c2bb92 100644 --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -2404,11 +2404,9 @@ class GnuCPPCompiler(GnuCompiler, CPPCompiler): class GnuObjCCompiler(GnuCompiler, ObjCCompiler): - def __init__(self, exelist, version, is_cross, exe_wrapper=None, defines=None): + def __init__(self, exelist, version, gcc_type, is_cross, exe_wrapper=None, defines=None): ObjCCompiler.__init__(self, exelist, version, is_cross, exe_wrapper) - # Not really correct, but GNU objc is only used on non-OSX non-win. File a bug - # if this breaks your use case. - GnuCompiler.__init__(self, GCC_STANDARD, defines) + GnuCompiler.__init__(self, gcc_type, defines) default_warn_args = ['-Wall', '-Winvalid-pch'] self.warn_args = {'1': default_warn_args, '2': default_warn_args + ['-Wextra'], @@ -2416,11 +2414,9 @@ class GnuObjCCompiler(GnuCompiler, ObjCCompiler): class GnuObjCPPCompiler(GnuCompiler, ObjCPPCompiler): - def __init__(self, exelist, version, is_cross, exe_wrapper=None, defines=None): + def __init__(self, exelist, version, gcc_type, is_cross, exe_wrapper=None, defines=None): ObjCPPCompiler.__init__(self, exelist, version, is_cross, exe_wrapper) - # Not really correct, but GNU objc is only used on non-OSX non-win. File a bug - # if this breaks your use case. - GnuCompiler.__init__(self, GCC_STANDARD, defines) + GnuCompiler.__init__(self, gcc_type, defines) default_warn_args = ['-Wall', '-Winvalid-pch', '-Wnon-virtual-dtor'] self.warn_args = {'1': default_warn_args, '2': default_warn_args + ['-Wextra'], @@ -2549,13 +2545,13 @@ class ClangCPPCompiler(ClangCompiler, CPPCompiler): class ClangObjCCompiler(ClangCompiler, GnuObjCCompiler): def __init__(self, exelist, version, cltype, is_cross, exe_wrapper=None): - GnuObjCCompiler.__init__(self, exelist, version, is_cross, exe_wrapper) + GnuObjCCompiler.__init__(self, exelist, version, cltype, is_cross, exe_wrapper) ClangCompiler.__init__(self, cltype) self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize', 'b_coverage'] class ClangObjCPPCompiler(ClangCompiler, GnuObjCPPCompiler): def __init__(self, exelist, version, cltype, is_cross, exe_wrapper=None): - GnuObjCPPCompiler.__init__(self, exelist, version, is_cross, exe_wrapper) + GnuObjCPPCompiler.__init__(self, exelist, version, cltype, is_cross, exe_wrapper) ClangCompiler.__init__(self, cltype) self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize', 'b_coverage'] diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index b184b3f..88dc4cf 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -521,8 +521,9 @@ class Environment: if not defines: popen_exceptions[compiler] = 'no pre-processor defines' continue + gtype = self.get_gnu_compiler_type(defines) version = self.get_gnu_version_from_defines(defines) - return GnuObjCCompiler(ccache + compiler, version, is_cross, exe_wrap, defines) + return GnuObjCCompiler(ccache + compiler, version, gtype, is_cross, exe_wrap, defines) if out.startswith('Apple LLVM'): return ClangObjCCompiler(ccache + compiler, version, CLANG_OSX, is_cross, exe_wrap) if out.startswith('clang'): @@ -545,8 +546,9 @@ class Environment: if not defines: popen_exceptions[compiler] = 'no pre-processor defines' continue + gtype = self.get_gnu_compiler_type(defines) version = self.get_gnu_version_from_defines(defines) - return GnuObjCPPCompiler(ccache + compiler, version, is_cross, exe_wrap, defines) + return GnuObjCPPCompiler(ccache + compiler, version, gtype, is_cross, exe_wrap, defines) if out.startswith('Apple LLVM'): return ClangObjCPPCompiler(ccache + compiler, version, CLANG_OSX, is_cross, exe_wrap) if out.startswith('clang'): -- cgit v1.1