From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrea Corallo via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#45303: #45303 [feature/native-comp] building error on Windows Date: Sat, 19 Dec 2020 07:57:10 +0000 Message-ID: References: <83k0te6c7i.fsf@gnu.org> Reply-To: Andrea Corallo Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="571"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 45303@debbugs.gnu.org To: Pal Gloss Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 19 08:58:28 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1kqX8G-000Acf-Hq for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 19 Dec 2020 08:58:28 +0100 Original-Received: from localhost ([::1]:37100 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqX8F-0002KT-CJ for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 19 Dec 2020 02:58:27 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56826) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqX7r-0002K4-No for bug-gnu-emacs@gnu.org; Sat, 19 Dec 2020 02:58:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57456) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kqX7q-0006ez-1A for bug-gnu-emacs@gnu.org; Sat, 19 Dec 2020 02:58:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kqX7p-00045B-Vl for bug-gnu-emacs@gnu.org; Sat, 19 Dec 2020 02:58:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Andrea Corallo Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 19 Dec 2020 07:58:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45303 X-GNU-PR-Package: emacs Original-Received: via spool by 45303-submit@debbugs.gnu.org id=B45303.160836463615634 (code B ref 45303); Sat, 19 Dec 2020 07:58:01 +0000 Original-Received: (at 45303) by debbugs.gnu.org; 19 Dec 2020 07:57:16 +0000 Original-Received: from localhost ([127.0.0.1]:40769 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kqX75-000446-I3 for submit@debbugs.gnu.org; Sat, 19 Dec 2020 02:57:15 -0500 Original-Received: from mab.sdf.org ([205.166.94.33]:33554 helo=ma.sdf.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kqX72-00043s-L9 for 45303@debbugs.gnu.org; Sat, 19 Dec 2020 02:57:13 -0500 Original-Received: from akrl by ma.sdf.org with local (Exim 4.92) (envelope-from ) id 1kqX70-0000y0-B1; Sat, 19 Dec 2020 07:57:10 +0000 In-Reply-To: (Pal Gloss's message of "Fri, 18 Dec 2020 23:21:44 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:196366 Archived-At: Pal Gloss writes: > I retried building with the most recent feature/native-comp branch and if= you > skip to the last code block, you can see how I managed to build emacs wit= h it > and use it (I've been using a similar build on Win10 for about 2 days). = I can > confirm that my previous hack for =3Dnt/epaths.nt=3D is not needed anymor= e. >=20=20 > #+begin_src shell :exports code > git rev-parse HEAD feature/native-comp > #+end_src > : 87f6e937995c433825173fb0473a801791d5beac > : 87f6e937995c433825173fb0473a801791d5beac [...] > # patch to look for libgccjit-0.dll instead of libgcc.dll in lisp/term/= w32-win.el & src/emacs.c > sed -i -e 's/libgccjit.dll/libgccjit-0.dll/' lisp/term/w32-win.el > sed -i -e 's/libgccjit.dll/libgccjit-0.dll/' src/emacs.c Okay this should be fixed by now. > mkdir -p ../build > cd ../build > ../emacs/configure \ > --with-xml2 \ > --without-pop \ > --prefix=3D"/home/cramaph1/$EMACS_VERSION/dest" \ > --without-compress-install \ > --without-dbus \ > --with-nativecomp \ > --with-modules 'CFLAGS=3D-O2 -g3' > # fix linker errors by making sure the correct libraries are added to t= he linker command > sed -i -e 's/^LIBGCCJIT =3D *$/LIBGCCJIT =3D -lz -lgccjit/' src/Makefile > make -j"$PROCESSORS_TO_USE" > #+end_src >=20=20 > Now I get a crash with a backtrace: > #+begin_example > Backtrace: > 00000004001afb22 > 00000004000b40a6 > 00000004000ccc64 > 000000040020a4ca > 00007ff9e5f58040 > 00007ff9e6181847 > 00007ff9e614a881 > 00007ff9e61804b6 > make[2]: *** [Makefile:297: ../../emacs/lisp/term/w32-win.elc] Error 3 > make[1]: *** [Makefile:797: ../../emacs/lisp/term/w32-win.elc] Error 2 > make[1]: Leaving directory '/home/cramaph1/emacs-native-comp/build/src' > make: *** [Makefile:434: src] Error 2 > #+end_example >=20=20 > This crash is due to the =3D#pragma GCC diagnostic=3D around a =3Dif > (gcc_jit_global_set_initializer)=3D: see this example program where the > =3D#pragma=3D around the =3Dif(...)=3D makes it into a separate statement= from the > =3D{...}=3D body. Apparently, on my machine, =3Dgcc_jit_global_set_initi= alizer=3D is > NULL but the body gets executed anyway. > #+begin_src c :exports code > /* save as /tmp/t.c, then run (cd /tmp && gcc t.c && ./a.exe) */ > /* It should print nothing at all, but on my machine, it prints > This should not be printed, but will be printed anyway (2). > This is gcc.exe (Rev6, Built by MSYS2 project) 10.2.0 */ > #include > int main() { > if (0) > { > printf("This will not be printed (1).\n"); > } > #pragma GCC diagnostic ignored "-Waddress" > if (0) > #pragma GCC diagnostic pop > { > printf("This should not be printed, but will be printed anyway (2= ).\n"); > } > #pragma GCC diagnostic ignored "-Waddress" > if (0) > { > #pragma GCC diagnostic pop > printf("This should not be printed (3).\n"); > } > return 0; > } > #+end_src > > So I try again, this time inverting the =3D#pragma GCC diagnostic pop=3D = and the =3D{=3D lines, too: > #+begin_src shell :exports code > cd ../emacs > rm -rf ../build > git restore . > # patch to avoid gcc_jit_global_set_initializer (crashes on my machine.= ..; it > # seems there is an interaction with the #pragma and the rest of the pa= rsing > # because the statement is incomplete?) and to adapt to (new) 5th param= eter to > # directory-files Nice :) While reporting the bug in GCC I've found this previous bugzilla report. Interesting... should work now. > sed -i -e '/if (gcc_jit_global_set_initializer)/,/{/ { > /#pragma GCC diagnostic pop/d > /{/a #pragma GCC diagnostic pop > }' \ > -e '/internal_condition_case_4/,/FOR_EACH/ { > s/internal_condition_case_4/internal_condition_case_5/ > s/Qt, return_nil);/Qnil, Qt, return_nil);/ > }' \ > src/comp.c > sed -i -e '/extern Lisp_Object internal_condition_case_4/a extern Lisp_= Object internal_condition_case_5 (Lisp_Object > (*) (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object), Li= sp_Object, Lisp_Object, Lisp_Object, > Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object (*) (Lisp_Object));' s= rc/lisp.h > sed -i -e '/Like internal_condition_case_1 but call BFUN with ARG1, ARG= 2, ARG3, ARG4 as/ { > s/ARG4 as/ARG4, ARG5 as/ > a its arguments. */ > a Lisp_Object > a internal_condition_case_5 (Lisp_Object (*bfun) (Lisp_Obj= ect, Lisp_Object, > a Lisp_Obj= ect, Lisp_Object, > a Lisp_Obj= ect), > a Lisp_Object arg1, Lisp_Object= arg2, > a Lisp_Object arg3, Lisp_Object= arg4, > a Lisp_Object arg5, > a Lisp_Object handlers, > a Lisp_Object (*hfun) (Lisp_Obj= ect)) > a { > a struct handler *c =3D push_handler (handlers, CONDITIO= N_CASE); > a if (sys_setjmp (c->jmp)) > a { > a Lisp_Object val =3D handlerlist->val; > a clobbered_eassert (handlerlist =3D=3D c); > a handlerlist =3D handlerlist->next; > a return hfun (val); > a } > a else > a { > a Lisp_Object val =3D bfun (arg1, arg2, arg3, arg4, = arg5); > a eassert (handlerlist =3D=3D c); > a handlerlist =3D c->next; > a return val; > a } > a } > a /* Like internal_condition_case_1 but call BFUN with ARG= 1, ARG2, ARG3, ARG4 as > }' src/eval.c Should be fixed too. [...] > And now emacs 28.0.50 seems to work (there are some compilation issues wi= th > hyperbole, but my config is usable). If I do =3DM-: (apropos-value > =E2=80=99("%emacs_dir%") nil)=3D, I still see these directories that look= fishy, but > i works for me at the moment. > #+begin_example > Info-default-directory-list > ("%emacs_dir%/share/info/") > ---------------- > configure-info-directory > "%emacs_dir%/share/info" > #+end_example Right so (unless I'm forgetting something) just the zlib linker error should be remaining, correct? I'll have a look later in the weekend or Monday. > Sorry for the wall of text, I am just trying to show that I built up my > hacks/patches step by step and make sure they are still needed. Thanks for the precise analysis this is very helpful. The Windows port is a bit rusty, I believe nobody compiled it since 6+ months, is good we resurrect it and keep it running. Andrea