Merge pull request #1397 from tonytheodore/host-toolchain

Add host toolchain example plugin
This commit is contained in:
Tony Theodore 2016-06-19 23:27:46 +10:00 committed by GitHub
commit cead35df4a
6 changed files with 104 additions and 7 deletions

View File

@ -0,0 +1,24 @@
Cross Compiling a Host Toolchain
--------------------------------
This plugin demonstrates a minimal working toolchain built with MXE to
execute on a Windows host. To build:
```
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.
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).

View File

@ -0,0 +1,26 @@
# This file is part of MXE.
# See index.html for further information.
PKG := binutils-host
$(PKG)_IGNORE = $(binutils_IGNORE)
$(PKG)_VERSION = $(binutils_VERSION)
$(PKG)_CHECKSUM = $(binutils_CHECKSUM)
$(PKG)_SUBDIR = $(binutils_SUBDIR)
$(PKG)_FILE = $(binutils_FILE)
$(PKG)_URL = $(binutils_URL)
$(PKG)_URL_2 = $(binutils_URL_2)
$(PKG)_DEPS := gcc
define $(PKG)_UPDATE
echo $(binutils_VERSION)
endef
define $(PKG)_BUILD
$(subst --disable-werror,\
--disable-werror \
--prefix='$(PREFIX)/$(TARGET)' \
--host='$(TARGET)',\
$(binutils_BUILD))
#rm -rf '$(PREFIX)/$(TARGET)/$(TARGET)'
endef

View File

@ -0,0 +1 @@
src/gcc-1.patch

View File

@ -0,0 +1,50 @@
# This file is part of MXE.
# See index.html for further information.
PKG := gcc-host
$(PKG)_IGNORE = $(gcc_IGNORE)
$(PKG)_VERSION = $(gcc_VERSION)
$(PKG)_CHECKSUM = $(gcc_CHECKSUM)
$(PKG)_SUBDIR = $(gcc_SUBDIR)
$(PKG)_FILE = $(gcc_FILE)
$(PKG)_URL = $(gcc_URL)
$(PKG)_URL_2 = $(gcc_URL_2)
$(PKG)_DEPS := gcc binutils-host cloog gmp isl mpfr mpc
define $(PKG)_UPDATE
echo $(gcc_VERSION)
endef
define $(PKG)_BUILD
mkdir '$(1).build'
cd '$(1).build' && '$(1)/configure' \
--host='$(TARGET)' \
--target='$(TARGET)' \
--build='$(BUILD)' \
--prefix='$(PREFIX)/$(TARGET)' \
--with-native-system-header-dir='$(PREFIX)/$(TARGET)/include' \
--enable-languages='c,c++,objc,fortran' \
--enable-version-specific-runtime-libs \
--with-gcc \
--with-gnu-ld \
--with-gnu-as \
--disable-nls \
$(if $(BUILD_STATIC),--disable-shared) \
--disable-multilib \
--without-x \
--disable-win32-registry \
--enable-threads=$(MXE_GCC_THREADS) \
--enable-libgomp \
--with-{cloog,gmp,isl,mpc,mpfr}='$(PREFIX)/$(TARGET)'
$(MAKE) -C '$(1).build' -j '$(JOBS)'
$(MAKE) -C '$(1).build' -j 1 install
# test compilation on host
cp '$(TOP_DIR)/src/pthreads-libgomp-test.c' '$(PREFIX)/$(TARGET)/bin/test-$(PKG).c'
(printf 'set PATH=..\\bin;%%PATH%%\r\n'; \
printf 'gcc test-$(PKG).c -o test-$(PKG).exe -fopenmp -v\r\n'; \
printf 'test-$(PKG).exe\r\n'; \
printf 'pause\r\n';) \
> '$(PREFIX)/$(TARGET)/bin/test-$(PKG).bat'
endef

View File

@ -22,13 +22,11 @@ define $(PKG)_UPDATE
tail -1
endef
define $(PKG)_BUILD_$(BUILD)
define $(PKG)_BUILD
cd '$(1)' && ./configure \
$(MXE_CONFIGURE_OPTS) \
--with-gmp-prefix='$(PREFIX)/$(TARGET)' \
--with-isl-prefix='$(PREFIX)/$(TARGET)'
$(MAKE) -C '$(1)' -j '$(JOBS)'
$(MAKE) -C '$(1)' -j '$(JOBS)' $(if $(BUILD_SHARED),LDFLAGS=-no-undefined)
$(MAKE) -C '$(1)' -j '$(JOBS)' install
endef
$(PKG)_BUILD_SHARED =

View File

@ -26,8 +26,6 @@ define $(PKG)_BUILD
cd '$(1)' && ./configure \
$(MXE_CONFIGURE_OPTS) \
--with-gmp-prefix='$(PREFIX)/$(TARGET)'
$(MAKE) -C '$(1)' -j '$(JOBS)'
$(MAKE) -C '$(1)' -j '$(JOBS)' $(if $(BUILD_SHARED),LDFLAGS=-no-undefined)
$(MAKE) -C '$(1)' -j '$(JOBS)' install
endef
$(PKG)_BUILD_SHARED =