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

From: Liāu, Kiong-Gē 廖宮毅 <[email-masked]>
Date: Thu, 17 Dec 2020 14:20:47 -0600

I tried to build feature/native-comp branch on Windows 10 using the most
up-to-date Msys2 system's mingw-w64-x86_64-gcc and mingw-w64-x86_64-libgccjit
as 2020-12-16.

The build is configured with flag
 'configure --prefix=/home/VWinUser0/Downloads/emacs/native-comp
 --with-nativecomp'

Configured for 'x86_64-w64-mingw32'.

  Where should the build process find the source code?    ../src
  What compiler should emacs be built with?               gcc  -g3 -O2 -gdwarf-2
  Should Emacs use the GNU version of malloc?             no
    (The GNU allocators don't work with this system configuration.)
  Should Emacs use a relocating allocator for buffers?    no
  Should Emacs use mmap(2) for buffer allocation?         yes
  What window system should Emacs use?                    w32
  What toolkit should Emacs use?                          none
  Where do we find X Windows header files?                NONE
  Where do we find X Windows libraries?                   NONE
  Does Emacs use -lXaw3d?                                 no
  Does Emacs use -lXpm?                                   yes
  Does Emacs use -ljpeg?                                  yes
  Does Emacs use -ltiff?                                  yes
  Does Emacs use a gif library?                           yes
  Does Emacs use a png library?                           yes
  Does Emacs use -lrsvg-2?                                yes
  Does Emacs use cairo?                                   no
  Does Emacs use -llcms2?                                 yes
  Does Emacs use imagemagick?                             no
  Does Emacs use native APIs for images?                  yes (w32)
  Does Emacs support sound?                               yes
  Does Emacs use -lgpm?                                   no
  Does Emacs use -ldbus?                                  no
  Does Emacs use -lgconf?                                 no
  Does Emacs use GSettings?                               no
  Does Emacs use a file notification library?             yes (w32)
  Does Emacs use access control lists?                    yes
  Does Emacs use -lselinux?                               no
  Does Emacs use -lgnutls?                                yes
  Does Emacs use -lxml2?                                  yes
  Does Emacs use -lfreetype?                              no
  Does Emacs use HarfBuzz?                                yes
  Does Emacs use -lm17n-flt?                              no
  Does Emacs use -lotf?                                   no
  Does Emacs use -lxft?                                   no
  Does Emacs use -lsystemd?                               no
  Does Emacs use -ljansson?                               yes
  Does Emacs use the GMP library?                         yes
  Does Emacs directly use zlib?                           yes
  Does Emacs have dynamic modules support?                yes
  Does Emacs use toolkit scroll bars?                     yes
  Does Emacs support Xwidgets?                            no
  Does Emacs have threading support in lisp?              yes
  Does Emacs support the portable dumper?                 yes
  Does Emacs support legacy unexec dumping?               no
  Which dumping strategy does Emacs use?                  pdumper
  Does Emacs have native lisp compiler?                   yes

configure: creating ./config.status
config.status: creating nt/emacs.rc
config.status: creating nt/emacsclient.rc
config.status: creating src/emacs-module.h
config.status: creating Makefile
config.status: creating lib/gnulib.mk
config.status: creating ../src/doc/man/emacs.1
config.status: creating lib/Makefile
config.status: creating lib-src/Makefile
config.status: creating oldXMenu/Makefile
config.status: creating doc/emacs/Makefile
config.status: creating doc/misc/Makefile
config.status: creating doc/lispintro/Makefile
config.status: creating doc/lispref/Makefile
config.status: creating src/Makefile

The compilation kicked-off using `make`, and it stopped at comp.c
with the following error message:

  CC       comp.o
../../src/src/comp.c: In function 'Fcomp_el_to_eln_filename':
../../src/src/comp.c:4110:36: error: expected ')' before 'PATH_REL_LOADSEARCH'
 4110 |    Fregexp_quote (build_string ("/" PATH_REL_LOADSEARCH "/")));
      |                                    ^~~~~~~~~~~~~~~~~~~~
      |                                    )
../../src/src/comp.c: In function 'Fcomp__compile_ctxt_to_file':
../../src/src/comp.c:4458:12: warning: unused variable 'oldset'
[-Wunused-variable]
 4458 |   sigset_t oldset;
      |            ^~~~~~
