meson icon indicating copy to clipboard operation
meson copied to clipboard

Support lists for ObjC and ObjC++ standards

Open dcbaker opened this issue 1 year ago • 3 comments

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

dcbaker avatar Sep 06 '24 17:09 dcbaker

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.

dcbaker avatar Sep 06 '24 17:09 dcbaker

Should there be a test for that, to ensure every compiler supports the same syntax for std option?

bruchar1 avatar Sep 06 '24 19:09 bruchar1

It was worth writing the tests, I found some issues that weren't being caught by our existing tests.

dcbaker avatar Sep 12 '24 16:09 dcbaker

Also in the latest version, use mixins for the Apple version overrides

dcbaker avatar Sep 25 '24 16:09 dcbaker

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 avatar Sep 25 '24 18:09 bgilbert

@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.

dcbaker avatar Sep 25 '24 19:09 dcbaker

The lint error comes from minstall.py, which is not edited at all in this patchset, so it is unrelated.

jpakkane avatar Jan 28 '25 21:01 jpakkane

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 avatar May 28 '25 23:05 yselkowitz

@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.

dcbaker avatar May 29 '25 15:05 dcbaker

Yes, see https://github.com/mesonbuild/meson/issues/14579

eli-schwartz avatar May 29 '25 16:05 eli-schwartz