meson
meson copied to clipboard
Support lists for ObjC and ObjC++ standards
Also, share the implementations between the C and ObjC, and C++ and OjbC++ instance of both Clang and GNU compilers, so that we update once, and only once for each compiler.
Mostly this just ends up moving code around.
Fixes: #13639
I have tested this with Clang and with GCC, but only far enough with GCC to get to the point it fails because my GCC build doesn't have ObjC[++] support.
Should there be a test for that, to ensure every compiler supports the same syntax for std option?
It was worth writing the tests, I found some issues that weren't being caught by our existing tests.
Also in the latest version, use mixins for the Apple version overrides
xref https://github.com/mesonbuild/meson/issues/13713: it'd be good to produce a future-feature warning if ObjC is used with a list of standards. Otherwise projects might be surprised e.g. if they use Objective C on macOS, don't CI on macOS with older Meson, and switch to c_std=gnuXX,cXX. (I tripped over this in glib, and CI caught it only because this PR hasn't shipped.)
@bgilbert given that this series is already up to 13 patches and is fixing tons of issues with ObjC, I'd prefer to handle that separately, but I assigned that to myself and I'll have a look it at.
The lint error comes from minstall.py, which is not edited at all in this patchset, so it is unrelated.
Would it make sense that this is causing a test failure as of 1.8.0 on RHEL-like platforms, where gcc is the default compiler but ObjC is not enabled:
ERROR: test_compiler_detection (unittests.allplatformstests.AllPlatformTests.test_compiler_detection)
Test that automatic compiler detection and setting from the environment
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib64/python3.13/unittest/mock.py", line 1891, in _inner
return f(*args, **kw)
File "/builddir/build/BUILD/meson-1.8.1-build/meson-1.8.1/unittests/allplatformstests.py", line 1130, in test_compiler_detection
cc = compiler_from_language(env, lang, MachineChoice.HOST)
File "/builddir/build/BUILD/meson-1.8.1-build/meson-1.8.1/mesonbuild/compilers/detect.py", line 103, in compiler_from_language
return lang_map[lang](env, for_machine) if lang in lang_map else None
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
File "/builddir/build/BUILD/meson-1.8.1-build/meson-1.8.1/mesonbuild/compilers/detect.py", line 871, in detect_objc_compiler
return _detect_objc_or_objcpp_compiler(env, 'objc', for_machine)
File "/builddir/build/BUILD/meson-1.8.1-build/meson-1.8.1/mesonbuild/compilers/detect.py", line 929, in _detect_objc_or_objcpp_compiler
_handle_exceptions(popen_exceptions, compilers)
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/builddir/build/BUILD/meson-1.8.1-build/meson-1.8.1/mesonbuild/compilers/detect.py", line 150, in _handle_exceptions
raise EnvironmentException(errmsg)
mesonbuild.utils.universal.EnvironmentException: Unknown compiler(s): [['clang'], ['gcc']]
The following exception(s) were encountered:
Running `clang --version` gave "[Errno 2] No such file or directory: 'clang'"
Running `gcc` gave "GCC was not built with support for objective-c"
@yselkowitz yes, specifically the last patch adds a check for gcc to see if it was built with objective-c support and to reject it it can't compile a basic test binary.
I tried to catch all of the cases where we could run into this and return a skip, but clearly one was missed. We should fix that.
Yes, see https://github.com/mesonbuild/meson/issues/14579