Subject: bug#57015: 29.0.50; macOS: libgccjit was not found: Homebrew libgccjit 12.1.0

From: Naofumi Yasufuku <[email-masked]>
Date: Sun, 07 Aug 2022 01:36:39 +0900

Naofumi Yasufuku <[email-masked]> writes:
[,,snip..]
> +          MAC_LIBS="-L$(dirname $($BREW ls -v libgccjit | \
> +                                  grep -E 'current/libgccjit\.(so|dylib)$' | \
> +                                  head -1))"
> +          if test "${MAC_LIBS}" = "-L"; then
> +            # Try for Homebrew libgccjit < 12.1.0.
> +            MAC_LIBS="-L$(dirname $($BREW ls -v libgccjit | \
> +                                    grep -E 'libgccjit\.(so|dylib)$' | \
> +                                    head -1))"

"x" is added for "${MAC_LIBS}" test, just in case.  Revised patch is
attached.  I also attach emacs-28 config.log's against both
homebrew libgccjit-12.1.0 and libgccjit-11.3.0.

>From cf149557e6d3722671d3acb90d2e9776b833eb5d Mon Sep 17 00:00:00 2001
From: Naofumi Yasufuku <[email-masked]>
Date: Sat, 6 Aug 2022 22:10:36 +0900
Subject: [PATCH] Fix libgccjit library path lookup for Homebrew libgccjit
 12.1.0 and above

* configure.ac: Choose the first match from multiple libgccjit.dylib
paths in 'brew ls -v libgccjit' output.  Prefer 'current/libgccjit.dylib'
over '${ver}/libgccjit.dylib'  (Bug#57015)
---
 configure.ac | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 57b86e8542..4636426443 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3843,8 +3843,15 @@ AC_DEFUN
         if test -n "`$BREW --prefix --installed libgccjit 2>/dev/null`"; then
           MAC_CFLAGS="-I$(dirname $($BREW ls -v libgccjit | \
                                                 grep libgccjit.h))"
-          MAC_LIBS="-L$(dirname $($BREW ls -v libgccjit| \
-                                            grep -E 'libgccjit\.(so|dylib)$'))"
+          MAC_LIBS="-L$(dirname $($BREW ls -v libgccjit | \
+                                  grep -E 'current/libgccjit\.(so|dylib)$' | \
+                                  head -1))"
+          if test "x${MAC_LIBS}" = "x-L"; then
+            # Try for Homebrew libgccjit < 12.1.0.
+            MAC_LIBS="-L$(dirname $($BREW ls -v libgccjit | \
+                                    grep -E 'libgccjit\.(so|dylib)$' | \
+                                    head -1))"
+          fi
         fi
       fi
 
-- 
2.37.1

Regards,
  Naofumi