Bug 258001

Summary: editors/emacs-devel: Build fails at configure phase with non-clean environment and NATIVECOMP option enabled
Product: Ports & Packages Reporter: Yasuhiro Kimura <yasu>
Component: Individual Port(s)Assignee: emacs (Nobody) <emacs>
Status: Closed FIXED    
Severity: Affects Only Me CC: ashish, jrm
Priority: --- Flags: ashish: maintainer-feedback+
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Patch file
none
Updated patch file none

Description Yasuhiro Kimura freebsd_committer freebsd_triage 2021-08-23 07:25:49 UTC
Build of this port fails at configure phase as following if (1) ports-mgmt/porttools is installed in build environment and (2) NATIVECOMP option is ON.

----------------------------------------------------------------------
checking for getpagesize... (cached) yes
checking for working mmap... (cached) yes
checking for main in -lXbsd... no
checking for pthread library... -lpthread
checking for thread support... yes
checking for getaddrinfo_a in -lanl... no
checking for gnutls >= 2.12.2... yes
checking for jansson >= 2.7... yes
checking for libkqueue... no
checking for library containing kqueue... none required
checking for library containing inflateEnd... -lz
checking for dlopen... (cached) yes
checking for dladdr... yes
checking for dlfunc... yes
usage: dirname string [...]
usage: dirname string [...]
checking for gcc_jit_context_acquire in -lgccjit... no
configure: error: ELisp native compiler was requested, but libgccjit was not found.
Please try installing libgccjit or a similar package.
If you are sure you want Emacs be compiled without ELisp native compiler,
pass the --without-native-compilation option to configure.
===>  Script "configure" failed unexpectedly.
Please report the problem to emacs@FreeBSD.org [maintainer] and attach the
"/wrkdirs/usr/ports/editors/emacs-devel/work-nox/emacs-3572613/config.log"
including the output of the failure of your make command. Also, it might be
a good idea to provide an overview of all packages installed on your system
(e.g. a /usr/local/sbin/pkg-static info -g -Ea).
*** Error code 1

Stop.
make: stopped in /usr/ports/editors/emacs-devel
----------------------------------------------------------------------

Full build log: https://www.utahime.org/FreeBSD/poudriere/data/logs/bulk/130amd64-default-emacs/2021-08-23_13h20m28s/logs/emacs-devel-nox-28.0.50.20210815,2.log

Note that in order to reproduce the build error with poudriere /usr/ports/editors/emacs-devel/Makefile is modified so ports-mgmt/porttools is added to BUILD_DEPENDS.
Comment 1 Ashish SHUKLA freebsd_committer freebsd_triage 2021-08-23 15:32:18 UTC
Thanks for reporting it. I'm able to reproduce it.

From my preliminary analysis of the problem, excerpt from the config.log:

configure:16368: checking for gcc_jit_context_acquire in -lgccjit
configure:16393: cc -o conftest -pipe  -g -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing  -I   -isystem /usr/local/include  -L/usr/local/lib/gcc11 -Wl,-rpath=/usr/local/lib -fstack-protector-strong -L/usr/local/lib  -L conftest.c -lgccjit  -lutil  >&5
ld: error: cannot open /usr/local/include: Is a directory
cc: error: linker command failed with exit code 1 (use -v to see invocation)
configure:16393: $? = 1
configure: failed program was:
| /* confdefs.h */


It seems like "-I -isystem" is the culprit here, need to figure out where it's coming from. I'll follow up later with.

Thanks!
Comment 2 Yasuhiro Kimura freebsd_committer freebsd_triage 2021-08-24 03:53:57 UTC
Created attachment 227396 [details]
Patch file

Now I think I know what is happening. ports-mgmt/porttools installs shell script named `port`. But configure script of emacs regards it as utility used to interact with MacPorts[1]. And it sets up CFLAGS, header directories, library directory, etc. assuming that environment is MacOS and GCC is installed by using MacPorts. As a result configure fails to detect libgccjit. Attached patch fixes it by patching configure.ac.

[1] https://guide.macports.org/#using.port
Comment 3 Yasuhiro Kimura freebsd_committer freebsd_triage 2021-08-24 07:57:52 UTC
Created attachment 227397 [details]
Updated patch file

* Improve patch so it can be upstreamed.

Original version only comments out the detection of 'port' command in configure.ac. So it doesn't work as is expected on MacOS and MacPorts environment and therefore can't be upstreamed. Updated version changes configure.ac so it tries to detect 'port' command only if $opsys is 'darwin'. So it can be upstreamed as it can not only fix our problem but also works fine on MacOS and MacPorts environment.
Comment 4 Ashish SHUKLA freebsd_committer freebsd_triage 2021-08-26 15:50:01 UTC
(In reply to Yasuhiro Kimura from comment #3)

The attached patch works for me.

We've an update scheduled for September 01, 2021, and we'll include this patch then. Could you please submit it upstream, and link us here ?

Thank you!
Comment 5 Yasuhiro Kimura freebsd_committer freebsd_triage 2021-08-29 22:59:54 UTC
(In reply to Ashish SHUKLA from comment #4)

> Could you please submit it upstream, and link us here ?

I have submitted to upstream as following.

https://debbugs.gnu.org/cgi/bugreport.cgi?bug=50259
Comment 6 Joseph Mingrone freebsd_committer freebsd_triage 2021-08-29 23:54:33 UTC
Great.  Looks like it will get pulled from upstream in the 2021-09-01 port update.

Thanks.
Comment 7 commit-hook freebsd_committer freebsd_triage 2021-09-01 23:00:38 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=76a124ab0b40e1a20689431f28e70d19a376cc29

commit 76a124ab0b40e1a20689431f28e70d19a376cc29
Author:     Joseph Mingrone <jrm@FreeBSD.org>
AuthorDate: 2021-09-01 22:56:57 +0000
Commit:     Joseph Mingrone <jrm@FreeBSD.org>
CommitDate: 2021-09-01 22:59:35 +0000

    editors/emacs-devel: Update to 2021-09-21 commit, a15f549

    PR:             258001

 editors/emacs-devel/Makefile  | 4 ++--
 editors/emacs-devel/distinfo  | 6 +++---
 editors/emacs-devel/pkg-plist | 7 ++++---
 3 files changed, 9 insertions(+), 8 deletions(-)
Comment 8 Joseph Mingrone freebsd_committer freebsd_triage 2021-09-01 23:01:28 UTC
Thanks for submitting and upstreaming.  Please re-open if the issue isn't resolved.