Subject: Re: bug#45303: 28.0.50; [feature/native-comp] comp.c compilation error on Windows 10

From: Liāu, Kiong-Gē 廖宮毅 <[email-masked]>
Date: Fri, 18 Dec 2020 13:40:22 -0600

By changing src/Makefile's temacs target to:

temacs$(EXEEXT): $(LIBXMENU) $(ALLOBJS) $(LIBEGNU_ARCHIVE) $(EMACSRES) \
  $(charsets) $(charscript) $(MAKE_PDUMPER_FINGERPRINT)
        $(AM_V_CCLD)$(CC) -o $@.tmp \
          $(ALL_CFLAGS) $(TEMACS_LDFLAGS) $(LDFLAGS) \
          $(ALLOBJS) $(LIBEGNU_ARCHIVE) $(W32_RES_LINK) $(LIBES) \
          -lgccjit -lz

Now the temacs is successfully generated, however, at ELC+ELN step of
macroexpand.el, temacs just crashed:

make[2]: Entering directory
'/home/VWinUser0/Downloads/emacs/native-comp/build/lisp'
 ELC+ELN   ../../src/lisp/emacs-lisp/macroexp.elc

Backtrace:
00000004001adbe2
00000004000b40a6
00000004000ccc64
000000040020581a
00007ffeba377ff0
00007ffebb9910f7
00007ffebb93b46c
00007ffebb98fc26
make[2]: *** [Makefile:319: ../../src/lisp/emacs-lisp/macroexp.elc] Error 255
make[2]: Leaving directory
'/home/VWinUser0/Downloads/emacs/native-comp/build/lisp'
make[1]: *** [Makefile:833: bootstrap-emacs.pdmp] Error 2
make[1]: Leaving directory
'/home/VWinUser0/Downloads/emacs/native-comp/build/src'
make: *** [Makefile:434: src] Error 2

Such a problem does not occur on Linux or FreeBSD.

Thanks,
Kiong-Ge.

On Fri, Dec 18, 2020 at 10:37 AM Andrea Corallo <[email-masked]> wrote:
>
> Eli Zaretskii <[email-masked]> writes:
>
> >> Date: Fri, 18 Dec 2020 13:28:20 +0000
> >> Cc: [email-masked], =?UTF-8?Q?Li=C4=[email-masked]
> >> From: Andrea Corallo via "Bug reports for GNU Emacs,
> >>  the Swiss army knife of text editors" <[email-masked]>
> >>
> >> >>  CCLD     temacs.exe
> >> >> C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
> >> >> comp.o: in function `md5_gz_stream':
> >> >> C:\msys64\home\VWinUser0\Downloads\emacs\native-comp\build\src/../../src/src/comp.c:713:
> >> >> undefined reference to `inflateInit2_'
> >> >> C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe:
> >> >> C:\msys64\home\VWinUser0\Downloads\emacs\native-comp\build\src/../../src/src/comp.c:730:
> >> >> undefined reference to `inflate'
> >> >
> >> > That's curious, looks you've not zlib but from the config.log you do...
> >>
> >> I really would like to understand what's going on here.
> >>
> >> We check in configure for zlib presence, actually this is also require
> >> by --with-nativecomp but somehow the linker fails to find it.
> >
> > Why does the native-comp branch require zlib in comp.c? what does it
> > do with zlib?
>
> We hash the content of the lisp source files to obtain the correspondent
> eln name in the eln-cache.
>
> This machinery has to work since early bootstrap (and has to be fast
> since is executed at each file load), so is directly done from comp.c.
>
> When Emacs is installed the el files are compressed and so before
> hashing them we have to decompress therefore we use zlib.
>
> > On master, zlib is an optional library, and when some Emacs command is
> > invoked that needs it, on MS-Windows we load the zlib DLL at run time
> > when requested.  See init_zlib_functions in decompress.c.  This is
> > unlike on Posix systems, where Emacs is linked with zlib at link time.
> > Does this explain what is going on?
>
> I see, we should probably have comp.c use the necessary DEF_DLL_FN bloat
> or have these functions wrapped in decompress.c.