mirror of
https://git.code.sf.net/p/mingw-w64/mingw-w64
synced 2024-11-23 18:04:18 +08:00
Update build guide and add advance guide
git-svn-id: svn+ssh://svn.code.sf.net/p/mingw-w64/code/trunk@1466 4407c894-4637-0410-b4f5-ada5f102cad1
This commit is contained in:
parent
61e46119da
commit
cacfe78743
427
mingw-w64-doc/howto-build/mingw-w64-howto-build-adv.txt
Executable file
427
mingw-w64-doc/howto-build/mingw-w64-howto-build-adv.txt
Executable file
@ -0,0 +1,427 @@
|
||||
The Advance Guide to
|
||||
Building the Mingw-w64 x86_64-w64-mingw32 cross-compiler
|
||||
|
||||
== About this document ==
|
||||
|
||||
This document describes more advanced methods in building the mingw-w64
|
||||
cross compiler. It also includes details about the toolchain
|
||||
dependencies and relevant options that can be passed to the GCC
|
||||
configure.
|
||||
|
||||
The commands are run under a MSYS/MinGW setup unless specified otherwise.
|
||||
|
||||
== Targeted audience ==
|
||||
|
||||
This document assumes readers are familiar with the UNIX Command Line
|
||||
and building the GNU toolchain in general, but would want a more fine
|
||||
grained control over the capabilities of the cross compiler.
|
||||
|
||||
For a basic guide on building the mingw-w64 toolchain, please refer to
|
||||
"mingw-w64-howto-build.txt".
|
||||
|
||||
== Version changes ==
|
||||
|
||||
Date / Version / Author
|
||||
2009-10-09 1.0 Jonathan Yong <jon_y[a]users.sourceforge.com>
|
||||
|
||||
== Table of Contents ==
|
||||
|
||||
* Some Basic Info about mingw-w64 [SBSCINF]
|
||||
* Host Support Libraries [HOSTLIB]
|
||||
* The GNU MP Bignum Library [BGMPLIB]
|
||||
* MPFR [BMPFRLB]
|
||||
* Multiprecision [BMPCLIB]
|
||||
* The Parma Polyhedra Library [BPPLLIB]
|
||||
* The Clunky Loop Generator (PPL port) [BCLGLIB]
|
||||
* Libelf [BELFLIB]
|
||||
* Target Support Libraries [TGTSPLB]
|
||||
* pthreads-win32 [PTHRW32]
|
||||
* Building the Multilib Cross MinGW-w64 GCC the
|
||||
lazy way(With ADA support and libgomp) [LAZYW64]
|
||||
* ADA Bootstrap Phase [ADABOOT]
|
||||
* MinGW-w64 cross Binutils [CRSBINU]
|
||||
* Install mingw-w64 Headers [MGW64HD]
|
||||
* Setup Symlinks [SETSYML]
|
||||
* Build Core GCC [BCORGCC]
|
||||
* Build the mingw-w64 CRT [BMGWCRT]
|
||||
* Build libgcc [BLIBGCC]
|
||||
* Build pthreads [BPTHR32]
|
||||
* Continue the build [CTNTBLD]
|
||||
|
||||
You can search the keys (i.e. [BMPCLIB]) to jump to that section.
|
||||
|
||||
== Some Basic Info about MinGW-w64 == [SBSCINF]
|
||||
|
||||
MinGW-w64 began as a fork of mingw.org MinGW to support 64bit windows as
|
||||
a target.
|
||||
|
||||
Canonical Triplet info:
|
||||
mingw.org MinGW: i686-pc-mingw32
|
||||
mingw-w64 64bit: x86_64-pc-mingw32 (obsolete triplet)
|
||||
x86_64-w64-mingw32 (preferred triplet)
|
||||
mingw-w64 32bit: i686-pc-mingw32 (mingw.org compatibility mode)
|
||||
i686-w64-mingw32 (preferred triplet)
|
||||
|
||||
== Host Support Libraries == [HOSTLIB]
|
||||
|
||||
These libraries are used by GCC on the "host" side. It means that these
|
||||
should be built for the system that will run the newly built GCC.
|
||||
|
||||
=== The GNU MP Bignum Library (GMP) === [BGMPLIB]
|
||||
|
||||
Homepage: <http://gmplib.org/>
|
||||
Depends on: None
|
||||
Depended by: MPC, MPFR, PPL, CLooG
|
||||
GCC dependency type: Hard (GCC won't build without it)
|
||||
|
||||
GMP is primarily written in C and assembly, but it comes with C++ bindings.
|
||||
The asm part is selected by the $host_cpu detected by configure. If your
|
||||
platform is not detected properly, you can use --host=none-none-none to
|
||||
disable asm optimizations. Be sure to set the correct CC, CXX, NM, RANLIB
|
||||
and AR variables.
|
||||
|
||||
The C++ bindings are not built by default, but it is required by PPL. To fix
|
||||
this, use "--enable-cxx" and "CPPFLAGS=-fexceptions". PPL needs the
|
||||
-fexceptions part to throw exceptions properly, but it is not strictly
|
||||
required.
|
||||
|
||||
On Windows hosts, only static or shared builds can be used at a time, but not
|
||||
both. This is reasoned by the incompatible header set used by static/shared
|
||||
builds. If you do use static builds, you should build any libs that depend on
|
||||
it as static to prevent accidentally exporting GMP symbols in other dlls.
|
||||
|
||||
=== MPFR === [BMPFRLB]
|
||||
|
||||
Homepage: <http://www.mpfr.org/>
|
||||
Depends on: GMP
|
||||
Depended by: None
|
||||
GCC dependency type: Hard (GCC won't build without it)
|
||||
|
||||
MPFR isn't particularly fussy about configure options, so the usual:
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
is fine.
|
||||
|
||||
=== Multiprecision (MPC) === [BMPCLIB]
|
||||
|
||||
Homepage: <http://www.multiprecision.org/>
|
||||
Depends on: GMP
|
||||
Depended by: None
|
||||
GCC dependency type: Soft (GCC can build without it)
|
||||
|
||||
MPC isn't particularly fussy about configure options, so the usual:
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
is fine.
|
||||
|
||||
=== The Parma Polyhedra Library (PPL) === [BPPLLIB]
|
||||
|
||||
Homepage: <http://www.cs.unipr.it/ppl/>
|
||||
Depends on: GMP
|
||||
Depended by: PPL
|
||||
GCC dependency type: None (GCC does not use it directly)
|
||||
|
||||
PPL requires that GMP be built with C++ bindings (--enable-cxx) and
|
||||
-fexceptions (to allow exceptions to be thrown across GMP).
|
||||
|
||||
=== The Clunky Loop Generator (PPL port) === [BCLGLIB]
|
||||
|
||||
Homepage: <http://repo.or.cz/w/cloog-ppl.git>
|
||||
Depends on: GMP, PPL
|
||||
Depended by: None
|
||||
GCC dependency type: Soft (GCC can build without it)
|
||||
CLooG isn't particularly fussy about configure options, so the usual:
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
is fine.
|
||||
|
||||
=== Libelf === [BELFLIB]
|
||||
|
||||
Homepage: <http://www.mr511.de/software/english.html>
|
||||
Depends on: None
|
||||
Depended by: None
|
||||
GCC dependency type: Soft (Required for GCC lto support)
|
||||
Libelf isn't particularly fussy about configure options, so the usual:
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
is fine.
|
||||
|
||||
== Target Support Libraries == [TGTSPLB]
|
||||
|
||||
Target support libraries are for use with mingw-w64 itself. It should not
|
||||
be used by the host directly. Hence the target libs will need to be compiled
|
||||
with a compiler targeting mingw-w64.
|
||||
|
||||
=== pthreads-win32 === [PTHRW32]
|
||||
Homepage: <http://sourceware.org/pthreads-win32/>
|
||||
Depends on: None
|
||||
Depended by: None
|
||||
GCC dependency type: Soft (Required for GCC libgomp support)
|
||||
|
||||
Download instructions:
|
||||
cvs -d :pserver:anoncvs@sourceware.org:/cvs/pthreads-win32 login
|
||||
{enter ``anoncvs'' for the password}
|
||||
cvs -d :pserver:anoncvs@sourceware.org:/cvs/pthreads-win32 checkout pthreads
|
||||
|
||||
Patch: <http://sourceware.org/ml/pthreads-win32/2009/msg00030/w64sup.patch>
|
||||
|
||||
Note: pthreads-win32 does not come with a autotools based build system. It
|
||||
uses a Makefile "GNUmakefile" to build the pthreads dll.
|
||||
|
||||
Note: To allow win64 support, apply the patch from the mailing list.
|
||||
|
||||
General Build and install instructions:
|
||||
Step 1) type "make clean GC CROSS=x86_64-w64-mingw32-"
|
||||
Note: The CROSS variable specifies your win64/win32 toolchain
|
||||
triplet prefix.
|
||||
Step 2) copy pthreadGC2.dll to your path
|
||||
Step 3) Install the lib by copying pthreadGC2 as libpthread.a to
|
||||
your GCC libdir
|
||||
Step 4) Copy pthread.h, sched.h and semaphore.h to the GCC include dir
|
||||
Step 5) Edit the pthread.h in your include dir and change the following
|
||||
section from:
|
||||
=======================================================================
|
||||
#if HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
=======================================================================
|
||||
to:
|
||||
=======================================================================
|
||||
/* #if HAVE_CONFIG_H */
|
||||
#include "pconfig.h"
|
||||
/* #endif HAVE_CONFIG_H */
|
||||
=======================================================================
|
||||
This is needed to prevent conflicts with other autotools based packages
|
||||
that actually use "config.h" for options.
|
||||
Step 6) Copy the pthread-win32 config.h to your include dir as pconfig.h
|
||||
|
||||
32bit build instructions (mutilib 64bit default GCC)
|
||||
* Edit the GNUmakefile, and change:
|
||||
=======================================================================
|
||||
AR = $(CROSS)ar
|
||||
DLLTOOL = $(CROSS)dlltool
|
||||
CC = $(CROSS)gcc
|
||||
CXX = $(CROSS)g++
|
||||
RANLIB = $(CROSS)ranlib
|
||||
RC = $(CROSS)windres
|
||||
=======================================================================
|
||||
to
|
||||
=======================================================================
|
||||
AR = $(CROSS)ar
|
||||
DLLTOOL = $(CROSS)dlltool -m i386
|
||||
CC = $(CROSS)gcc -m32
|
||||
CXX = $(CROSS)g++ -m32
|
||||
RANLIB = $(CROSS)ranlib
|
||||
RC = $(CROSS)windres -F pe-i386
|
||||
=======================================================================
|
||||
* Next, follow the General Build and install instructions
|
||||
|
||||
== Building the Multilib Cross MinGW-w64 GCC the lazy way ==
|
||||
(With ADA support and libgomp) [LAZYW64]
|
||||
|
||||
Its a lazy method because it involves building GCC with all enabled
|
||||
front ends only once, without restarting the cross GCC build.
|
||||
|
||||
First of all, your host compiler (usually "gcc") must support ADA.
|
||||
If your platform does not have GNAT binaries, use the binaries from:
|
||||
<https://libre.adacore.com/libre/download/>
|
||||
|
||||
If you do not want ADA support, or confident about your host ADA support,
|
||||
you can skip the ADA bootstrap phase.
|
||||
|
||||
=== ADA Bootstrap Phase === [ADABOOT]
|
||||
|
||||
Bootstrapping ADA is needed if ADA is to be supported by the mingw-w64
|
||||
cross GCC.
|
||||
|
||||
To begin bootstrap ADA, you must grab the GCC source that will be used
|
||||
for the mingw-w64 cross GCC, so that the ADA support is as close as
|
||||
possible with the target GCC version.
|
||||
|
||||
Use the source to build a native compiler for your host machine. You must
|
||||
enable at least C, ADA, and C++ support. It is advisable to prefix
|
||||
(i.e. using --prefix=/opt/test) the entire native bootstrap toolchain
|
||||
in order to avoid overwriting the compiler provided by your host system.
|
||||
You should also build a prefixed native Binutils for use with the new
|
||||
bootstrap compiler.
|
||||
|
||||
Remember to build GCC OUTSIDE its source directory, NOT inside it and
|
||||
certainly NOT in a sub-directory.
|
||||
|
||||
=== MinGW-w64 cross Binutils === [CRSBINU]
|
||||
|
||||
The official method to build the mingw-w64 toolchain is to set --prefix
|
||||
and --with-sysroot to the same directory to allow the toolchain to be
|
||||
relocatable. To make Multilib support possible, you need to use
|
||||
"--enable-targets=x86_64-w64-mingw32,i686-w64-mingw32".
|
||||
|
||||
An example configure line for Binutils is:
|
||||
../path/to/binutils/configure --prefix=<prefix> --with-sysroot=<prefix> \
|
||||
--enable-targets=x86_64-w64-mingw32,i686-w64-mingw32 \
|
||||
--host=<build triplet> --build=<build triplet> \
|
||||
--target=x86_64-w64-mingw32
|
||||
|
||||
=== Install mingw-w64 Headers === [MGW64HD]
|
||||
|
||||
When you checkout the svn trunk from the mingw-w64 developer repository, there
|
||||
should be a directory called mingw-w64-headers. Install it with:
|
||||
../path/to/mingw-w64-headers/configure --prefix=<prefix> \
|
||||
--with-sdks=none --build=<host triplet> --host=x86_64-w64-mingw32
|
||||
make install
|
||||
|
||||
To view the available sdks, use --help. The prefix should be similar to the
|
||||
prefix used for cross Binutils. Although the mingw-w64 cross GCC is not
|
||||
installed yet, configure will not fail it as it only checks the --host option.
|
||||
It is important to set the --host option correctly, failing to do so will
|
||||
cause the cross GCC to fail to find the expected system headers.
|
||||
|
||||
=== Setup Symlinks === [SETSYML]
|
||||
|
||||
Your install root for the mingw-w64 cross toolchain should contain the
|
||||
following directories. Create the directories if missing. It is easier
|
||||
to use "ln -s" softlinks to link directories than to copy them over.
|
||||
|
||||
<root>/x86_64-w64-mingw32
|
||||
<root>/x86_64-w64-mingw32/include [headers previously installed here]
|
||||
<root>/x86_64-w64-mingw32/lib
|
||||
<root>/x86_64-w64-mingw32/lib32
|
||||
<root>/x86_64-w64-mingw32/lib64 [link to neighbor lib]
|
||||
<root>/mingw [link to x86_64-w64-mingw32]
|
||||
<root>/mingw/include
|
||||
<root>/mingw/lib
|
||||
<root>/mingw/lib32
|
||||
<root>/mingw/lib64 [link to neighbor lib]
|
||||
|
||||
On Windows, you can use "ntfs link" <http://elsdoerfer.name/=ntfslink>
|
||||
to create "junction points" to link directories. These junction points
|
||||
are transparent to user mode applications such as GCC.
|
||||
|
||||
Make sure the "mingw" directory mirrors "x86_64-w64-mingw32" exactly. Ditto
|
||||
for "lib64" and "lib"
|
||||
|
||||
=== Build Core GCC === [BCORGCC]
|
||||
|
||||
GCC can be configured in many ways, the following is an example that worked.
|
||||
Make sure to add your cross Binutils binaries to your $PATH before continuing.
|
||||
|
||||
If you did use the ADA compiler from adacore to produce a bootstrap ADA
|
||||
compiler, make sure to add the prefix in such a way that it is found
|
||||
before your default host compiler.
|
||||
(i.e. export PATH=/opt/adaboot/bin:$PATH:/mingw64/path/bin)
|
||||
|
||||
Some of the configure options do not sound possible with a stage-1 cross,
|
||||
but be assured that it has been tested.
|
||||
|
||||
Remember to build GCC OUTSIDE its source directory, NOT inside it and certainly
|
||||
NOT in a sub-directory.
|
||||
|
||||
Example:
|
||||
../gcc-trunk/configure --{host,build}=<build triplet> \
|
||||
--target=x86_64-w64-mingw32 --enable-multilib --enable-64bit \
|
||||
--{prefix,with-sysroot}=<prefix> --enable-version-specific-runtime-libs \
|
||||
--enable-shared --with-dwarf --enable-fully-dynamic-string \
|
||||
--enable-languages=c,ada,c++,fortran,objc,obj-c++ --enable-libgomp \
|
||||
--enable-libssp --enable-lto --with-host-libstdcxx="-lstdc++ -lsupc++" \
|
||||
--with-{gmp,mpfr,mpc,cloog,ppl,libelf}=<host dir>
|
||||
|
||||
Explanation:
|
||||
--enable-version-specific-runtime-libs
|
||||
Installs libgcc/libstdc++ and other target support libraries in such a
|
||||
way that multiple GCC installs can coexist simultaneously.
|
||||
|
||||
--enable-shared
|
||||
Builds shared support libraries
|
||||
|
||||
--with-dwarf
|
||||
Use Dwarf debugging format by default
|
||||
|
||||
--enable-fully-dynamic-string
|
||||
Enable dynamic std::string class to work around lazy initialization.
|
||||
|
||||
--enable-libgomp
|
||||
Enable OpenMP support, it is not enabled by default on MinGW platforms.
|
||||
Requires pthreads-win32 (target) installed.
|
||||
|
||||
--enable-libssp
|
||||
Enable Stack Smash Protection, a buffer overrun detector.
|
||||
|
||||
--with-host-libstdcxx
|
||||
Lists down the C++ support libraries to link with. This is useful
|
||||
when using static PPL and CLooG.
|
||||
|
||||
--enable-lto
|
||||
Enable Link-Time Optimization. Requires libelf (host) installed.
|
||||
|
||||
--with-{gmp,mpfr,mpc,cloog,ppl,libelf}=<host dir>
|
||||
Tells GCC where the host support libraries are installed to.
|
||||
(i.e. search <host dir>/include & <host dir>/lib)
|
||||
|
||||
Use "make all-gcc" to build the standalone GCC compiler without target
|
||||
support libs. Install it with "make install-gcc".
|
||||
|
||||
Remember, this is a standalone gcc, it won't actually be able to link
|
||||
executables, but it is already suitable to compile the CRT.
|
||||
|
||||
Do not delete the GCC build directory, we can continue later.
|
||||
|
||||
=== Build the mingw-w64 CRT === [BMGWCRT]
|
||||
|
||||
When you checkout the svn trunk from the mingw-w64 developer repository, there
|
||||
should be a directory called mingw-w64-crt.
|
||||
Example configure:
|
||||
../path/to/crt/configure --prefix=<prefix> --enable-lib32 \
|
||||
--enable-lib64 --build=<build triplet> --host=x86_64-w64-mingw32
|
||||
|
||||
Explanation:
|
||||
--enable-lib32
|
||||
If you enabled multilib support in x86_64-w64-mingw32-gcc, this will build
|
||||
32bit libs for use with win32 programming. For $host_cpu i686-w64-mingw32,
|
||||
it is enabled by default.
|
||||
|
||||
--enable-lib64
|
||||
Enable building 64bit libs for use with win64 programming. For $host_cpu
|
||||
x86_64-w64-mingw32, it is enabled by default.
|
||||
|
||||
If you used symlinks or ntfs junction points to link the "lib*" directories,
|
||||
you should be fine. If you manually copied x86_64-w64-mingw32 to mingw, you
|
||||
must copy the "lib*" directories so that "lib64" mirrors "lib" and
|
||||
"lib32" in "mingw" mirrors "x86_64-w64-mingw32/lib32"
|
||||
|
||||
=== Build libgcc === [BLIBGCC]
|
||||
|
||||
Reenter the build directory used earlier in [BCORGCC], and issue
|
||||
"make all-target-libgcc", then "make install-target-libgcc".
|
||||
|
||||
This will install libgcc. As of writing, there is a minor bug when
|
||||
--enable-version-specific-runtime-libs is used, libgcc_s.a is
|
||||
installed incorrectly.
|
||||
|
||||
Move it from:
|
||||
<prefix>/lib/gcc/<arch>/lib32/libgcc_s.a to
|
||||
<prefix>/lib/gcc/<arch>/<version>/32/libgcc_s.a
|
||||
and
|
||||
<prefix>/lib/gcc/<arch>/lib64/libgcc_s.a to
|
||||
<prefix>/lib/gcc/<arch>/<version>/libgcc_s.a
|
||||
|
||||
The libgcc dll is also clobbered during install, search the build
|
||||
directory for the dll and install it to separate directories as you
|
||||
see fit. Make sure 32bit apps only see the 32bit variant, same for
|
||||
64bit apps.
|
||||
|
||||
=== Build pthreads === [BPTHR32]
|
||||
|
||||
pthread-win32 is required for libgomp to work. Now that the CRT and
|
||||
libgcc is installed, we can proceed with building the pthread dll.
|
||||
|
||||
Please refer to the pthreads-win32 section [PTHRW32] for instructions.
|
||||
Make sure to build for both win32 and win64 variants.
|
||||
|
||||
=== Continue the build === [CTNTBLD]
|
||||
|
||||
Reenter the build directory used earlier in [BCORGCC] and continue
|
||||
the build with "make". Finally, install with "make install".
|
||||
|
@ -1,5 +1,7 @@
|
||||
How to build a Mingw-w64 x86_64-w64-mingw32 cross-compiler.
|
||||
|
||||
== About this document ==
|
||||
|
||||
(At this time, building a native compiler is suggested. Documentation
|
||||
to follow. This is all still required to be able to build it.)
|
||||
Top-level configure to do this all with one command is also to follow.
|
||||
@ -10,25 +12,53 @@ mingw.org's MinGW.
|
||||
|
||||
All default libraries work! We are now in a functional beta stage.
|
||||
|
||||
Date / Version / Author
|
||||
2007-07-31 1.0 Kai Tietz <Kai.Tietz at onevision.com>
|
||||
2007-08-20 1.1 Kai Tietz <Kai.Tietz at onevision.com>
|
||||
2007-08-21 1.2 NightStrike <nightstrike at gmail.com>
|
||||
2007-10-01 1.3 NightStrike <nightstrike at gmail.com>
|
||||
2007-11-27 1.4 NightStrike <nightstrike at gmail.com>
|
||||
2009-05-31 1.5 Xenofears <xenofears at gmail.com>
|
||||
2009-06-06 1.6 Xenofears <xenofears at gmail.com>
|
||||
2009-08-28 1.7 Xenofears <xenofears at gmail.com>
|
||||
2009-08-30 1.8 <sezeroz at gmail dot com>
|
||||
|
||||
This file describes how to build the Mingw-w64 gcc toolchain as a cross-compiler
|
||||
This file describes how to build the Mingw-w64 GCC toolchain as a cross-compiler
|
||||
on Cygwin, MinGW with MSys, and *nix shells.
|
||||
|
||||
Cygwin 1.5 and 1.7 currently in beta testing are both supported. This document
|
||||
recommends and assumes Bash (for Cygwin, Unix), or MSys core sh default shells
|
||||
are used.
|
||||
|
||||
== Requirements ==
|
||||
== Targeted audience ==
|
||||
|
||||
This document is written to help those new to building the mingw-w64 cross
|
||||
compilers on Windows using MSYS/MinGW and Cygwin. It can also be adapted
|
||||
slightly for building the mingw-w64 cross compiler on Linux.
|
||||
|
||||
For a more advanced guide on building the mingw-w64 cross compiler including
|
||||
the optional dependencies, please refer to the "mingw-w64-howto-build-adv.txt"
|
||||
guide.
|
||||
|
||||
== Version changes ==
|
||||
|
||||
Date / Version / Author
|
||||
2007-07-31 1.0 Kai Tietz <Kai.Tietz at onevision.com>
|
||||
2007-08-20 1.1 Kai Tietz <Kai.Tietz at onevision.com>
|
||||
2007-08-21 1.2 NightStrike <nightstrike at gmail.com>
|
||||
2007-10-01 1.3 NightStrike <nightstrike at gmail.com>
|
||||
2007-11-27 1.4 NightStrike <nightstrike at gmail.com>
|
||||
2009-05-31 1.5 Xenofears <xenofears at gmail.com>
|
||||
2009-06-06 1.6 Xenofears <xenofears at gmail.com>
|
||||
2009-08-28 1.7 Xenofears <xenofears at gmail.com>
|
||||
2009-08-30 1.8 Ozkan Sezer <sezeroz at gmail dot com>
|
||||
2009-10-09 1.9 Jonathan Yong <jon_y[a]users.sourceforge.com>
|
||||
|
||||
== Table of Contents ==
|
||||
|
||||
* Requirements [RQRMTS]
|
||||
* Optional [OPTNLB]
|
||||
* Download new packages [DWNWPK]
|
||||
* Build type options [BTYOPT]
|
||||
* Building binutils cross toolchain [CRSBNT]
|
||||
* Install the Mingw-w64 header set and create required symlinks [HDRSYM]
|
||||
* Building the GCC core cross-compiler [BDGCOR]
|
||||
* Building the crt [BLDCRT]
|
||||
* Finishing GCC [FNSHGC]
|
||||
* Path update and using your new cross-compiler [PTHUPD]
|
||||
|
||||
You can search the keys (i.e. [BLDCRT]) to jump to that section.
|
||||
|
||||
== Requirements == [RQRMTS]
|
||||
|
||||
You will need a complete GCC toolchain for the host system (Cygwin, MinGW/MSys
|
||||
or Linux), which usually includes all of the required components:
|
||||
@ -37,15 +67,16 @@ or Linux), which usually includes all of the required components:
|
||||
* Binutils (for the native platform)
|
||||
* Bison
|
||||
* Flex
|
||||
* gperf (Optional, for developing on GCC)
|
||||
* Coreutils
|
||||
* Make
|
||||
* GMP 4.2.4 or newer (4.3.1 recommended)
|
||||
* Make (3.81 or newer)
|
||||
* GMP 4.3.1 or newer
|
||||
[found on Cygwin setup under math]
|
||||
* MPFR 2.3.1 or newer (2.4.1 recommended)
|
||||
* MPFR 2.4.1 or newer
|
||||
[found on Cygwin setup under math]
|
||||
* Perl (optional for pod2man)
|
||||
|
||||
== Optional ==
|
||||
== Optional == [OPTNLB]
|
||||
|
||||
Optional for source download / version management:
|
||||
|
||||
@ -59,10 +90,11 @@ elaborated on GMP)
|
||||
|
||||
* PPL 0.10 or newer
|
||||
* ClooG-PPL 0.15 or newer (must be ppl)
|
||||
* MPC 0.6 or newer
|
||||
* MPC 0.7 or newer
|
||||
* Libelf 0.8.12 or newer
|
||||
|
||||
To build with MSys (Minimal SYStem for Win32), to satisfy the requirements
|
||||
download and install functional MinGW (gcc toolchain), MSys (sh shell), bison,
|
||||
download and install functional MinGW (GCC toolchain), MSYS (sh shell), bison,
|
||||
and flex.
|
||||
|
||||
If your host OS is Vista, you must install SP1 or SP2! If you can't, you must
|
||||
@ -71,23 +103,25 @@ use an unoptimized collect2.exe as a workaround, but you are on your own.
|
||||
Win32 installers to use with mingw msys available for download at MinGW's
|
||||
sourceforge page: http://sourceforge.net/project/showfiles.php?group_id=23617
|
||||
|
||||
GMP & MPFR sources may be placed in the gcc source tree root in directories
|
||||
with their names and they will be built automatically by gcc's configure (as
|
||||
GMP & MPFR sources may be placed in the GCC source tree root in directories
|
||||
with their names and they will be built automatically by GCC's configure (as
|
||||
static libs). You might need to make install from inside the directories if
|
||||
gcc doesn't do it for you.
|
||||
GCC doesn't do it for you.
|
||||
|
||||
|
||||
== Download new packages ==
|
||||
== Download new packages == [DWNWPK]
|
||||
|
||||
You need to download the following packages:
|
||||
|
||||
* Binutils 2.19.1 release for stable, or 2.19.51+ or newer or latest
|
||||
snapshot 2.19.51 for experimental as of 06-01-2009.
|
||||
* Binutils 2.19.1 release for stable, or 2.20.51+ or newer or latest
|
||||
snapshot 2.20.51 for experimental as of 08-Oct-2009. As of writing,
|
||||
stable Binutils 2.20.1 is about to be released.
|
||||
|
||||
* GCC version 4.4.1 release for stable, or latest gcc (4.5) snapshot
|
||||
or svn co for experimental as of 06-01-2009. Gcc-4.5 is good for
|
||||
* GCC version 4.4.1 release for stable, or latest GCC (4.5) snapshot
|
||||
or svn co for experimental as of 06-01-2009. GCC-4.5 is good for
|
||||
proper support for the new -w64-, see note above, but is in Stage 1
|
||||
yet and may have bugs. Gcc-4.3 support is no longer maintained.
|
||||
yet and may have bugs. GCC-4.3 support is no longer maintained.
|
||||
As of writing, stable GCC 4.4.2 is about to be released.
|
||||
|
||||
* Current Mingw-w64 release available at
|
||||
http://sourceforge.net/projects/mingw-w64 . Snapshot, even better
|
||||
@ -96,10 +130,10 @@ You need to download the following packages:
|
||||
http://www.cadforte.com/downloads.html , which includes full tree
|
||||
including experimental branch.
|
||||
|
||||
Official releases of gcc and binutils may be downloaded from a GNU FTP mirror
|
||||
from http://www.gnu.org/prep/ftp.html. GCC snapshots may be found at
|
||||
ftp://gcc.gnu.org/pub/gcc/snapshots/ . Binutils snapshots may be found at
|
||||
ftp://sourceware.org/pub/binutils/snapshots/ . Extract the tarballs (i.e.
|
||||
Official releases of GCC and binutils may be downloaded from a GNU FTP mirror
|
||||
from <http://www.gnu.org/prep/ftp.html>. GCC snapshots may be found at
|
||||
<ftp://gcc.gnu.org/pub/gcc/snapshots/>. Binutils snapshots may be found at
|
||||
<ftp://sourceware.org/pub/binutils/snapshots/>. Extract the tarballs (i.e.
|
||||
tar -xf filename.tar.gz) to a temporary folders.
|
||||
|
||||
You can also download the latest working version using SVN & CVS. Both source
|
||||
@ -119,14 +153,20 @@ MSys/MinGW Packages. To use them:
|
||||
(a directory named 'src' will be created and will hold the sources.)
|
||||
|
||||
|
||||
=== Build type options ===
|
||||
=== Build type options === [BTYOPT]
|
||||
|
||||
When building binutils, gcc and Mingw-w64, you will be using standard autotools
|
||||
When building binutils, GCC and Mingw-w64, you will be using standard autotools
|
||||
configure scripts. It is not a good idea to build in the source directory, so
|
||||
you will make a subdirectory in the tree, enter it, and invoke configure with
|
||||
'../configure' (which is then followed by 'make' and then 'make install'.) You
|
||||
will be providing options to the configure script, in the syntax of
|
||||
../configure --flag[=setting]. This will be further detailed below.
|
||||
you will make a sibling directory next to the source tree, enter it, and invoke
|
||||
configure with '../path/to/configure' (which is then followed by 'make' and
|
||||
then 'make install'.) You will be providing options to the configure script,
|
||||
in the syntax of ../path/to/configure --flag[=setting]. This will be further
|
||||
detailed below.
|
||||
|
||||
Note: Do not build GCC in the source tree or in a subdirectory contained in
|
||||
source tree. This generally applies to many other autotools based
|
||||
packages too, unless specifically specified by the package developers
|
||||
or maintainers.
|
||||
|
||||
You have two main choices to make building the cross-compiler toolchain:
|
||||
|
||||
@ -134,7 +174,7 @@ You have two main choices to make building the cross-compiler toolchain:
|
||||
alternate target, using Mingw-w64's lib32), or to disable multilib. Multilib
|
||||
is installed by default, if you don't want it, you have to explicitly disable
|
||||
it by passing --disable-multilib to configure, i.e.
|
||||
../configure --disable-multilib
|
||||
../path/to/configure --disable-multilib
|
||||
|
||||
2) Using standard settings of configure, which installs to /usr/local and
|
||||
requires no setting changes, or to build to a sysroot you designate. /usr/local
|
||||
@ -142,26 +182,26 @@ is universally used as the default install point, and you may wish to keep all
|
||||
the Mingw-w64 (64-bit) in a separate sysroot instead. In the example in these
|
||||
instructions, the sysroot is '/mypath'. To use a sysroot, pass
|
||||
--with-sysroot=/mypath and --prefix=/mypath as configure flags, i.e.
|
||||
../configure --with-sysroot=/mypath --prefix=/mypath
|
||||
../path/to/configure --with-sysroot=/mypath --prefix=/mypath
|
||||
|
||||
|
||||
== Building binutils cross toolchain ==
|
||||
== Building binutils cross toolchain == [CRSBNT]
|
||||
|
||||
Step 1) Enter into the binutils extracted source root folder and create a new
|
||||
folder within (e.g. 'build'). Then enter into it.
|
||||
Step 1) Create a build directory (e.g. 'build'), where binutils compiled object
|
||||
files will be stored. Then enter into it.
|
||||
|
||||
Step 2) Run configure.
|
||||
For multilib:
|
||||
../configure --target=x86_64-w64-mingw32 \
|
||||
../path/to/configure --target=x86_64-w64-mingw32 \
|
||||
--enable-targets=x86_64-w64-mingw32,i686-w64-mingw32
|
||||
|
||||
For no multilib:
|
||||
../configure --target=x86_64-w64-mingw32 \
|
||||
For non-multilib:
|
||||
../path/to/configure --target=x86_64-w64-mingw32 \
|
||||
--disable-multilib
|
||||
|
||||
If using a sysroot, add "--with-sysroot=/mypath --prefix=/mypath" to
|
||||
your configure command, i.e., for multilib:
|
||||
../configure --target=x86_64-w64-mingw32 \
|
||||
../path/to/configure --target=x86_64-w64-mingw32 \
|
||||
--enable-targets=x86_64-w64-mingw32,i686-w64-mingw32 \
|
||||
--with-sysroot=/mypath --prefix=/mypath
|
||||
|
||||
@ -169,17 +209,26 @@ Step 3) Run make (type 'make'). This will take a while.
|
||||
|
||||
Step 4) Run make install (type 'make install')
|
||||
|
||||
Step 5) You may optionally delete the "build" directory to save disk space.
|
||||
|
||||
== Install the Mingw-w64 header set and create required symlinks ==
|
||||
Step 6) If you are using "--prefix" to install binutils to a directory not in
|
||||
your $PATH environmental variable, you should add the "bin" directory
|
||||
to you $PATH, i.e., for binutils installed to /home/luser/mingw64, use
|
||||
the following command to make new cross binutils visible by issuing:
|
||||
export PATH="$PATH:/home/luser/mingw64/bin"
|
||||
This step is required for building GCC later.
|
||||
|
||||
== Install the Mingw-w64 header set and create required symlinks == [HDRSYM]
|
||||
|
||||
Step 1) Enter into the Mingw-w64 source headers. It is in
|
||||
Step 1) The source directory for the headers can be
|
||||
mingw-w64/trunk/mingw-w64-headers, or mingw-w64/mingw-w64-headers
|
||||
depending on your source.
|
||||
|
||||
Step 2) Copy the 'include' directory here into your installation directory's
|
||||
new x86_64-w64-mingw32 subdirectory. So, if using configure default
|
||||
/usr/local, type 'cp -r include /usr/local/x86_64-w64-mingw32'.
|
||||
If using a sysroot, type 'cp -r include /mypath/x86_64-w64-mingw32/'
|
||||
Step 2) Create another "build" directory, and enter it.
|
||||
To install the headers, run:
|
||||
../path/to/configure --build=<your build machine> \
|
||||
--host=x86_64-w64-mingw32 --prefix=/mypath
|
||||
Then run "make install" to install the headers.
|
||||
|
||||
Step 3) GCC requires the x86_64-w64-mingw32 directory be mirrored as a
|
||||
directory 'mingw' in the same root. So, if using configure default
|
||||
@ -189,9 +238,9 @@ Step 3) GCC requires the x86_64-w64-mingw32 directory be mirrored as a
|
||||
ln -s /mypath/x86_64-w64-mingw32 /mypath/mingw
|
||||
|
||||
Step 4) Manually create the x86_64-w64-mingw32/lib directory:
|
||||
mkdir /usr/local/x86_64-w64-mingw32/lib
|
||||
mkdir -p /usr/local/x86_64-w64-mingw32/lib
|
||||
or, for sysroot:
|
||||
mkdir /mypath/x86_64-w64-mingw32/lib
|
||||
mkdir -p /mypath/x86_64-w64-mingw32/lib
|
||||
If it already exists and you get an error, ignore it.
|
||||
|
||||
Step 5) Symlink x86_64-w64-mingw32/lib directory as x86_64-w64-mingw32/lib64:
|
||||
@ -199,87 +248,94 @@ Step 5) Symlink x86_64-w64-mingw32/lib directory as x86_64-w64-mingw32/lib64:
|
||||
or, for sysroot:
|
||||
ln -s /mypath/x86_64-w64-mingw32/lib /mypath/x86_64-w64-mingw32/lib64
|
||||
|
||||
Note: If you are using MSys, you will need to do Step 5 again after building
|
||||
the crt (it will be noted in the instructions.) 'ln -s' makes symlinks, which
|
||||
are kind of like *nix shortcuts, as a major simplification, but MSys doesn't
|
||||
support that and just copies the files instead of making a pointer object.
|
||||
Note: On Windows systems or other systems that do not support UNIX type
|
||||
softlinks, you may copy the entire directory to mirror it. It will
|
||||
have the same effect as a symlink.
|
||||
|
||||
Note: The header-set and crt contains the standard-c and the windows platform
|
||||
headers. Therefore it is not necessary to install an additional package.
|
||||
headers. Therefore it is not necessary to install an additional package.
|
||||
|
||||
|
||||
== Building the gcc core cross-compiler(s) ==
|
||||
== Building the GCC core cross-compiler(s) == [BDGCOR]
|
||||
|
||||
There are no gcc patches required anymore. We keep up with gcc and get any
|
||||
fixes applied upsteam.
|
||||
There are no GCC patches required anymore. We keep up with GCC and get any
|
||||
fixes applied upstream.
|
||||
|
||||
Step 1) Enter into the gcc root folder and generate a folder within (e.g.
|
||||
Step 1) Enter into the GCC root folder and generate a folder within (e.g.
|
||||
'build'), then enter it.
|
||||
|
||||
Step 2) Run configure.
|
||||
For multilib:
|
||||
../configure --target=x86_64-w64-mingw32 --enable-targets=all
|
||||
../path/to/configure --target=x86_64-w64-mingw32 --enable-targets=all
|
||||
To disable multilib:
|
||||
../configure --target=x86_64-w64-mingw32 --disable-multilib
|
||||
../path/to/configure --target=x86_64-w64-mingw32 --disable-multilib
|
||||
|
||||
Add the --prefix=/mypath and --with-sysroot=/mypath flags if you are
|
||||
using a sysroot.
|
||||
Note: Remember to add the --prefix=/mypath and --with-sysroot=/mypath flags
|
||||
to match the binutils build if you are using a sysroot.
|
||||
|
||||
Step 3) Type 'make all-gcc'. This will build the gcc core.
|
||||
Step 3) Type 'make all-gcc'. This will build the GCC core.
|
||||
|
||||
Step 4) Type 'make install-gcc'. This will install the gcc core.
|
||||
Step 4) Type 'make install-gcc'. This will install the GCC core.
|
||||
|
||||
Now the core stuff of gcc is present and we can build the crt itself.
|
||||
Step 5) You can leave the "build" directory alone for now, so you can
|
||||
resume building the rest of GCC later after installing the CRT.
|
||||
|
||||
Now the core stuff of GCC is present and we can build the crt itself.
|
||||
|
||||
|
||||
== Building the crt (Mingw-w64 itself) ==
|
||||
== Building the crt (Mingw-w64 itself) == [BLDCRT]
|
||||
|
||||
Step 1) Put the gcc that you just installed into your PATH.
|
||||
For configure default /usr/local :
|
||||
PATH="/usr/local/bin:$PATH"
|
||||
export PATH
|
||||
For custom sysroot:
|
||||
PATH="/mypath/bin:$PATH"
|
||||
export PATH
|
||||
Step 1) Create a new "build" directory for the crt. Enter the "build" directory.
|
||||
|
||||
Step 2) Enter into the trunk/mingw-w64-crt source directory and generate a
|
||||
directory within (e.g. build), and enter into it.
|
||||
|
||||
Step 3) Run configure.
|
||||
Step 2) Run configure.
|
||||
For multilib:
|
||||
../configure --host=x86_64-w64-mingw32 --enable-lib32
|
||||
../path/to/configure --host=x86_64-w64-mingw32 --enable-lib32
|
||||
(NOTE: This won't work if you disabled multilib!)
|
||||
|
||||
Without multilib:
|
||||
../configure --host=x86_64-w64-mingw32
|
||||
../path/to/configure --host=x86_64-w64-mingw32
|
||||
|
||||
If using sysroot/prefix, again add the the --prefix=/mypath and
|
||||
If using sysroot/prefix, again add the the --prefix=/mypath and
|
||||
--with-sysroot=/mypath flags.
|
||||
|
||||
Step 4) Type make. This will take a while.
|
||||
Step 3) Type make. This will take a while.
|
||||
|
||||
Step 5) Type make install
|
||||
Step 4) Type make install
|
||||
|
||||
Step 6) If you are using MSys/MinGW, repeat Step 5 of 'Install the Mingw-w64
|
||||
header set...'
|
||||
Step 5) Make sure you have the following directories in the directory you
|
||||
have installed the mingw-w64 toolchain to:
|
||||
<root>/x86_64-w64-mingw32
|
||||
<root>/x86_64-w64-mingw32/include
|
||||
<root>/x86_64-w64-mingw32/lib
|
||||
<root>/x86_64-w64-mingw32/lib32
|
||||
<root>/x86_64-w64-mingw32/lib64 [link to lib]
|
||||
<root>/mingw [link to x86_64-w64-mingw32]
|
||||
<root>/mingw/include
|
||||
<root>/mingw/lib
|
||||
<root>/mingw/lib32
|
||||
<root>/mingw/lib64 [link to lib]
|
||||
If you are using MSys/MinGW on Windows, remember to copy the "linked"
|
||||
directories to simulate the use of a symbolic link.
|
||||
|
||||
Note: Currently there is no dll build. As long as we use static crt import
|
||||
libraries we won't need a ctor/dtor dll.
|
||||
Note: For non-multilib builds, you can omit the "lib32" and "lib64"
|
||||
directories and only have "lib".
|
||||
|
||||
Note: Currently there are no dlls built. As long as we use static crt import
|
||||
libraries we won't need a ctor/dtor dll (mingwm10.dll).
|
||||
|
||||
|
||||
== Finishing gcc (the libraries built using gcc core and Mingw-w64) ==
|
||||
== Finishing GCC (the libraries built using GCC core and Mingw-w64) == [FNSHGC]
|
||||
|
||||
Now you are ready to build the rest of gcc:
|
||||
Now you are ready to build the rest of GCC:
|
||||
|
||||
Step 1) Enter back into your generated folder within your gcc root source
|
||||
folder.
|
||||
Step 1) Enter back into your GCC "build" directory.
|
||||
|
||||
Step 2) Type 'make'. This will take a while.
|
||||
|
||||
Step 3) Type 'make install'
|
||||
|
||||
|
||||
== Path update and using your new cross-compiler ==
|
||||
== Path update and using your new cross-compiler == [PTHUPD]
|
||||
|
||||
Permanently update your path to use your new cross-compiler:
|
||||
|
||||
@ -292,7 +348,7 @@ so there are no file name clashes.
|
||||
* If you are using MSys, you will need to add the directory to your path in
|
||||
/etc/profile.
|
||||
|
||||
* To reiterate, for default /usr/local, Add /usr/local/bin to your path (this
|
||||
* To reiterate, for default /usr/local, add /usr/local/bin to your PATH (this
|
||||
should not be necessary.) If using a sysroot, add /mypath/bin to your path.
|
||||
|
||||
You are finished.
|
||||
|
Loading…
Reference in New Issue
Block a user