Opened 2 years ago

Last modified 2 months ago

#64331 accepted defect

emacs-app-devel: problems with native compilation

Reported by: pmetzger (Perry E. Metzger) Owned by: drkp (Dan Ports)
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: danchr (Dan Villiom Podlaski Christiansen), jlargentaye (John de Largentaye), wilya7, cooljeanius (Eric Gallager)
Port: emacs-app-devel

Description

If you build the devel version of emacs-app, you start getting lots of messages about -lSystem not being found if you actually try to natively compile anything. Reproducing is quite easy.

Change History (16)

comment:1 Changed 2 years ago by ryandesign (Ryan Carsten Schmidt)

Owner: set to drkp
Status: newassigned

What do you mean "natively compile"? If the port is failing to build, could you attach the main.log file, please?

comment:2 Changed 2 years ago by pmetzger (Perry E. Metzger)

The port builds fine, that's not the problem.

Native compilation is a feature of Emacs as of version 28. Emacs now has a native code compiler for elisp, the extension language that is part of the Emacs system. It works by using libgccjit, although it's not a jit but rather an ahead of time compiler. Emacs will attempt to compile (and cache) basically any elisp it gets invoked on. What happens with the port is Emacs itself starts, but when it attempts to compile elisp code to execute it, it starts spitting out error messages in an internal *Warnings* window. (If you're not an Emacs user, this likely isn't very meaningful to you.)

Regardless, the problem happens with most elisp. For example, with my particular init.elc file:

Warning (initialization): An error occurred while loading ‘/Users/perry/.config/emacs/init.elc’:

Native compiler error: (lambda (arg0 &optional) (let ((f #'yes-or-no-p)) (funcall f arg0))), Compiling /Users/perry/.config/emacs/eln-cache/29_0_50-99cad26e/subr--trampoline-7965732d6f722d6e6f2d70_yes_or_no_p_0.eln...
ld: library not found for -lSystem
collect2: error: ld returned 1 exit status
libgccjit.so: error: error invoking gcc driver
Debugger entered--Lisp error: (native-ice "failed to compile" "/Users/perry/.config/emacs/eln-cache/29_0_50-99cad..." "error invoking gcc driver")
  comp--compile-ctxt-to-file("/Users/perry/.config/emacs/eln-cache/29_0_50-99cad...")
  comp-compile-ctxt-to-file("/Users/perry/.config/emacs/eln-cache/29_0_50-99cad...")
  comp-final1()
  load-with-code-conversion("/private/var/folders/f7/wtf8h98x1wd8sbzw0vrh0d5c00..." "/private/var/folders/f7/wtf8h98x1wd8sbzw0vrh0d5c00..." nil t)
  command-line-1(("-l" "/var/folders/f7/wtf8h98x1wd8sbzw0vrh0d5c0000gq/T/e..."))
  command-line()
  normal-top-level()

You can invoke it in many ways and get similar problems. The consistent error is the stuff about -lSystem not being found.

It's important that those of us who know how to deal with Emacs fix this relatively soon because Emacs 28 will be out relatively soon.

Last edited 2 years ago by pmetzger (Perry E. Metzger) (previous) (diff)

comment:3 Changed 2 years ago by pmetzger (Perry E. Metzger)

(Note that other people's builds of the head of the git repo for the Mac, like "emacsformacosx.com", work just fine. It's clearly something we've done in the way we're doing our build.)

comment:4 Changed 2 years ago by drkp (Dan Ports)

Status: assignedaccepted

Yes, I'm seeing that too. Native compilation works fine during the port build but not afterwards.

(Also happens with today's emacs-devel HEAD, FWIW)

comment:5 Changed 2 years ago by pmetzger (Perry E. Metzger)

I'm now having trouble building an Emacs on my own that doesn't have this "-lSystem" issue, so I'm interested in what is actually going on here.

BTW, side note, "emacsformacosx.com" carefully packages a bunch of systems libraries in the .app file; we might want to do the same.

comment:6 Changed 2 years ago by amake (Aaron Madlon-Kay)

I have been using emacs-app-devel (with +nativecomp) for quite a while and have never seen this issue. Can anyone give specific repro steps?

To be clear, my installation *does* do on-demand compilation of Elisp files, but it always does so successfully.

Last edited 2 years ago by amake (Aaron Madlon-Kay) (previous) (diff)

comment:7 Changed 2 years ago by pmetzger (Perry E. Metzger)

You just build an emacs with macports and start it with an init file that loads things that aren't precompiled; it starts spewing messages almost immediately because it can't compile (or run) them.

Last edited 2 years ago by pmetzger (Perry E. Metzger) (previous) (diff)

comment:8 Changed 2 years ago by danchr (Dan Villiom Podlaski Christiansen)

Cc: danchr added

comment:9 Changed 22 months ago by jlargentaye (John de Largentaye)

Cc: jlargentaye added

comment:10 Changed 22 months ago by wilya7

Cc: wilya7 added

comment:11 in reply to:  7 Changed 22 months ago by wilya7

Replying to pmetzger:

You just build an emacs with macports and start it with an init file that loads things that aren't precompiled; it starts spewing messages almost immediately because it can't compile (or run) them.

For me to trigger this bug it was enough to use the help system and search for the the documentation of a variable.

comment:12 Changed 19 months ago by cooljeanius (Eric Gallager)

Cc: cooljeanius added

comment:13 Changed 13 months ago by jokuha (Jochen)

Is there any solution or workaround to this, as it makes Emacs not go through init.el successfully and thus the running instance is not set up/useful.

And -nativecomp leads to a local rebuild (which I will try now, hope ti helps:-o)

comment:14 Changed 13 months ago by catap (Kirill A. Korinsky)

After reboot of my machine I've encounter the same issue.

Magically but xcode-select --install seems to fix it.

comment:15 Changed 2 months ago by diekhans (Mark Diekhans)

Just started getting this error after an upgrade; is there a definitive way to address it?

comment:16 Changed 2 months ago by diekhans (Mark Diekhans)

Ah, bingo; it is doing "xcode-select --install. " My bad; I thought this had been done.

Perhaps the way to code this is to have the emacs require it, or at least warn?

Note: See TracTickets for help on using tickets.