Bug 2338605

Summary: emacs: FTBFS with GCC 15
Product: [Fedora] Fedora Reporter: Peter Oliver <mavit>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: dan.cermak, dmalcolm, fweimer, jakub, jlaw, josmyers, jwakely, mcermak, mpolacek, msebor, nickc, nixuser, releng, sipoyare
Target Milestone: ---   
Target Release: ---   
Hardware: aarch64   
OS: Unspecified   
URL: https://koschei.fedoraproject.org/package/emacs
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2025-01-28 11:56:41 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2300528    
Attachments:
Description Flags
build.log, s390x
none
build.log, ppc64le none

Description Peter Oliver 2025-01-17 13:32:59 UTC
Created attachment 2066456 [details]
build.log, s390x

Description of problem:
Package emacs fails to build from source with GCC 15 on most platforms.  

Version-Release number of selected component (if applicable):
29.4-47.fc42

Steps to Reproduce:
koji build --scratch f42 emacs-29.4-47.fc42.src.rpm

Additional info:
This package is tracked by Koschei. See:
https://koschei.fedoraproject.org/package/emacs

On aarch64 and ppc64le, the error is:
libgccjit.so: <built-in>:0:0: error: in jit_langhook_pushdecl, at jit/dummy-frontend.cc:1375

On s390x, the error is:
Unknown type:
 <integer_type 0x3ffb74109d8 TI
    size <integer_cst 0x3ffb7402990 type <integer_type 0x3ffb74100a8 bitsizetype> constant 128>
    unit-size <integer_cst 0x3ffb74029a8 type <integer_type 0x3ffb7410000 sizetype> constant 16>
    align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x3ffb74109d8 precision:128 min <integer_cst 0x3ffb7403540 -170141183460469231731687303715884105728> max <integer_cst 0x3ffb7403560 170141183460469231731687303715884105727>>
libgccjit.so: <built-in>:0:0: error: in tree_type_to_jit_type, at jit/dummy-frontend.cc:1305

On x86_64 and i686, this issue is not encountered.

Comment 1 Peter Oliver 2025-01-17 13:34:21 UTC
Created attachment 2066457 [details]
build.log, ppc64le

Comment 2 Siddhesh Poyarekar 2025-01-17 18:20:05 UTC
Looks like the same problem as bug 2336714.

Comment 3 Jakub Jelinek 2025-01-20 10:09:51 UTC
Feels like at least related to https://gcc.gnu.org/PR117886

Comment 4 Peter Oliver 2025-01-22 19:34:35 UTC
*** Bug 2339739 has been marked as a duplicate of this bug. ***

Comment 5 Dave Malcolm 2025-01-22 21:07:17 UTC
I was able to reproduce this on a mock build of emacspeak on aarch64, with a crash in the in-memory compiler:

  libgccjit.so: <built-in>:0:0: error: in jit_langhook_pushdecl, at jit/dummy-frontend.cc:1375

I copied in a build of libgccjit.so.0.0.1 with the fix from upstream commit
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=27470f9a818538fadb0e458a272358c7141fcd8c

and it gets *much* further: the in-memory "compile" seems to have succeeded, and it's failing running the driver (to turn the .s file into a .so) with:

