Hi,

The AC_PROG_OBJC macro does not work out-of-the-box on RHEL 9, AlmaLinux 9,
etc. because on these systems, the /usr/bin/gcc program does not support
Objective-C [1]. There is a package in EPEL 9 (the "community"-driven
package repository for RHEL-based distributions) that contains the GNU
Objective-C compiler [2] (provided by Robert Scheck [3]), under the name
/usr/bin/gobjc.

However, this is still not sufficient for packages that invoke AC_PROG_OBJC
without arguments, because the configure script will find the 'gcc' program
(from its list of tries: gcc objcc objc cc CC clang), and the gcc program
does not support Objective-C even after the EPEL 9 package is installed.

Two workarounds are possible:

  a) The package maintainer can use
       AC_PROG_OBJC([gobjc gcc objcc objc cc CC clang])
     instead of
       AC_PROG_OBJC

  b) The user can set the OBJC environment variable to 'gobjc'
     before running configure.

However, it would be better if this worked out-of-the-box,
because RHEL 9 and compatible systems are not just some random
system like Haiku or AIX; these distros are some of the most
important distributions of GNU systems.

Find attached a proposed patch that makes this work out-of-the-box.

  Bruno

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1826731
[2] https://packages.fedoraproject.org/pkgs/gcc-epel/gcc-objc/
[3] https://fedoraproject.org/wiki/User:Robert

>From e19f43b9bdefd8547d9056ae99de3e20e311e1e4 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Tue, 16 Jul 2024 04:59:23 +0200
Subject: [PATCH] Make AC_PROG_OBJC work out-of-the-box on RHEL 9 and
 compatible systems.

* lib/autoconf/c.m4 (AC_PROG_OBJC): Search for gobjc before gcc.
* NEWS: Mention the change.
---
 NEWS              |  3 +++
 lib/autoconf/c.m4 | 13 ++++++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/NEWS b/NEWS
index bca11391..e0d35099 100644
--- a/NEWS
+++ b/NEWS
@@ -28,6 +28,9 @@ GNU Autoconf NEWS - User visible changes.
   The autom4te, autoscan and ifnames programs now recognize the two
   preprocessor directives, which were introduced in C23 and C++23.
 
+*** AC_PROG_OBJC now finds the GNU Objective-C compiler, as packaged in
+  EPEL 9, by default, without the user having to set the OBJC variable.
+
 * Noteworthy changes in release 2.72 (2023-12-22) [release]
 
 ** Backward incompatibilities
diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4
index 456a6ba7..1727961e 100644
--- a/lib/autoconf/c.m4
+++ b/lib/autoconf/c.m4
@@ -854,10 +854,13 @@ AC_DEFUN([AC_LANG_COMPILER(Objective C)],
 # search for (if not specified, a default list is used).  This just gives
 # the user an opportunity to specify an alternative search list for the
 # Objective C compiler.
-# objcc StepStone Objective-C compiler (also "standard" name for OBJC)
-# objc  David Stes' POC.  If you installed this, you likely want it.
-# cc    Native C compiler (for instance, Apple).
-# CC    You never know.
+# gobjc  GNU Objective-C compiler packaged in EPEL (for systems where gcc
+#        does not support Objective-C)
+# gcc    GNU Objective-C compiler on most systems
+# objcc  StepStone Objective-C compiler (also "standard" name for OBJC)
+# objc   David Stes' POC.  If you installed this, you likely want it.
+# cc     Native C compiler (for instance, Apple).
+# CC     You never know.
 AN_MAKEVAR([OBJC],  [AC_PROG_OBJC])
 AN_PROGRAM([objcc],  [AC_PROG_OBJC])
 AN_PROGRAM([objc],  [AC_PROG_OBJC])
@@ -870,7 +873,7 @@ _AC_ARG_VAR_LIBS()dnl
 _AC_ARG_VAR_CPPFLAGS()dnl
 _AC_ARG_VAR_PRECIOUS([OBJC])dnl
 AC_CHECK_TOOLS(OBJC,
-	       [m4_default([$1], [gcc objcc objc cc CC clang])],
+	       [m4_default([$1], [gobjc gcc objcc objc cc CC clang])],
 	       gcc)
 # Provide some information about the compiler.
 _AS_ECHO_LOG([checking for _AC_LANG compiler version])
-- 
2.34.1

Reply via email to