3

I recently switched to Emacs 28.1 hoping to use the new native-comp support. Being on Windows, I followed these instructions to install libgccjit, copying the resulting libgccjit.dll library to Emacs’s bin folder. However, upon doing so, I received the following warning whenever Emacs attempted to compile any file:

Warning (comp): C:\Users\<omitted>\AppData\Local\Temp\\libgccjit-554575/fake.s:4: Error: junk at end of line, first unrecognized character is `"' Disable showing Disable logging
Warning (comp): C:\Users\<omitted>\AppData\Local\Temp\\libgccjit-554575/fake.s:4: Error: file number less than one Disable showing Disable logging
Warning (comp): c:\emacs\bin\libgccjit-0.dll: error: error invoking gcc driver Disable showing Disable logging
Warning (comp): <filename>: Error: Internal native compiler error failed to compile Disable showing Disable logging

(Where <filename> is the name of each file Emacs attempted to compile, of course.)

Curiously, when I launch Emacs from MSYS2 MinGW (64-bit), the errors disappear, and Emacs is successfully able to compile all files. What is going on here, and how may I fix it? All I know at this point is that the problem is probably unrelated to the dependencies to libgccjit.dll: using dumpbin libgccjit.dll /dependents revealed that Emacs’s bin folder already contains all dependencies of libgccjit.dll.

bradrn
  • 153
  • 6

2 Answers2

1

Do you have another msys2/MinGW environment in your path? I had the same error message and after removing the bin folder of git-sdk-64 from my path, emacs could compile the files.

A binary or library which is not found should trigger an error message about a missing dependency.

Sorry to write this here as answer, I don't have enough reputation to comment.

cannero
  • 11
  • 2
  • I do not have any MSYS2/MinGW environment in my path. However, it turns out I *do* have several other instances of `libgcc_s_seh-1.dll`! I assume that different versions of these are messing up everything — when I get some time I’ll try rearranging my PATH to see what happens. – bradrn Apr 26 '22 at 00:58
  • I finally got some time to try this; alas, it doesn’t seem to work. The problem must be elsewhere. – bradrn May 12 '22 at 06:25
  • Actually, on further investigation, the problem does indeed turn out to be closely related to what you suggested: Emacs was trying to run processes like `as` and `ld`, but didn’t know where to find them. So the problem was not one of too *many* conflicting files on PATH, but too *few*. I’m not quite sure how to solve this, though, short of adding the whole MinGW64 environment to my PATH. – bradrn May 12 '22 at 06:51
0

Try adding C:\msys2\mingw64\bin to your windows path using the "Edit System Environment Variables" control panel.

While other approaches are possible I haven't found any that is simpler, nor has this caused any issue for me. In any case, copying libgccjit.dll into the bin folder of your Emacs installation is not sufficient to get native elisp compilation working.

Irrespective of DLLs directly needed by libgccjit.dll, invoking just-in-time compilation implies running GCC. This, in turn, requires that GCC can find your system (e.g. MSYS2) configuration, for example environment variables settings up your LD_LIBRARY_PATH. By using libgccjit.dll from its installation location you preserve this configuration as captured when you installed libgccjit.

When you launch from MSYS2's MinGW64 shell the relevant bin folder has already been added to your path for you.