Prefer Clang over GCC for Objective-C(++)

GCC only has very limited support for Objective-C and doesn't support
any of the modern features, so whenever Clang is available, it should be
used instead. Essentially, the only reason to ever use GCC for
Objective-C is that Clang simply does not support the target system.
pull/13157/head
Jonathan Schleifer 8 months ago committed by Eli Schwartz
parent c9aa4aff66
commit 205f09e1b0
  1. 9
      mesonbuild/compilers/detect.py
  2. 5
      test cases/cmake/24 mixing languages/meson.build

@ -46,9 +46,8 @@ if is_windows():
# There is currently no pgc++ for Windows, only for Mac and Linux. # There is currently no pgc++ for Windows, only for Mac and Linux.
defaults['cpp'] = ['icl', 'cl', 'c++', 'g++', 'clang++', 'clang-cl'] defaults['cpp'] = ['icl', 'cl', 'c++', 'g++', 'clang++', 'clang-cl']
defaults['fortran'] = ['ifort', 'gfortran', 'flang', 'pgfortran', 'g95'] defaults['fortran'] = ['ifort', 'gfortran', 'flang', 'pgfortran', 'g95']
# Clang and clang++ are valid, but currently unsupported. defaults['objc'] = ['clang-cl', 'gcc']
defaults['objc'] = ['cc', 'gcc'] defaults['objcpp'] = ['clang-cl', 'g++']
defaults['objcpp'] = ['c++', 'g++']
defaults['cs'] = ['csc', 'mcs'] defaults['cs'] = ['csc', 'mcs']
else: else:
if platform.machine().lower() == 'e2k': if platform.machine().lower() == 'e2k':
@ -59,8 +58,8 @@ else:
else: else:
defaults['c'] = ['cc', 'gcc', 'clang', 'nvc', 'pgcc', 'icc', 'icx'] defaults['c'] = ['cc', 'gcc', 'clang', 'nvc', 'pgcc', 'icc', 'icx']
defaults['cpp'] = ['c++', 'g++', 'clang++', 'nvc++', 'pgc++', 'icpc', 'icpx'] defaults['cpp'] = ['c++', 'g++', 'clang++', 'nvc++', 'pgc++', 'icpc', 'icpx']
defaults['objc'] = ['cc', 'gcc', 'clang'] defaults['objc'] = ['clang', 'gcc']
defaults['objcpp'] = ['c++', 'g++', 'clang++'] defaults['objcpp'] = ['clang++', 'g++']
defaults['fortran'] = ['gfortran', 'flang', 'nvfortran', 'pgfortran', 'ifort', 'ifx', 'g95'] defaults['fortran'] = ['gfortran', 'flang', 'nvfortran', 'pgfortran', 'ifort', 'ifx', 'g95']
defaults['cs'] = ['mcs', 'csc'] defaults['cs'] = ['mcs', 'csc']
defaults['d'] = ['ldc2', 'ldc', 'gdc', 'dmd'] defaults['d'] = ['ldc2', 'ldc', 'gdc', 'dmd']

@ -1,4 +1,7 @@
project('CMake mix', ['c', 'cpp']) # Explicitly require PIE so that mixing compilers with different defaults for
# whether to use PIE works.
project('CMake mix', ['c', 'cpp'],
default_options: ['b_pie=true'])
if not add_languages('objc', required : false) if not add_languages('objc', required : false)
error('MESON_SKIP_TEST: No ObjC compiler') error('MESON_SKIP_TEST: No ObjC compiler')

Loading…
Cancel
Save