GNU bug report logs - #71292
30.0.50; macOS: .elns have no debug info

Previous Next

Package: emacs;

Reported by: Gerd Möllmann <gerd.moellmann <at> gmail.com>

Date: Fri, 31 May 2024 13:57:02 UTC

Severity: normal

Found in version 30.0.50

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Gerd Möllmann <gerd.moellmann <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.50; macOS: .elns have no debug info
Date: Fri, 31 May 2024 15:55:43 +0200
On macOS, executables (including .dylibs (=.eln)) never not contain
debug info themselves. Debug info is instead contained in .o files, and
executables reference the .o files used to build them in a debug map.
This can be seen with, e.g.

  dsymutil --dump-debug-map

This means no .o files, no debug info.

libgccjit deletes the .o files if debug > 0, gcc-14 -g does not delete
them, the .o files are kept in some temporary directory.

I found that the following change makes libgccjit behave like gcc:

modified   lisp/emacs-lisp/comp.el
@@ -99,7 +99,7 @@ native-comp-compiler-options
   :version "28.1")

 (defcustom native-comp-driver-options
-  (cond ((eq system-type 'darwin) '("-Wl,-w"))
+  (cond ((eq system-type 'darwin) '("-Wl,-w" "-save-temps=obj"))
         ((eq system-type 'cygwin) '("-Wl,-dynamicbase")))
   "Options passed verbatim to the native compiler's back-end driver.

This does not address the generation of .dSYM bundles. The .o files in
the temp dirs will be deleted at some point by which the debug info of
an executable is lost. This can be prevented by producing a .dSYM
bundle for the executable with

  dsymutil <executable>

and keeping the .dSYM around with the executable. .dSYM bundles can be
loaded in LLDB with

  process symbols add <dsym>.

To produce .dSYMs for native lisp:

  #! /usr/bin/env zsh
  rm -rf native-lisp/**/*.dSYM
  for f in native-lisp/**/*.eln; do
    dsymutil $f
  done

I've made jit <at> gcc.gnu.org aware of this. Maybe they will change
something in the future.

Example in LLDB with native-comp-debug == 2

  frame #7: 0x000000010350db68 comp-7672a6ed-3a3b5dd7.eln`F636f6d702d2d6c696d706c6966792d626c6f636b_comp__limplify_block_0 + 1632 at comp-7672a6ed-3a3b5dd7.c:101440

and one can look at the C file.





This bug report was last modified 1 year and 69 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.