Skip to content

Commit

Permalink
Prefer Clang over GCC for Objective-C(++)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Midar and tristan957 committed Apr 23, 2024
1 parent bf00ca6 commit de4de65
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/cygwin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ jobs:
with:
platform: ${{ matrix.ARCH }}
packages: |
clang
cmake
gcc-fortran
gcc-objc++
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/msys2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions mesonbuild/compilers/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand All @@ -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']
Expand Down
5 changes: 5 additions & 0 deletions test cases/cmake/24 mixing languages/test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"env": {
"CC": "clang"
}
}

0 comments on commit de4de65

Please sign in to comment.