emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 443d37f 1/2: Fix libgccjit detection on macOS


From: Alan Third
Subject: master 443d37f 1/2: Fix libgccjit detection on macOS
Date: Tue, 14 Sep 2021 05:12:17 -0400 (EDT)

branch: master
commit 443d37ff213ec31c8450a9cce36a7c44ac63945b
Author: Alan Third <alan@idiocy.org>
Commit: Alan Third <alan@idiocy.org>

    Fix libgccjit detection on macOS
    
    * configure.ac: Combine the Homebrew and MacPorts detection so they
    will not create nonsense flags if both are installed.
---
 configure.ac | 64 ++++++++++++++++++++++++++++++++----------------------------
 1 file changed, 34 insertions(+), 30 deletions(-)

diff --git a/configure.ac b/configure.ac
index 418a62f..1146b58 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3822,40 +3822,44 @@ if test "${with_native_compilation}" != "no"; then
        AC_MSG_ERROR(['--with-native-compilation' requires zlib])
     fi
 
-    # Ensure libgccjit installed by Homebrew can be found.
-    if test -n "$BREW"; then
-      if test -n "`$BREW --prefix --installed libgccjit 2>/dev/null`"; then
-        BREW_LIBGCCJIT_INCLUDE=$(dirname $($BREW ls -v libgccjit | \
-                                              grep libgccjit.h))
-        BREW_LIBGCCJIT_LIB=$(dirname $($BREW ls -v libgccjit| \
-                                          grep libgccjit.so\$))
-        CFLAGS="$CFLAGS -I${BREW_LIBGCCJIT_INCLUDE}"
-        LDFLAGS="$LDFLAGS -L${BREW_LIBGCCJIT_LIB}"
+    SAVE_CFLAGS=$CFLAGS
+    SAVE_LIBS=$LIBS
+
+    if test "${opsys}" = "darwin"; then
+      # Ensure libgccjit installed by Homebrew or macports can be found.
+      if test -n "$BREW"; then
+        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 libgccjit.so\$))"
+        fi
       fi
-    fi
 
-    # Ensure libgccjit installed by MacPorts can be found.
-    if test -n "$HAVE_MACPORTS"; then
-      # Determine which gcc version has been installed (gcc11, for
-      # instance).
-      PORT_PACKAGE=$(port installed active | grep '^ *gcc@<:@0-9@:>@* ' | \
-                          awk '{ print $1; }')
-      MACPORTS_LIBGCCJIT_INCLUDE=$(dirname $(port contents $PORT_PACKAGE | \
-                                           grep libgccjit.h))
-      MACPORTS_LIBGCCJIT_LIB=$(dirname $(port contents $PORT_PACKAGE | \
-                                              grep libgccjit.dylib))
-      CFLAGS="$CFLAGS -I${MACPORTS_LIBGCCJIT_INCLUDE}"
-      LDFLAGS="$LDFLAGS -L${MACPORTS_LIBGCCJIT_LIB}"
+      if test -n "$HAVE_MACPORTS"; then
+        # Determine which gcc version has been installed (gcc11, for
+        # instance).
+        PORT_PACKAGE=$(port installed active | grep '^ *gcc@<:@0-9@:>@* ' | \
+                            awk '{ print $1; }')
+        if test -n "$PORT_PACKAGE"; then
+          MAC_CFLAGS="-I$(dirname $(port contents $PORT_PACKAGE | \
+                                           grep libgccjit.h))"
+          MAC_LIBS="-L$(dirname $(port contents $PORT_PACKAGE | \
+                                              grep libgccjit.dylib))"
+        fi
+      fi
+
+      if test -n "$MAC_CFLAGS" && test -n "$MAC_LIBS"; then
+        CFLAGS="$CFLAGS ${MAC_CFLAGS}"
+        LIBS="$LIBS ${MAC_LIBS}"
+      fi
     fi
 
     # Check if libgccjit is available.
     AC_CHECK_LIB(gccjit, gcc_jit_context_acquire, [], [libgccjit_not_found])
     AC_CHECK_HEADERS(libgccjit.h, [], [libgccjit_dev_not_found])
-    emacs_save_LIBS=$LIBS
-    LIBS="-lgccjit"
     # Check if libgccjit really works.
     AC_RUN_IFELSE([libgccjit_smoke_test], [], [libgccjit_broken])
-    LIBS=$emacs_save_LIBS
     HAVE_NATIVE_COMP=yes
     case "${opsys}" in
       # mingw32 loads the library dynamically.
@@ -3863,17 +3867,17 @@ if test "${with_native_compilation}" != "no"; then
       # OpenBSD doesn't have libdl, all the functions are in libc
       netbsd|openbsd)
         LIBGCCJIT_LIBS="-lgccjit" ;;
+      darwin)
+        LIBGCCJIT_CFLAGS="${MAC_CFLAGS}"
+        LIBGCCJIT_LIBS="${MAC_LIBS} -lgccjit -ldl";;
       *)
         LIBGCCJIT_LIBS="-lgccjit -ldl" ;;
     esac
     NEED_DYNLIB=yes
     AC_DEFINE(HAVE_NATIVE_COMP, 1, [Define to 1 if native compiler is 
available.])
 
-    # Ensure libgccjit installed by MacPorts can be found.
-    if test -n "$HAVE_MACPORTS"; then
-      LIBGCCJIT_CFLAGS="$LIBGCCJIT_CFLAGS  -I${MACPORTS_LIBGCCJIT_INCLUDE}"
-      LIBGCCJIT_LIBS="-L${MACPORTS_LIBGCCJIT_LIB} $LIBGCCJIT_LIBS"
-    fi
+    CFLAGS=$SAVE_CFLAGS
+    LIBS=$SAVE_LIBS
 fi
 AC_DEFINE_UNQUOTED(NATIVE_ELISP_SUFFIX, ".eln",
   [System extension for native compiled elisp])



reply via email to

[Prev in Thread] Current Thread [Next in Thread]