Just in case this helps (sorry I did not have time to split up this into separate bug reports, but it will help [I hope] fix the problems encountered): here are the notes/hacks/command lines I used to build a recent gccemacs on my Win10 machine with mingw64:
#+begin_src shell :exports code
git rev-parse HEAD feature/native-comp
#+end_src
: 682bd303470d4a0fcd2690aff6aa58fb720a8d41
: 682bd303470d4a0fcd2690aff6aa58fb720a8d41
#+begin_src shell :exports code
pacman -S --needed base-devel \
mingw-w64-x86_64-toolchain \
mingw-w64-x86_64-xpm-nox \
mingw-w64-x86_64-libtiff \
mingw-w64-x86_64-giflib \
mingw-w64-x86_64-libpng \
mingw-w64-x86_64-libjpeg-turbo \
mingw-w64-x86_64-librsvg \
mingw-w64-x86_64-lcms2 \
mingw-w64-x86_64-jansson \
mingw-w64-x86_64-libxml2 \
mingw-w64-x86_64-gnutls \
mingw-w64-x86_64-zlib \
mingw-w64-x86_64-harfbuzz \
mingw-w64-x86_64-libgccjit
PROCESSORS_TO_USE="3"
EMACS_VERSION=emacs-native-comp
./autogen.sh
# edit nt/epaths.nt to add PATH_REL_LOADSEARCH:
grep -q PATH_REL_LOADSEARCH nt/epaths.nt || echo '#define PATH_REL_LOADSEARCH ""' >> nt/epaths.nt
# patch to look for libgccjit-0.dll instead of libgcc.dll? 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
# 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 parsing
# because the statement is incomplete?) and to adapt to (new) 5th parameter to
# directory-files
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), Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object (*) (Lisp_Object));' src/lisp.h
sed -i -e '/Like internal_condition_case_1 but call BFUN with ARG1, ARG2, ARG3, ARG4 as/ {
s/ARG4 as/ARG4, ARG5 as/
a its arguments. */
a Lisp_Object
a internal_condition_case_5 (Lisp_Object (*bfun) (Lisp_Object, Lisp_Object,
a Lisp_Object, Lisp_Object,
a Lisp_Object),
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_Object))
a {
a struct handler *c = push_handler (handlers, CONDITION_CASE);
a if (sys_setjmp (c->jmp))
a {
a Lisp_Object val = handlerlist->val;
a clobbered_eassert (handlerlist == c);
a handlerlist = handlerlist->next;
a return hfun (val);
a }
a else
a {
a Lisp_Object val = bfun (arg1, arg2, arg3, arg4, arg5);
a eassert (handlerlist == c);
a handlerlist = c->next;
a return val;
a }
a }
a /* Like internal_condition_case_1 but call BFUN with ARG1, ARG2, ARG3, ARG4 as
}' src/eval.c
sed -i -e '/PATH_EXEC, 0);/ {
s/.*/#ifdef WINDOWSNT/
a /* On MS-Windows, PATH_EXEC normally starts with a literal
a "%emacs_dir%", so it will never work without some tweaking. */
a w32_relocate (PATH_EXEC),
a #else
a PATH_EXEC,
a #endif
a 0);
}' src/callproc.c
mkdir -p ../build
cd ../build
../emacs/configure \
--with-xml2 \
--without-pop \
--prefix="/home/cramaph1/$EMACS_VERSION/dest" \
--without-compress-install \
--without-dbus \
--with-nativecomp \
--with-modules 'CFLAGS=-O2 -g3' 'LIBGCCJIT=-lz -lgccjit'
sed -i -e 's/^LIBGCCJIT = *$/LIBGCCJIT = -lz -lgccjit/' src/Makefile
make -j"$PROCESSORS_TO_USE"
make install
#+end_src