aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Seifert <soap@gentoo.org>2018-09-16 11:39:54 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2018-09-16 18:27:19 +0300
commit8f16d0f3c99666c36f37ef10df0b916e88c1afaa (patch)
tree58ed5d4066c2db116e9f3cec614c46a33ad5cffa
parent2b9fb36267c8661604ef53a7ddbd3a65f7b910dc (diff)
downloadmeson-8f16d0f3c99666c36f37ef10df0b916e88c1afaa.zip
meson-8f16d0f3c99666c36f37ef10df0b916e88c1afaa.tar.gz
meson-8f16d0f3c99666c36f37ef10df0b916e88c1afaa.tar.bz2
Fix ICC on macOS
-rw-r--r--mesonbuild/compilers/c.py10
-rw-r--r--mesonbuild/compilers/compilers.py19
-rw-r--r--mesonbuild/compilers/cpp.py19
-rw-r--r--mesonbuild/environment.py9
-rwxr-xr-xrun_unittests.py23
-rw-r--r--test cases/common/204 function attributes/meson.build8
-rw-r--r--test cases/unit/6 std override/meson.build4
-rw-r--r--test cases/unit/6 std override/prog98.cpp (renamed from test cases/unit/6 std override/prog03.cpp)2
8 files changed, 72 insertions, 22 deletions
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py
index 9b7ac68..c226a09 100644
--- a/mesonbuild/compilers/c.py
+++ b/mesonbuild/compilers/c.py
@@ -1191,7 +1191,7 @@ class IntelCCompiler(IntelCompiler, CCompiler):
default_warn_args = ['-Wall', '-w3', '-diag-disable:remark', '-Wpch-messages']
self.warn_args = {'1': default_warn_args,
'2': default_warn_args + ['-Wextra'],
- '3': default_warn_args + ['-Wextra', '-Wpedantic']}
+ '3': default_warn_args + ['-Wextra']}
def get_options(self):
opts = CCompiler.get_options(self)
@@ -1214,8 +1214,14 @@ class IntelCCompiler(IntelCompiler, CCompiler):
def get_std_shared_lib_link_args(self):
return ['-shared']
+ def get_std_shared_module_link_args(self, options):
+ if self.compiler_type.is_osx_compiler:
+ return ['-bundle', '-Wl,-undefined,dynamic_lookup']
+ return ['-shared']
+
def has_arguments(self, args, env, code, mode):
- return super().has_arguments(args + ['-diag-error', '10006'], 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)
class VisualStudioCCompiler(CCompiler):
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 9569c3f..6f90c6a 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -1451,7 +1451,7 @@ class ClangCompiler:
return GNU_LD_AS_NEEDED
def get_pic_args(self):
- if self.compiler_type in (CompilerType.CLANG_MINGW, CompilerType.CLANG_OSX):
+ if self.compiler_type.is_osx_compiler or self.compiler_type.is_windows_compiler:
return [] # On Window and OS X, pic is always on.
return ['-fPIC']
@@ -1615,19 +1615,31 @@ class IntelCompiler:
self.compiler_type = compiler_type
self.lang_header = 'none'
self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize', 'b_coverage',
- 'b_colorout', 'b_ndebug', 'b_staticpic', 'b_lundef', 'b_asneeded']
+ 'b_colorout', 'b_ndebug', 'b_staticpic', 'b_asneeded']
+ if not self.compiler_type.is_osx_compiler:
+ self.base_options.append('b_lundef')
# Assembly
self.can_compile_suffixes.add('s')
def get_pic_args(self):
+ if self.compiler_type.is_osx_compiler or self.compiler_type.is_windows_compiler:
+ return [] # On Window and OS X, pic is always on.
return ['-fPIC']
def get_buildtype_args(self, buildtype):
return gnulike_buildtype_args[buildtype]
def get_buildtype_linker_args(self, buildtype):
+ if self.compiler_type.is_osx_compiler:
+ return apple_buildtype_linker_args[buildtype]
return gnulike_buildtype_linker_args[buildtype]
+ def get_optimization_args(self, optimization_level):
+ return gnu_optimization_args[optimization_level]
+
+ def get_debug_args(self, is_debug):
+ return clike_debug_args[is_debug]
+
def get_pch_suffix(self):
return 'pchi'
@@ -1670,6 +1682,9 @@ class IntelCompiler:
def get_link_whole_for(self, args):
return GnuCompiler.get_link_whole_for(self, args)
+ def gnu_symbol_visibility_args(self, vistype):
+ return gnu_symbol_visibility_args[vistype]
+
class ArmCompiler:
# Functionality that is common to all ARM family compilers.
diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py
index 004f65e..6220b93 100644
--- a/mesonbuild/compilers/cpp.py
+++ b/mesonbuild/compilers/cpp.py
@@ -261,12 +261,15 @@ class IntelCPPCompiler(IntelCompiler, CPPCompiler):
'-Wpch-messages', '-Wnon-virtual-dtor']
self.warn_args = {'1': default_warn_args,
'2': default_warn_args + ['-Wextra'],
- '3': default_warn_args + ['-Wextra', '-Wpedantic']}
+ '3': default_warn_args + ['-Wextra']}
def get_options(self):
opts = CPPCompiler.get_options(self)
- c_stds = []
- g_stds = ['gnu++98']
+ # Every Unix compiler under the sun seems to accept -std=c++03,
+ # with the exception of ICC. Instead of preventing the user from
+ # globally requesting C++03, we transparently remap it to C++98
+ c_stds = ['c++98', 'c++03']
+ g_stds = ['gnu++98', 'gnu++03']
if version_compare(self.version, '>=15.0.0'):
c_stds += ['c++11', 'c++14']
g_stds += ['gnu++11']
@@ -286,7 +289,11 @@ class IntelCPPCompiler(IntelCompiler, CPPCompiler):
args = []
std = options['cpp_std']
if std.value != 'none':
- args.append('-std=' + std.value)
+ remap_cpp03 = {
+ 'c++03': 'c++98',
+ 'gnu++03': 'gnu++98'
+ }
+ args.append('-std=' + remap_cpp03.get(std.value, std.value))
if options['cpp_debugstl'].value:
args.append('-D_GLIBCXX_DEBUG=1')
return args
@@ -294,6 +301,10 @@ class IntelCPPCompiler(IntelCompiler, CPPCompiler):
def get_option_link_args(self, options):
return []
+ 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)
+
class VisualStudioCPPCompiler(VisualStudioCCompiler, CPPCompiler):
def __init__(self, exelist, version, is_cross, exe_wrap, is_64):
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index 81ba54c..a26787c 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -602,8 +602,13 @@ This is probably wrong, it should always point to the native compiler.''' % evar
cls = VisualStudioCCompiler if lang == 'c' else VisualStudioCPPCompiler
return cls(compiler, version, is_cross, exe_wrap, is_64)
if '(ICC)' in out:
- # TODO: add microsoft add check OSX
- compiler_type = CompilerType.ICC_STANDARD
+ if mesonlib.for_darwin(want_cross, self):
+ compiler_type = CompilerType.ICC_OSX
+ elif mesonlib.for_windows(want_cross, self):
+ # TODO: fix ICC on Windows
+ compiler_type = CompilerType.ICC_WIN
+ else:
+ compiler_type = CompilerType.ICC_STANDARD
cls = IntelCCompiler if lang == 'c' else IntelCPPCompiler
return cls(ccache + compiler, version, compiler_type, is_cross, exe_wrap, full_version=full_version)
if 'ARM' in out:
diff --git a/run_unittests.py b/run_unittests.py
index f8f6624..bd0103b 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -3472,7 +3472,11 @@ class LinuxlikeTests(BasePlatformTests):
std_opt = '{}={}'.format(lang_std, v)
self.init(testdir, ['-D' + std_opt])
cmd = self.get_compdb()[0]['command']
- if v != 'none':
+ # c++03 and gnu++03 are not understood by ICC, don't try to look for them
+ skiplist = frozenset([
+ ('intel', 'c++03'),
+ ('intel', 'gnu++03')])
+ if v != 'none' and not (compiler.get_id(), v) in skiplist:
cmd_std = " -std={} ".format(v)
self.assertIn(cmd_std, cmd)
try:
@@ -3683,23 +3687,26 @@ class LinuxlikeTests(BasePlatformTests):
testdir = os.path.join(self.unit_test_dir, '6 std override')
self.init(testdir)
compdb = self.get_compdb()
+ # Don't try to use -std=c++03 as a check for the
+ # presence of a compiler flag, as ICC does not
+ # support it.
for i in compdb:
- if 'prog03' in i['file']:
- c03_comp = i['command']
+ if 'prog98' in i['file']:
+ c98_comp = i['command']
if 'prog11' in i['file']:
c11_comp = i['command']
if 'progp' in i['file']:
plain_comp = i['command']
self.assertNotEqual(len(plain_comp), 0)
- self.assertIn('-std=c++03', c03_comp)
- self.assertNotIn('-std=c++11', c03_comp)
+ self.assertIn('-std=c++98', c98_comp)
+ self.assertNotIn('-std=c++11', c98_comp)
self.assertIn('-std=c++11', c11_comp)
- self.assertNotIn('-std=c++03', c11_comp)
- self.assertNotIn('-std=c++03', plain_comp)
+ self.assertNotIn('-std=c++98', c11_comp)
+ self.assertNotIn('-std=c++98', plain_comp)
self.assertNotIn('-std=c++11', plain_comp)
# Now werror
self.assertIn('-Werror', plain_comp)
- self.assertNotIn('-Werror', c03_comp)
+ self.assertNotIn('-Werror', c98_comp)
def test_run_installed(self):
if is_cygwin() or is_osx():
diff --git a/test cases/common/204 function attributes/meson.build b/test cases/common/204 function attributes/meson.build
index bc049d7..e46533f 100644
--- a/test cases/common/204 function attributes/meson.build
+++ b/test cases/common/204 function attributes/meson.build
@@ -50,9 +50,15 @@ attributes = [
'used',
'warn_unused_result',
'weak',
- 'weakref',
]
+if c.get_id() != 'intel'
+ # not supported by icc as of 19.0.0
+ attributes += 'weakref'
+endif
+
+expected_result = c.get_id() != 'msvc'
+
# These are unsupported on darwin with apple clang 9.1.0
if host_machine.system() != 'darwin'
attributes += 'alias'
diff --git a/test cases/unit/6 std override/meson.build b/test cases/unit/6 std override/meson.build
index ef2baac..0eac752 100644
--- a/test cases/unit/6 std override/meson.build
+++ b/test cases/unit/6 std override/meson.build
@@ -1,10 +1,10 @@
project('cpp std override', 'cpp',
- default_options : ['cpp_std=c++03',
+ default_options : ['cpp_std=c++98',
'werror=true'])
executable('plain', 'progp.cpp',
override_options : 'cpp_std=none')
-executable('v03', 'prog03.cpp',
+executable('v98', 'prog98.cpp',
override_options : 'werror=false')
executable('v11', 'prog11.cpp',
override_options : 'cpp_std=c++11')
diff --git a/test cases/unit/6 std override/prog03.cpp b/test cases/unit/6 std override/prog98.cpp
index d30abc9..67c326d 100644
--- a/test cases/unit/6 std override/prog03.cpp
+++ b/test cases/unit/6 std override/prog98.cpp
@@ -1,6 +1,6 @@
#include<iostream>
int main(int argc, char **argv) {
- std::cout << "I am a c++03 test program.\n";
+ std::cout << "I am a c++98 test program.\n";
return 0;
}