../../src/src/comp.c: In function 'eln_load_path_final_clean_up':
../../src/src/comp.c:4621:29: warning: passing argument 1 of
'internal_condition_case_4' from incompatible pointer type
[-Wincompatible-pointer-types]
 4621 |  internal_condition_case_4 (Fdirectory_files,
      |                             ^~~~~~~~~~~~~~~~
      |                             |
      |                             struct Lisp_X * (*)(struct Lisp_X
*, struct Lisp_X *, struct Lisp_X *, struct Lisp_X *, struct Lisp_X *)
In file included from ../../src/src/comp.c:23:
../../src/src/lisp.h:4160:47: note: expected 'struct Lisp_X *
(*)(struct Lisp_X *, struct Lisp_X *, struct Lisp_X *, struct Lisp_X
*)' but argument is of type 'struct Lisp_X * (*)(struct Lisp_X *,
struct Lisp_X *, struct Lisp_X *, struct Lisp_X *, struct Lisp_X *)'
 4160 | extern Lisp_Object internal_condition_case_4 (Lisp_Object (*)
(Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object), Lisp_Object,
Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object (*)
(Lisp_Object));
      |
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[1]: *** [Makefile:410: comp.o] Error 1
make[1]: Leaving directory
'/home/VWinUser0/Downloads/emacs/native-comp/build/src'
make: *** [Makefile:433: src] Error 2

src/epaths.h has the following content:

$ cat src/epaths.h
/* Hey Emacs, this is -*- C -*- code!  */
/* epaths.in file for MS-Windows build that uses the configure script.

   Since Emacs on Windows must be relocatable to any directory, it
   cannot have here hard-coded directories determined at configure
   time.  Therefore, each directory must begin with %emacs_dir%, which
   is resolved at startup to the root of the Emacs installation tree
   (see w32.c:init_environment).

   This file is edited at configure time to replace @VER@ by the Emacs
   version being built (e.g., 25.9.77), @CFG@ by the canonical name of
   the host system (e.g., i686-pc-mingw32), and @SRC@ by the root of
   the Emacs source tree used to build Emacs.  */
/*
Copyright (C) 1993, 1995, 1997, 1999, 2001-2020 Free Software
Foundation, Inc.

This file is part of GNU Emacs.

GNU Emacs is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */

/* Together with PATH_SITELOADSEARCH, this gives the default value of
   load-path, which is the search path for the Lisp function "load".
   Configure (using "make epaths-force") sets this to
   ${standardlisppath}, which typically has a value like:
   <datadir>/emacs/VERSION/lisp where datadir is eg /usr/local/share.
*/
#define PATH_LOADSEARCH "%emacs_dir%/share/emacs/28.0.50/lisp"
/* Like PATH_LOADSEARCH, but contains the non-standard pieces.
   These are the site-lisp directories.  Configure sets this to
   ${locallisppath}, which typically defaults to something like:
   <datadir>/emacs/VERSION/site-lisp:<datadir>/emacs/site-lisp
   but can be overridden by the --enable-locallisppath argument.
   This is combined with PATH_LOADSEARCH to make the default load-path.
   If the --no-site-lisp option is used, this piece is excluded.
*/
#define PATH_SITELOADSEARCH
"%emacs_dir%/share/emacs/28.0.50/site-lisp;%emacs_dir%/share/emacs/site-lisp"

/* Like PATH_LOADSEARCH, but used only during the build process
   when Emacs is dumping.  Configure (using "make epaths-force-w32") sets
   this to $buildlisppath, which normally has the value: <srcdir>/lisp.
*/
#define PATH_DUMPLOADSEARCH
"C:/msys64/home/VWinUser0/Downloads/emacs/native-comp/src/lisp"

/* The extra search path for programs to invoke.  This is appended to
   whatever the PATH environment variable says to set the Lisp
   variable exec-path and the first file name in it sets the Lisp
   variable exec-directory.  exec-directory is used for finding
   executables and other architecture-dependent files.  */
#define PATH_EXEC "%emacs_dir%/libexec/emacs/28.0.50/x86_64-w64-mingw32"

/* Where Emacs should look for its architecture-independent data
   files, like the NEWS file.  The lisp variable data-directory
   is set to this value.  */
#define PATH_DATA "%emacs_dir%/share/emacs/28.0.50/etc"

/* Where Emacs should look for X bitmap files.
   The lisp variable x-bitmap-file-path is set based on this value.  */
#define PATH_BITMAPS ""

/* Where Emacs should look for its docstring file.  The lisp variable
   doc-directory is set to this value.  */
#define PATH_DOC "%emacs_dir%/share/emacs/28.0.50/etc"

/* Where the configuration process believes the info tree lives.  The
   lisp variable configure-info-directory gets its value from this
   macro, and is then used to set the Info-default-directory-list.  */
#define PATH_INFO "%emacs_dir%/share/info"

/* Where Emacs should store game score files.  */
#define PATH_GAME "%emacs_dir%/var/games/emacs"

/* Where Emacs should look for the application default file. */
#define PATH_X_DEFAULTS ""