Error: error ("Eager macro-expansion failure: (native-compiler-error (lambda (arg0 &rest arg1) (let ((f #'funcall-interactively)) (apply f arg0 arg1))) \"Compiling /builddir/.emacs.d/eln-cache/29.4-70b1d7ab/subr--trampoline-66756e63616c6c2d696e7465726163746976656c79_funcall_interactively_0.eln...
/usr/bin/ld: cannot find crtbeginS.o: No such file or directory
/usr/bin/ld: cannot find -lgcc: No such file or directory
/usr/bin/ld: cannot find -lgcc_s: No such file or directory
libgccjit.so: error: error invoking gcc driver
Internal native compiler error: \\\"failed to compile\\\", \\\"/builddir/.emacs.d/eln-cache/29.4-70b1d7ab/subr--trampoline-66756e63616c6c2d696e7465726163746976656c79_funcall_interactively_0.eln\\\", \\\"error invoking gcc driver\\\"

presumably due to me using a libgccjit.so with totally wrong configure settings (or maybe I've messed up my chroot).

So this may well be fixed by that upstream commit; i.e. r15-7126-g27470f9a818538.

I'm wondering if there's any info from the emacs side on how to tweak libgccjit's debugging/logging options to better see what's going on internally?  (there are a bunch of such options inside libgccjit, but I'm not sure how they're wired up in emacs, if at all; see https://gcc.gnu.org/onlinedocs/jit/topics/contexts.html#debugging from the libgccjit C API side)

Comment 6 Dave Malcolm 2025-01-22 21:20:04 UTC
(In reply to Dave Malcolm from comment #5)
> I was able to reproduce this on a mock build of emacspeak on aarch64, with a
> crash in the in-memory compiler:
> 
>   libgccjit.so: <built-in>:0:0: error: in jit_langhook_pushdecl, at
> jit/dummy-frontend.cc:1375
> 
> I copied in a build of libgccjit.so.0.0.1 with the fix from upstream commit
> https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;
> h=27470f9a818538fadb0e458a272358c7141fcd8c
> 
> and it gets *much* further: the in-memory "compile" seems to have succeeded,
> and it's failing running the driver (to turn the .s file into a .so) with:
> 
> Error: error ("Eager macro-expansion failure: (native-compiler-error (lambda
> (arg0 &rest arg1) (let ((f #'funcall-interactively)) (apply f arg0 arg1)))
> \"Compiling
> /builddir/.emacs.d/eln-cache/29.4-70b1d7ab/subr--trampoline-
> 66756e63616c6c2d696e7465726163746976656c79_funcall_interactively_0.eln...
> /usr/bin/ld: cannot find crtbeginS.o: No such file or directory
> /usr/bin/ld: cannot find -lgcc: No such file or directory
> /usr/bin/ld: cannot find -lgcc_s: No such file or directory
> libgccjit.so: error: error invoking gcc driver
> Internal native compiler error: \\\"failed to compile\\\",
> \\\"/builddir/.emacs.d/eln-cache/29.4-70b1d7ab/subr--trampoline-
> 66756e63616c6c2d696e7465726163746976656c79_funcall_interactively_0.eln\\\",
> \\\"error invoking gcc driver\\\"
> 
> presumably due to me using a libgccjit.so with totally wrong configure
> settings (or maybe I've messed up my chroot).

Aha: if I run:

LIBRARY_PATH=/usr/lib/gcc/aarch64-redhat-linux/15/ make emacspeak

with my hacked up libgccjit.so.0.0.1 it seems to be building the .el files successfully:

emacspeak-loaddefs.el
outloud-voices.el
espeak-voices.el
mac-voices.el
voice-setup.el
voice-defs.el
emacspeak-pronounce.el
emacspeak-speak.el
emacspeak-sounds.el
emacspeak.el
emacspeak-setup.el
emacspeak-keymap.el

In end of data:
emacspeak-2048.el:155:7: Warning: the function ‘2048-init-tile’ is not known to be defined.
emacspeak-2048.el:94:8: Warning: the function ‘2048-print-board’ is not known to be defined.
amixer.el
emacspeak-2048.el
emacspeak-abc-mode.el
emacspeak-add-log.el
emacspeak-analog.el
emacspeak-annotate.el

[...etc...; hasn't finished yet]

So it looks like we need a gcc build with upstream commit r15-7126-g27470f9a818538 to fix emacs compilation on non-x86_64 archs.

Comment 7 Dave Malcolm 2025-01-22 21:21:08 UTC
Though I see that the s390x failure is a different one; taking a closer look...

Comment 8 Peter Oliver 2025-01-23 00:08:43 UTC
*** Bug 2340119 has been marked as a duplicate of this bug. ***

Comment 9 Jakub Jelinek 2025-01-27 15:11:42 UTC
gcc-15.0.1-0.4.fc42 in rawhide should have the various libgccjit fixes in it (it is r15-7207 based).

Comment 10 Peter Oliver 2025-01-28 11:56:41 UTC
Emacs builds successfully on all architectures with the GCC now in rawhide.  Thanks.