emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: The 'cross' directory


From: Helmut Eller
Subject: Re: The 'cross' directory
Date: Wed, 16 Aug 2023 23:32:46 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

On Tue, Aug 15 2023, Eli Zaretskii wrote:

>> From: Helmut Eller <eller.helmut@gmail.com>
>> Is it possible/easy to cross-compile Emacs for Windows on a Unix
>> machine?  Possibly with the help of Wine for dumping.
>
> Maybe, I don't know.  I never tried, and neither I think has anyone
> else.

I tried it now.  It kinda works, but it's not easy.  What follows is a
summary of the steps that I did, for the unlikely case that somebody is
interested in these things:

1. Run configure with:
   configure --host=x86_64-w64-mingw32 --without-gnutls
    --without-libsystemd --without-xml2 --without-dbus
    --prefix=/z/opt/emacs -C CFLAGS="-g -O1"

   The crucial bit here is the --host argument.  The --without-X
   switches are only needed because the configure script incorrectly
   detects those features.  The --prefix option is probably not needed,
   as I didn't actually call "make install".

2. This produced errors like:
   ./build-aux/msys-to-w32: line 79: pwd: -W: invalid option
  
   The -W option seems to be a cygwin/msys specific option, for printing
   Windows filenames in a form like c:/foo/bar.  I tried to replace this
   with "winepath -w" but that uses the form c:\foo\bar and so it didn't
   work either.  In the end I removed the -W option and edited the
   src/epaths.h file manually.  In particular

   #define PATH_DUMPLOADSEARCH "Z:/emacs-mingw/lisp"

   must be set correctly, otherwise temacs will abort in init_charset.
   
3. Executing "make" goes a bit further, but while building emacsclient
   an error like

   can't open icon file `icons\emacs.ico': No such file or directory

   occurs.  In emacsclient.rc.in, I replaced icons\emacs.ico with
   icons/emacs.ico.  This is probably safe, as emacs.rc.in also uses
   forward slashes.

4. Executing "make" now wants to execute make-docfile.exe, but can't.

   In autoconf terminology, make-docfile is executed on the build
   machine and not on the host machine.  However the Makefiles aren't
   prepared for such a distinction.  For a while I tried to introduce
   CC_FOR_BUILD and CLFAGS_FOR_BUILD variables, patterned after the
   configure scripts of the binutits.  That kinda worked for
   make-docfile, but not well enough make-fingerprint, which is needed a
   bit later and has the same problem.

   So I gave up on CC_FOR_BUILD and instead copied make-docfile and
   make-fingerprint from a normal, non-cross build directory, like

   cp ../emacs-git/lib-src/make-docfile lib-src/make-docfile.exe
   cp ../emacs-git/lib-src/make-fingerprint lib-src/make-fingerprint.exe

5. After that, "make" continues until it wants to run temacs the first
   time.

   To pass this hurdle, I created a script, wine-temacs.sh, that
   basically executes: wine $emacsdir/src/temacs.exe "$@"

   It's a bit more complicated than that, because wine, mysteriously,
   can't print to stderr and instead produces helpful messages of the
   form:

   Z:\emacs-mingw\src\emacs.exe: Write error to standard output: Success

   Maybe my wine installation is just botched.

   Anyway, running temacs with wine actually produces
   bootstrap-emacs.pdmp.

6. Now "make RUN_TEMACS=$(pwd)/src/wine-temacs.sh" wants run bootstrap-emacs
   to produce all the .elc files.

   For that I wrote another script, wine-bootstrap-emacs.sh, that just
   like wine-temacs.sh, runs bootstrap-emacs.exe in wine.

7. Now "make RUN_TEMACS=$(pwd)/src/wine-temacs.sh \
             bootstrap_exe=$(pwd)/src/wine-bootstrap-emacs.sh"
   wants to compile the .elc files.

   This would be slow, so I aborted and instead copied all the .elc
   files from the non-cross build and touched them like

   find . -name '*.elc' -exec touch {} +

   so that Make would consider them new.

8. Even with all the .elc files in place, make still wants to execute
   bootstrap-emacs for things like

   GEN ../lisp/leim/quail/CCDOSPY.el
   or
   GEN ../../lisp/cedet/semantic/bovine/c-by.el
   or
   ELC ../lisp/loaddefs.elc

   I just waited and let it proceed, as I didn't know any shortcuts.

9. Eventually it creates the all important emacs.pdmp.

   At that point make, still wants to continue, this time executing
   emacs.exe.  For which I wrote the thirt script, wine-emacs.sh, which
   does again the usual.

10. Now "make RUN_TEMACS=$(pwd)/src/wine-temacs.sh \
              bootstrap_exe=$(pwd)/src/wine-bootstrap-emacs.sh \
              EMACS=$(pwd)/src/wine-emacs.sh"
    still doesn't stop and produces things like

    GEN      autoloads
    ...
    ELC      cedet/semantic/grammar-wy.elc
    ...
    GEN      org.texi
    ...

11. Eventually it aborts with

    ***  "make all" succeeded, but Emacs is not functional.

    The filename used in the sanity-check can't be easily overriden so I
    stopped here.

Executing "wine src/emacs.exe" does however start an GUI Emacs and at
least the basic things seem to work.  "wine src/emacs.exe -nw" mostly
works, but some keys like, C-c, '(' and ')' seem to get lost somewhere.
In "wineconsole src/emacs.exe -nw" all keys seem to work as expected,
but it's a "choppy" experience as wine (or emacs) seems to sleep for a
moment after every few keystrokes.

It also starts on a real Windows laptop.  I used sshfs to mount the
build directory and executed emacs.exe there.  So that wasn't a proper
installation as "make install" would, of course, not have worked on
Windows.

Helmut



reply via email to

[Prev in Thread] Current Thread [Next in Thread]