emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] [WIP] Port feature/native-comp to Windows.


From: Eli Zaretskii
Subject: Re: [PATCH] [WIP] Port feature/native-comp to Windows.
Date: Sun, 10 May 2020 21:22:45 +0300

> From: Nicolas Bértolo <address@hidden>
> Date: Sun, 10 May 2020 14:50:52 -0300
> Cc: Andrea Corallo <address@hidden>, address@hidden
> 
> > What information do we need, exactly?
> 
> We need:
> - The name of the setjmp function.
> - Whether it needs a second parameter, in that case:
>    - It can be a gcc builtin, a function call or a NULL constant.
>    - If it is a function call or a builtin it may need a parameter.
>      This is a NULL constant in all cases I have seen.

This is known in advance.  We already have that knowledge in Emacs,
see HAVE__SETJMP and HAVE_SIGSETJMP used in lisp.h.

I don't yet understand why we need the _name_ of the setjmp function.
How will this name be used?

> > What is the definition of " where the gcc installation lives"?  What
> > files does libgccjit need from that place, and how does it look for
> > those files?
> 
> libgccjit implements generates an assembler file. This is done without any 
> calls
> to any external program. Then it calls a gcc entry point to finish the 
> process.
> This calls the same functions that the `gcc` program uses to identify where it
> was installed. In particular, it uses constants defined at libgccjit build 
> time
> (the compiler version, the directories where it was installed, etc.). It uses
> that information plus some environment variables: GCC_EXEC_PREFIX, 
> LIBRARY_PATH,
> maybe others, to find where the gcc support files are installed: the support
> binaries, libgcc. This is what I meant by "where the gcc installation lives".
> 
> This logic runs inside the Emacs process that is performing the compilation
> process, but it is the same code that would run in a `gcc -print-*` IIUC.
> 
> > IIUC what is needed, it should be relatively easy to glean this
> > information from the output of "gcc -print-file-name=" and its ilk.
> 
> libgccjit runs the exact same code as gcc would. So this would not help.

Then why do we need to tell libgccjit where the GCC installation
lives?  AFAIU from what you are saying, libgccjit already knows that.
What am I missing?

> Moreover, how would Emacs find gcc? We would need to add it to PATH.

The gcc executable is always on PATH, only the auxiliary programs
(cc1.exe etc.) aren't.  Otherwise you couldn't compile programs in
arbitrary directories.

> > Using the above-mentioned -print-* options to GCC should accomplish
> > the same tasks, because they ask GCC to reveal the places where it
> > finds its auxiliary binaries and support libraries.  Isn't it enough
> > to find out the absolute file names of each such file/program, and
> > tell libgccjit to use that absolute file name, instead of using -B?
> 
> I do not think that is possible. libgccjit likes to find the files it needs as
> if it was a gcc instance.

Then I don't understand why it needs any help at all.  When I invoke
gcc to compile a program, I don't tell it anything about where the
installation lives, gcc finds that all by itself.  Why is libgccjit
different?

> > I'd like to avoid that: it's a nuisance to have to copy files that
> > way, and users could legitimately have more than one GCC version
> > installed and available at the same time.
> 
> AFAIU, we need to use the same GCC version, that is what libgccjit looks for.

Same GCC version as what other version? the one used to compile Emacs
itself, perhaps?

> Using support libraries from different GCC versions may cause weird bugs.

Then we are already in trouble, because libgcc comes with each GCC
version and is slightly different from other versions (although it's
supposed to be compatible), and libmingwex and libmingw32 come with
MinGW distribution which is independent of GCC -- users can upgrade
their MinGW installation at will.

I don't think using libraries from a different GCC version is going to
cause problems, assuming the newer library is binary-compatible to the
old one (if it isn't, the DLL will have a different name, like
libgcc_s_dw2-2.dll vs libgcc_s_dw2-1.dll).

> > That assumes that Emacs is configured and built on the same system
> > where it is used.  That assumption is mostly false for Windows, where
> > many users simply download and install precompiled binaries, or build
> > on one system and then use on several different ones.  We should try
> > to find a way of getting this information at run time, not at
> > configure time.  And it shouldn't be hard: we can use at run time the
> > same GCC options as the configure script would do.  This should be
> > done once, and the result stored in some FOO-directory variable for
> > use when Lisp should be compiled.
> 
> This would mean that users would have to download the appropriate GCC version 
> if
> they want to use native lisp compilation

What is the definition of "the appropriate GCC version" in this
context?  E.g., does it have to be exactly the same version as the one
used to build Emacs itself?  Or does it mean something else?

> By copying the support files into the installation dir we ensure
> that Emacs finds the correct files and it works out of the box for
> users that download a ZIP file.

How will this work in practice?  Are you suggesting that we include
part of the GCC installation in the Emacs binary zip file?  If so, we
will have to provide also the humongous GCC source tarball on the same
site, to comply with the GPL.  That is doable, of course, but very
inconvenient.  We should try to find a better way.

But this is still too early, I think we first need to understand
exactly what files does libgccjit need to find during compilation and
how.  (Well, I guess _I_ need to understand that; apologies for not
being more familiar with these details of the native-comp branch, and
wasting your time on looking into this and describing the findings.
maybe someone else who knows more about this could chime in and make
the progress faster and less tedious.)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]