unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Third <alan@idiocy.org>
To: Jean-Christophe Helary <lists@traduction-libre.org>
Cc: Emacs Devel <emacs-devel@gnu.org>
Subject: Re: ./configure --with-native-compilation on macos (11.5.2 Big Sur)
Date: Fri, 10 Sep 2021 21:53:52 +0100	[thread overview]
Message-ID: <YTvF4OKV5fWwmpV7@idiocy.org> (raw)
In-Reply-To: <4921CF13-07A1-48B2-8115-E74428B4020B@traduction-libre.org>

[-- Attachment #1: Type: text/plain, Size: 877 bytes --]

On Fri, Sep 10, 2021 at 09:35:02AM +0900, Jean-Christophe Helary wrote:
> 
> 
> > On Sep 10, 2021, at 6:07, Alan Third <alan@idiocy.org> wrote:
> > 
> > On Thu, Sep 09, 2021 at 08:44:47AM +0900, Jean-Christophe Helary wrote:
> >> 
> >> And the third version of the patch you sent produced the same error... :(
> >> 
> >> I have just totally removed brew and macports to remove all the
> >> cruft and reinstalled only the packages that I needed (and their
> >> dependencies).
> > 
> > What about running
> > 
> >    HAVE_MACPORTS="" ./configure
> > 
> > ?
> > 
> > I have no idea if that will work.
> 
> It did.
> 
> :-)

OK, at least we have a work-around.

Can you try the attached patch. I noticed what I think is a mistake in
setting up CFLAGS and LIBS for libgccjit, not just in macOS but
generally, so I've fixed that and tidied the rest of the macOS code.
-- 
Alan Third

[-- Attachment #2: 0001-Fix-libgccjit-detection-on-macOS.patch --]
[-- Type: text/x-diff, Size: 4552 bytes --]

From 3424621a2076b6cea03fa4a411168aa99ff60a06 Mon Sep 17 00:00:00 2001
From: Alan Third <alan@idiocy.org>
Date: Thu, 9 Sep 2021 22:33:01 +0100
Subject: [PATCH] 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 418a62fd5e..1146b581cd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3822,40 +3822,44 @@ AC_DEFUN
        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 @@ AC_DEFUN
       # 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])
-- 
2.30.2


  reply	other threads:[~2021-09-10 20:53 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-15  6:10 ./configure --with-native-compilation on macos (11.5.2 Big Sur) Jean-Christophe Helary
2021-08-16 17:18 ` Alan Third
2021-08-17  0:59   ` Jean-Christophe Helary
2021-08-17  1:02     ` Jean-Christophe Helary
2021-08-17 19:45     ` Alan Third
2021-08-20  6:29       ` Jean-Christophe Helary
2021-08-21  4:43         ` Jean-Christophe Helary
2021-08-21  9:47           ` Alan Third
2021-09-05 13:07             ` Alan Third
2021-09-05 13:22               ` Jean-Christophe Helary
2021-09-06  3:24                 ` Alan Third
2021-09-06  3:46                   ` Jean-Christophe Helary
2021-09-06  6:27                     ` Jean-Christophe Helary
2021-09-06  6:43                       ` Jean-Christophe Helary
2021-09-06  7:10                         ` Jean-Christophe Helary
2021-09-06  7:34                           ` Stefan Kangas
2021-09-06  7:38                             ` Jean-Christophe Helary
2021-09-06  7:52                               ` Stefan Kangas
2021-09-06 10:33                         ` Eli Zaretskii
2021-09-06 12:12                           ` Jean-Christophe Helary
2021-09-06 12:34                             ` Eli Zaretskii
2021-09-06  9:45                       ` Jean-Christophe Helary
2021-09-06 20:01                         ` Alan Third
2021-09-06 23:50                           ` Jean-Christophe Helary
2021-09-13 22:55                             ` Jean-Christophe Helary
2021-09-08  7:34                           ` Lars Ingebrigtsen
2021-09-08 15:31                         ` Alan Third
2021-09-08 20:59                           ` Alan Third
2021-09-08 21:15                             ` Alan Third
2021-09-08 23:44                           ` Jean-Christophe Helary
2021-09-09 21:07                             ` Alan Third
2021-09-10  0:35                               ` Jean-Christophe Helary
2021-09-10 20:53                                 ` Alan Third [this message]
2021-09-11  5:54                                   ` Eli Zaretskii
2021-09-11  0:30                               ` Jean-Christophe Helary
2021-09-11 16:17                                 ` Alan Third
2021-09-12  8:47                                   ` Jean-Christophe Helary
2021-09-12 11:59                                     ` Alan Third
2021-09-13 12:06                                       ` Jean-Christophe Helary
2021-09-13 18:19                                         ` Alan Third
2021-09-13 18:42                                           ` Alan Third
2021-09-13 22:04                                             ` Jean-Christophe Helary
2021-09-13 22:08                                               ` Alan Third
2021-09-13 22:24                                                 ` Jean-Christophe Helary
2021-09-13 22:56                                                   ` Jean-Christophe Helary
2021-09-14 15:22                                           ` Alan Third
2021-09-14 17:10                                             ` Jean-Christophe Helary

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YTvF4OKV5fWwmpV7@idiocy.org \
    --to=alan@idiocy.org \
    --cc=emacs-devel@gnu.org \
    --cc=lists@traduction-libre.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).