On 2024-05-11 05:39, Gerd Möllmann wrote:
David Malcolm <dmalc...@redhat.com> writes:
As I understand it, Emacs is using libgccjit to do ahead-of-time
compilation, presumably compiling the optimized ELisp code to machine
code as a shared library.
Correct.
Is Emacs using gcc_jit_context_compile_to_file with
GCC_JIT_OUTPUT_KIND_DYNAMIC_LIBRARY, or is it doing something more
complicated?
Yes. (Sorry, I forgot to CC Andrea; he sent me here :-)).
If that's what it's doing, you might want to take a look
at playback::context::compile in gcc/jit-playback.cc (and try stepping
through it in the debugger). In particular, the
playback::compile_to_file::postprocess implementation of the
playback::context::postprocess vfunc is responsible for taking a .s in
a tempdir and turning it into the desired output. Perhaps there's some
macOS-specific special-casing needed there?
You might also find it useful to look at the overview of how
libgccjit's internals here:
https://gcc.gnu.org/onlinedocs/jit/internals/index.html#overview-of-code-structure
Hope this is helpful
Yes it is. Thanks, David!
Found something out.
Passing -save-temps=obj to libgccjit makes it keep the .o file used to
compile the .eln dylibs in Emacs/macOS. Libgccjit then performs the same
way gcc-14 does on macOS when compiling with -g.
Maybe one could check what gcc-14 does for -g on macOS, and do the same
when libgccjit compiles with debug > 0. I'm not familiar enough with GCC
to do that in a reasoanble time, sorry. And I can't build it easily.