mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-08 10:23:03 +00:00
README.MinGW-cross: Tell the user to provide native substitutes for every .exe file in the cross-compiler installation.
77 lines
2.8 KiB
Plaintext
77 lines
2.8 KiB
Plaintext
-----------------------------------------------------------------------------
|
|
|
|
COMPILING MERCURY WITH A MINGW / MINGW-W64 CROSS-COMPILER
|
|
|
|
You can compile Mercury on Linux with a MinGW or MinGW-w64 cross-compiler.
|
|
After copying and adjusting some paths, the Mercury installation should be
|
|
usable on Windows. When combined with a native Mercury compiler, it can be
|
|
used to cross-compile Mercury applications for Windows.
|
|
|
|
NOTE: There are currently problems with 64-bit executables in the 'asm_fast*'
|
|
grade. The 'none*' and 'reg*' grades do appear to work correctly in our
|
|
limited testing.
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
PREREQUISITES
|
|
|
|
We assume you are on Linux. You will need a native Mercury installation
|
|
installed in the normal way. The native Mercury version should match the
|
|
version of Mercury you intend to cross-compile.
|
|
|
|
You need a MinGW or MinGW-w64 cross-compiler, and a pthreads implementation.
|
|
Many Linux distributions will have packages available, e.g. gcc-mingw32 and
|
|
friends on Debian. Otherwise, you may try <http://mxe.cc/>.
|
|
|
|
git clone -b stable https://github.com/mxe/mxe.git
|
|
cd mxe
|
|
make gcc pthreads JOBS=6
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
INSTALLATION
|
|
|
|
Ensure that the MinGW cross-compiler i686-pc-mingw-gcc or similar is in your
|
|
PATH. In a fresh copy of the Mercury source tree, run the following in place
|
|
of the configure script:
|
|
|
|
tools/configure_mingw_cross [--host=HOST] OPTIONS...
|
|
|
|
If your installation uses a host triplet other than "i686-pc-mingw32" then
|
|
you must pass that using the --host= option. You may pass other options
|
|
through to configure as well, e.g.
|
|
|
|
tools/configure_mingw_cross \
|
|
--host=x86_64-w64-mingw32 \
|
|
--prefix=/usr/local/mercury-mingw
|
|
|
|
Then install Mercury as usual:
|
|
|
|
mmake install -j6
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
USING THE CROSS-COMPILER ON LINUX
|
|
|
|
To use the cross-compiled installation on Linux, you must provide Linux
|
|
binaries to substitute each of the .exe files in the bin directory.
|
|
The Linux binaries should be from the same version of the Mercury compiler.
|
|
|
|
For example, you can run a command such as below to hard link the binaries
|
|
from the native compiler to the cross-compiler installation, or add the '-s'
|
|
option to create symbolic links instead. Be careful not to overwrite the
|
|
shell scripts.
|
|
|
|
ln /usr/local/mercury/bin/* /usr/local/mercury-mingw/bin || true
|
|
|
|
Now you can run the 'mmc' script from the cross-compiled installation:
|
|
|
|
% /usr/local/mercury-mingw/bin/mmc -m hello
|
|
Making Mercury/int3s/hello.int3
|
|
Making Mercury/ints/hello.int
|
|
Making Mercury/cs/hello.c
|
|
Making Mercury/os/hello.o
|
|
Making hello.exe
|
|
|
|
-----------------------------------------------------------------------------
|