From de4de65f9725039f1d4c60bce61740d481cfe07c Mon Sep 17 00:00:00 2001 From: Jonathan Schleifer Date: Thu, 11 Apr 2024 01:44:58 +0200 Subject: [PATCH] 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. This also sets CC=clang for "test cases/cmake/24 mixing languages/test.json" as openSUSE's GCC defaults to no PIE while openSUSE's Clang defaults to PIE, which makes the test fail if OBJC=clang and CC=gcc. Co-authored-by: Tristan Partin --- .github/workflows/cygwin.yml | 1 + .github/workflows/msys2.yml | 1 + mesonbuild/compilers/detect.py | 9 ++++----- test cases/cmake/24 mixing languages/test.json | 5 +++++ 4 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 test cases/cmake/24 mixing languages/test.json diff --git a/.github/workflows/cygwin.yml b/.github/workflows/cygwin.yml index c6f3dc416687..8dfedd3c67ba 100644 --- a/.github/workflows/cygwin.yml +++ b/.github/workflows/cygwin.yml @@ -55,6 +55,7 @@ jobs: with: platform: ${{ matrix.ARCH }} packages: | + clang cmake gcc-fortran gcc-objc++ diff --git a/.github/workflows/msys2.yml b/.github/workflows/msys2.yml index fe28a67edbad..cf92f2bc6e80 100644 --- a/.github/workflows/msys2.yml +++ b/.github/workflows/msys2.yml @@ -74,6 +74,7 @@ jobs: lcov wget unzip + mingw-w64-${{ matrix.MSYS2_ARCH }}-clang mingw-w64-${{ matrix.MSYS2_ARCH }}-cmake mingw-w64-${{ matrix.MSYS2_ARCH }}-glib2 mingw-w64-${{ matrix.MSYS2_ARCH }}-libxml2 diff --git a/mesonbuild/compilers/detect.py b/mesonbuild/compilers/detect.py index aed03391889d..53d40def42d7 100644 --- a/mesonbuild/compilers/detect.py +++ b/mesonbuild/compilers/detect.py @@ -46,9 +46,8 @@ # There is currently no pgc++ for Windows, only for Mac and Linux. defaults['cpp'] = ['icl', 'cl', 'c++', 'g++', 'clang++', 'clang-cl'] defaults['fortran'] = ['ifort', 'gfortran', 'flang', 'pgfortran', 'g95'] - # Clang and clang++ are valid, but currently unsupported. - defaults['objc'] = ['cc', 'gcc'] - defaults['objcpp'] = ['c++', 'g++'] + defaults['objc'] = ['clang-cl', 'gcc'] + defaults['objcpp'] = ['clang-cl', 'g++'] defaults['cs'] = ['csc', 'mcs'] else: if platform.machine().lower() == 'e2k': @@ -59,8 +58,8 @@ else: defaults['c'] = ['cc', 'gcc', 'clang', 'nvc', 'pgcc', 'icc', 'icx'] defaults['cpp'] = ['c++', 'g++', 'clang++', 'nvc++', 'pgc++', 'icpc', 'icpx'] - defaults['objc'] = ['cc', 'gcc', 'clang'] - defaults['objcpp'] = ['c++', 'g++', 'clang++'] + defaults['objc'] = ['clang', 'gcc'] + defaults['objcpp'] = ['clang++', 'g++'] defaults['fortran'] = ['gfortran', 'flang', 'nvfortran', 'pgfortran', 'ifort', 'ifx', 'g95'] defaults['cs'] = ['mcs', 'csc'] defaults['d'] = ['ldc2', 'ldc', 'gdc', 'dmd'] diff --git a/test cases/cmake/24 mixing languages/test.json b/test cases/cmake/24 mixing languages/test.json new file mode 100644 index 000000000000..501fcfe8c113 --- /dev/null +++ b/test cases/cmake/24 mixing languages/test.json @@ -0,0 +1,5 @@ +{ + "env": { + "CC": "clang" + } +}