From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] [WIP] Port feature/native-comp to Windows. Date: Sun, 10 May 2020 21:22:45 +0300 Message-ID: <83ftc7d4zu.fsf@gnu.org> References: <5eb5b953.1c69fb81.a67ce.a764@mx.google.com> <83lfm1hc91.fsf@gnu.org> <83wo5lds87.fsf@gnu.org> <83lflzd8es.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="76606"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org, akrl@sdf.org To: Nicolas =?utf-8?Q?B=C3=A9rtolo?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun May 10 20:23:39 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jXqby-000JqY-ET for ged-emacs-devel@m.gmane-mx.org; Sun, 10 May 2020 20:23:38 +0200 Original-Received: from localhost ([::1]:44328 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXqbx-00021S-0B for ged-emacs-devel@m.gmane-mx.org; Sun, 10 May 2020 14:23:37 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44320) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXqbE-0001aF-B8 for emacs-devel@gnu.org; Sun, 10 May 2020 14:22:52 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:47541) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXqbD-0006jN-Nw; Sun, 10 May 2020 14:22:51 -0400 Original-Received: from [176.228.60.248] (port=4841 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jXqbD-0002qA-7G; Sun, 10 May 2020 14:22:51 -0400 In-Reply-To: (message from Nicolas =?utf-8?Q?B=C3=A9rtolo?= on Sun, 10 May 2020 14:50:52 -0300) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:249693 Archived-At: > From: Nicolas BĂ©rtolo > Date: Sun, 10 May 2020 14:50:52 -0300 > Cc: Andrea Corallo , emacs-devel@gnu.org > > > 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.)