From 484fca9866f6b477a2ca30bb75be8a15de598e66 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Mon, 8 Oct 2018 15:40:15 -0700 Subject: compilers: Fix the set of features that ICC exposes --- mesonbuild/compilers/compilers.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'mesonbuild/compilers/compilers.py') diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 85a8480..ca8c09c 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -1731,10 +1731,17 @@ 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' -- cgit v1.1 From 28fd725d61bec363d9bcc403e78b38312dfeb276 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 9 Oct 2018 11:04:27 -0700 Subject: compilers: fix compiler.compile for Intel Compilers has_arguments is the wrong thing to fix, since all checks that require compiler options are based on compiles, it's the right thing to modify. --- mesonbuild/compilers/compilers.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'mesonbuild/compilers/compilers.py') diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index ca8c09c..306e5d6 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. @@ -1733,6 +1736,7 @@ class ArmclangCompiler: # 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. @@ -1764,9 +1768,16 @@ 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 + ] + return super().compiles(*args, **kwargs) class ArmCompiler: -- cgit v1.1 From f46adb44bf7eeeb15ddaed81f73433b5e7a3bff6 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Wed, 10 Oct 2018 10:17:55 -0700 Subject: compilers: Enable PGO for ICC ICC doesn't use the same -fprofile-generate/-fprofile-use that GCC and Clang use, instead it has -prof-gen and -prof-use. I've gone ahead and added the threadsafe option to -prof-gen, as meson currently doesn't have a way to specify that level of granularity and GCC and Clang's profiles are threadsafe. --- mesonbuild/compilers/compilers.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'mesonbuild/compilers/compilers.py') diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 306e5d6..755bd46 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -457,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: @@ -503,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: @@ -674,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 @@ -1258,6 +1257,14 @@ 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()) + @enum.unique class CompilerType(enum.Enum): @@ -1498,6 +1505,12 @@ 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'] + class GnuCompiler(GnuLikeCompiler): """ @@ -1779,6 +1792,12 @@ class IntelCompiler(GnuLikeCompiler): ] 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: # Functionality that is common to all ARM family compilers. -- cgit v1.1 From a480de1cb55c9efa88a9a520d0d776743b4e5664 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Wed, 10 Oct 2018 13:36:23 -0700 Subject: compilers: ICC should error when an unknown __attribute__ is tested --- mesonbuild/compilers/compilers.py | 1 + 1 file changed, 1 insertion(+) (limited to 'mesonbuild/compilers/compilers.py') diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 755bd46..3d53f27 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -1789,6 +1789,7 @@ class IntelCompiler(GnuLikeCompiler): extra_args, '-diag-error', '10006', # ignoring unknown option '-diag-error', '10148', # Option not supported + '-diag-error', '1292', # unknown __attribute__ ] return super().compiles(*args, **kwargs) -- cgit v1.1 From 9f9cfd21396db5cd5eb1711916c8b0c6e433c702 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Sat, 13 Oct 2018 20:00:38 -0700 Subject: compilers: Move get_allow_undefined_link_args to Compiler This allows each implementation (gnu-like) and msvc to be implemented in their respective classes rather than through an if tree in the CCompiler class. This is cleaner abstraction and allows us to clean up the Fortran compiler, which was calling CCompiler bound methods without an instance. --- mesonbuild/compilers/compilers.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'mesonbuild/compilers/compilers.py') diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 3d53f27..f464ec8 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -1265,6 +1265,12 @@ class Compiler: 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): @@ -1511,6 +1517,14 @@ class GnuLikeCompiler(abc.ABC): 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): """ -- cgit v1.1