mxe/plugins/examples/host-toolchain
Boris Nagaev 6adb5ade12 Copyright headers: point to LICENSE.md and shorten
The following script was applied:

    sed ':a;/part of MXE.$/{N;s/\n//;ba}' -i $(git grep -l 'part of MXE')

    sed 's/\(part of MXE\).*\(See index.html\)/\1. \2/' -i \
        $(git grep -l 'part of MXE.*See index.html')

    before='This file is part of MXE. See index.html for further information.'
    after='This file is part of MXE. See LICENSE.md for licensing information.'
    sed "s/$before/$after/" -i $(git grep -l 'part of MXE')

Then git grep 'index.html for further information' revealed two other files.
One of them was patched manually (patch.mk). Makefile has text
"See index.html for further information" unrelated to licensing.

See https://github.com/mxe/mxe/issues/1500#issuecomment-241340792
2016-08-27 12:31:29 +03:00
..
README.md host-toolchain plugin: fix shared libgcc and qt tools 2016-08-07 02:11:13 +10:00
binutils-host.mk Copyright headers: point to LICENSE.md and shorten 2016-08-27 12:31:29 +03:00
cmake-host.mk Copyright headers: point to LICENSE.md and shorten 2016-08-27 12:31:29 +03:00
gcc-host.mk Copyright headers: point to LICENSE.md and shorten 2016-08-27 12:31:29 +03:00
make-w32-bin.mk Copyright headers: point to LICENSE.md and shorten 2016-08-27 12:31:29 +03:00
pkgconf-host.mk Copyright headers: point to LICENSE.md and shorten 2016-08-27 12:31:29 +03:00
qt5-host-tools.mk Copyright headers: point to LICENSE.md and shorten 2016-08-27 12:31:29 +03:00
winpthreads-host.mk Copyright headers: point to LICENSE.md and shorten 2016-08-27 12:31:29 +03:00

README.md

Cross Compiling a Host Toolchain

This plugin demonstrates a minimal working toolchain built with MXE to execute on a Windows host.

GCC

make gcc-host MXE_PLUGIN_DIRS=plugins/examples/host-toolchain/

This will run the usual steps to build a cross-compiler, then build a second pass to cross-compile the basic toolchain (binutils and gcc).

Once complete, copy usr/{target} to an appropriate Windows machine and execute the usr\{target}\bin\test-gcc-host.bat batch file. This builds and runs the libgomp test as a sanity check. The cross and host built programs should be identical (after stripping), confirmed with the final step:

>fc /b test-gcc-host.exe test-pthreads-libgomp.exe
Comparing files test-gcc-host.exe and TEST-PTHREADS-LIBGOMP.EXE
FC: no differences encountered

CMake

make cmake-host MXE_PLUGIN_DIRS=plugins/examples/host-toolchain/

CMake defaults to Visual Studio generators and additional configuration is required for MinGW or MSYS Makefiles. MinGW uses cmd.exe and requires mingw32-make, MSYS uses make and requires /bin/sh. The latter is recommended for further investigation since it's closest to the normal environment MXE expects. See the following projects for shells and terminal emulators:

Make

Make is difficult to cross-compile so it is downloaded from the source recommended by the GNU Make team.

pkgconf/pkg-config

make pkgconf-host MXE_PLUGIN_DIRS=plugins/examples/host-toolchain/

This will cross-compile pkgconf and create the pkg-config wrapper. The wrapper requires /bin/sh so one of the MSYS2 options should be used. Run the usr/{target}/bin/test-pkgconf-host script to build libffi test with non-standard include paths.

Qt5 tools (qmake.exe, rcc.exe, etc.)

make qt5-host-tools MXE_PLUGIN_DIRS=plugins/examples/host-toolchain/

This will build qtbase, cross-compile the toolchain and qt tools, and download make binaries.

On a windows machine, execute usr\{target}\qt5\test-qt5-host-tools\test-qt5-host-tools.bat to build and confirm the normal qt test with the cross-compiled qtbase libraries.

Why?

Simply for curiosity, it's hard to see a practical use for this. Certainly, attempting to use it as a way to bootstrap MXE on Windows would strain one's sanity and cross-compiling is the recommended way (even if that means running a Linux VM on Windows).