Fix build with native compilation but without zlib

* src/comp.c (comp_hash_source_file): Condition code that requires
zlib with HAVE_ZLIB.

* etc/NEWS: Explain that '--without-compress-install' is necessary
when configuring with native compilation but without zlib.
This commit is contained in:
Eli Zaretskii 2021-09-22 19:13:49 +03:00
parent eb42c4b099
commit 2386b08526
2 changed files with 15 additions and 0 deletions

View file

@ -31,6 +31,11 @@ and also requires GCC and Binutils to be available when Lisp code is
natively compiled. See the Info node "(elisp) Native Compilation" for
more details.
If you build Emacs with native compilation, but without zlib, be sure
to configure with the '--without-compress-install' option, so that the
installed *.el files are not compressed; otherwise, you will not be
able to use JIT native compilation of the installed *.el files.
** The Cairo graphics library is now used by default if present.
'--with-cairo' is now the default, if the appropriate development files
are found by 'configure'. Note that building with Cairo means using

View file

@ -705,6 +705,12 @@ comp_hash_source_file (Lisp_Object filename)
/* Can't use Finsert_file_contents + Fbuffer_hash as this is called
by Fcomp_el_to_eln_filename too early during bootstrap. */
bool is_gz = suffix_p (filename, ".gz");
#ifndef HAVE_ZLIB
if (is_gz)
xsignal2 (Qfile_notify_error,
build_string ("Cannot natively compile compressed *.el files without zlib support"),
filename);
#endif
Lisp_Object encoded_filename = ENCODE_FILE (filename);
FILE *f = emacs_fopen (SSDATA (encoded_filename), is_gz ? "rb" : "r");
@ -713,9 +719,13 @@ comp_hash_source_file (Lisp_Object filename)
Lisp_Object digest = make_uninit_string (MD5_DIGEST_SIZE * 2);
#ifdef HAVE_ZLIB
int res = is_gz
? md5_gz_stream (f, SSDATA (digest))
: md5_stream (f, SSDATA (digest));
#else
int res = md5_stream (f, SSDATA (digest));
#endif
fclose (f);
if (res)