diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2018-11-17 06:57:07 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-17 06:57:07 -0800 |
commit | 0092a7d3f98b01afdffd3e4ede29d6b6e6bde96d (patch) | |
tree | 0c493f0c8e63b4a03b1bb69c3549351b04b32b49 /mesonbuild/compilers | |
parent | aa20c91e6e03373cd00af110a56640d3f51205cd (diff) | |
parent | 842d8556ecc873abf3c580b725bb8d1fe5230246 (diff) | |
download | meson-0092a7d3f98b01afdffd3e4ede29d6b6e6bde96d.zip meson-0092a7d3f98b01afdffd3e4ede29d6b6e6bde96d.tar.gz meson-0092a7d3f98b01afdffd3e4ede29d6b6e6bde96d.tar.bz2 |
Merge pull request #4359 from dcbaker/icc-fixes
ICC fixes for Linux and MacOS
Diffstat (limited to 'mesonbuild/compilers')
-rw-r--r-- | mesonbuild/compilers/c.py | 36 | ||||
-rw-r--r-- | mesonbuild/compilers/c_function_attributes.py | 8 | ||||
-rw-r--r-- | mesonbuild/compilers/compilers.py | 72 | ||||
-rw-r--r-- | mesonbuild/compilers/fortran.py | 14 |
4 files changed, 87 insertions, 43 deletions
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index 547d59f..e5b89ce 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -157,26 +157,6 @@ class CCompiler(Compiler): ''' return self.get_no_optimization_args() - def get_allow_undefined_link_args(self): - ''' - Get args for allowing undefined symbols when linking to a shared library - ''' - if self.id in ('clang', 'gcc'): - if self.compiler_type.is_osx_compiler: - # Apple ld - return ['-Wl,-undefined,dynamic_lookup'] - elif self.compiler_type.is_windows_compiler: - # For PE/COFF this is impossible - return [] - else: - # GNU ld and LLVM lld - return ['-Wl,--allow-shlib-undefined'] - elif isinstance(self, VisualStudioCCompiler): - # link.exe - return ['/FORCE:UNRESOLVED'] - # FIXME: implement other linkers - return [] - def get_output_args(self, target): return ['-o', target] @@ -413,12 +393,12 @@ class CCompiler(Compiler): dependencies=dependencies) def _get_compiler_check_args(self, env, extra_args, dependencies, mode='compile'): - if callable(extra_args): - extra_args = extra_args(mode) if extra_args is None: extra_args = [] - elif isinstance(extra_args, str): - extra_args = [extra_args] + else: + extra_args = listify(extra_args) + extra_args = listify([e(mode) if callable(e) else e for e in extra_args]) + if dependencies is None: dependencies = [] elif not isinstance(dependencies, list): @@ -1268,7 +1248,7 @@ class IntelCCompiler(IntelCompiler, CCompiler): CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwargs) IntelCompiler.__init__(self, compiler_type) self.lang_header = 'c-header' - default_warn_args = ['-Wall', '-w3', '-diag-disable:remark', '-Wpch-messages'] + default_warn_args = ['-Wall', '-w3', '-diag-disable:remark'] self.warn_args = {'1': default_warn_args, '2': default_warn_args + ['-Wextra'], '3': default_warn_args + ['-Wextra']} @@ -1597,11 +1577,17 @@ class VisualStudioCCompiler(CCompiler): def get_argument_syntax(self): return 'msvc' + def get_allow_undefined_link_args(self): + # link.exe + return ['/FORCE:UNRESOLVED'] + + class ClangClCCompiler(VisualStudioCCompiler): def __init__(self, exelist, version, is_cross, exe_wrap, is_64): super().__init__(exelist, version, is_cross, exe_wrap, is_64) self.id = 'clang-cl' + class ArmCCompiler(ArmCompiler, CCompiler): def __init__(self, exelist, version, compiler_type, is_cross, exe_wrapper=None, **kwargs): CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwargs) diff --git a/mesonbuild/compilers/c_function_attributes.py b/mesonbuild/compilers/c_function_attributes.py index 9aeaaf2..a522a1a 100644 --- a/mesonbuild/compilers/c_function_attributes.py +++ b/mesonbuild/compilers/c_function_attributes.py @@ -91,10 +91,10 @@ C_FUNC_ATTRIBUTES = { 'used': 'int foo(void) __attribute__((used));', 'visibility': ''' - int foo_def(void) __attribute__((visibility(("default")))); - int foo_hid(void) __attribute__((visibility(("hidden")))); - int foo_int(void) __attribute__((visibility(("internal")))); - int foo_pro(void) __attribute__((visibility(("protected"))));''', + int foo_def(void) __attribute__((visibility("default"))); + int foo_hid(void) __attribute__((visibility("hidden"))); + int foo_int(void) __attribute__((visibility("internal"))); + int foo_pro(void) __attribute__((visibility("protected")));''', 'warning': 'int foo(void) __attribute__((warning("")));', 'warn_unused_result': diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 85a8480..f464ec8 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -19,7 +19,10 @@ from ..linkers import StaticLinker from .. import coredata from .. import mlog from .. import mesonlib -from ..mesonlib import EnvironmentException, MesonException, OrderedSet, version_compare, Popen_safe +from ..mesonlib import ( + EnvironmentException, MesonException, OrderedSet, version_compare, + Popen_safe +) """This file contains the data files of all compilers Meson knows about. To support a new compiler, add its information below. @@ -454,9 +457,9 @@ def get_base_compile_args(options, compiler): try: pgo_val = options['b_pgo'].value if pgo_val == 'generate': - args.append('-fprofile-generate') + args.extend(compiler.get_profile_generate_args()) elif pgo_val == 'use': - args.extend(['-fprofile-use', '-fprofile-correction']) + args.extend(compiler.get_profile_use_args()) except KeyError: pass try: @@ -500,9 +503,9 @@ def get_base_link_args(options, linker, is_shared_module): try: pgo_val = options['b_pgo'].value if pgo_val == 'generate': - args.append('-fprofile-generate') + args.extend(linker.get_profile_generate_args()) elif pgo_val == 'use': - args.extend(['-fprofile-use', '-fprofile-correction']) + args.extend(linker.get_profile_use_args()) except KeyError: pass try: @@ -671,7 +674,6 @@ class CompilerArgs(list): to recursively search for symbols in the libraries. This is not needed with other linkers. ''' - # A standalone argument must never be deduplicated because it is # defined by what comes _after_ it. Thus dedupping this: # -D FOO -D BAR @@ -1255,6 +1257,20 @@ class Compiler: """ return 'other' + def get_profile_generate_args(self): + raise EnvironmentException( + '%s does not support get_profile_generate_args ' % self.get_id()) + + def get_profile_use_args(self): + raise EnvironmentException( + '%s does not support get_profile_use_args ' % self.get_id()) + + def get_undefined_link_args(self): + ''' + Get args for allowing undefined symbols when linking to a shared library + ''' + return [] + @enum.unique class CompilerType(enum.Enum): @@ -1495,6 +1511,20 @@ class GnuLikeCompiler(abc.ABC): def get_argument_syntax(self): return 'gcc' + def get_profile_generate_args(self): + return ['-fprofile-generate'] + + def get_profile_use_args(self): + return ['-fprofile-use', '-fprofile-correction'] + + def get_allow_undefined_link_args(self): + if self.compiler_type.is_osx_compiler: + # Apple ld + return ['-Wl,-undefined,dynamic_lookup'] + else: + # GNU ld and LLVM lld + return ['-Wl,--allow-shlib-undefined'] + class GnuCompiler(GnuLikeCompiler): """ @@ -1731,10 +1761,18 @@ class ArmclangCompiler: return ['--symdefs=' + implibname] -# Tested on linux for ICC 14.0.3, 15.0.6, 16.0.4, 17.0.1 +# Tested on linux for ICC 14.0.3, 15.0.6, 16.0.4, 17.0.1, 19.0.0 class IntelCompiler(GnuLikeCompiler): + def __init__(self, compiler_type): super().__init__(compiler_type) + # As of 19.0.0 ICC doesn't have sanitizer, color, or lto support. + # + # It does have IPO, which serves much the same purpose as LOT, but + # there is an unfortunate rule for using IPO (you can't control the + # name of the output file) which break assumptions meson makes + self.base_options = ['b_pch', 'b_lundef', 'b_asneeded', 'b_pgo', + 'b_coverage', 'b_ndebug', 'b_staticpic', 'b_pie'] self.id = 'intel' self.lang_header = 'none' @@ -1757,9 +1795,23 @@ class IntelCompiler(GnuLikeCompiler): else: return ['-openmp'] - def has_arguments(self, args, env, code, mode): - # -diag-error 10148 is required to catch invalid -W options - return super().has_arguments(args + ['-diag-error', '10006', '-diag-error', '10148'], env, code, mode) + def compiles(self, *args, **kwargs): + # This covers a case that .get('foo', []) doesn't, that extra_args is + # defined and is None + extra_args = kwargs.get('extra_args') or [] + kwargs['extra_args'] = [ + extra_args, + '-diag-error', '10006', # ignoring unknown option + '-diag-error', '10148', # Option not supported + '-diag-error', '1292', # unknown __attribute__ + ] + return super().compiles(*args, **kwargs) + + def get_profile_generate_args(self): + return ['-prof-gen=threadsafe'] + + def get_profile_use_args(self): + return ['-prof-use'] class ArmCompiler: diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py index 23c4892..75db26d 100644 --- a/mesonbuild/compilers/fortran.py +++ b/mesonbuild/compilers/fortran.py @@ -144,9 +144,6 @@ end program prog def get_compiler_check_args(self): return CCompiler.get_compiler_check_args(self) - def get_allow_undefined_link_args(self): - return CCompiler.get_allow_undefined_link_args(self) - def get_output_args(self, target): return CCompiler.get_output_args(self, target) @@ -172,7 +169,7 @@ end program prog return ('-I', ) def get_module_outdir_args(self, path): - return ['-module' + path] + return ['-module', path] def module_name_to_filename(self, module_name): return module_name.lower() + '.mod' @@ -342,6 +339,15 @@ class IntelFortranCompiler(IntelCompiler, FortranCompiler): def get_preprocess_only_args(self): return ['-cpp', '-EP'] + def get_always_args(self): + """Ifort doesn't have -pipe.""" + val = super().get_always_args() + val.remove('-pipe') + return val + + def language_stdlib_only_link_flags(self): + return ['-lifcore', '-limf'] + class PathScaleFortranCompiler(FortranCompiler): def __init__(self, exelist, version, is_cross, exe_wrapper=None, **kwags): |