Build a cross compiler on Windows using MSYS2

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
hwg
Posts: 22
Joined: Wed Nov 18, 2015 11:56 am
Libera.chat IRC: hwg

Re: Build a cross compiler on Windows using MSYS2

Post by hwg »

It compiled fine for an hour then spat out the following error:

Command lines:

Code: Select all

$ export PREFIX=/home/Harley/opt/cross
$ export TARGET=i686-elf
$ ../gcc-5.3.0/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c,c++ --without-headers
$ make all-gcc # it fails here
The error:

Code: Select all

In file included from /usr/lib/gcc/x86_64-pc-msys/4.9.2/include/c++/string:41:0,
                 from ../../gcc-5.3.0/gcc/system.h:201,
                 from gtype-desc.c:22:
/usr/lib/gcc/x86_64-pc-msys/4.9.2/include/c++/bits/allocator.h:46:75: fatal error: bits/c++allocator.h: No such file or directory
compilation terminated.
Makefile:1065:recipe for target 'gtype-desc.o' failed
make[1]: *** [gtype-desc.o] Error 1
make[1]: Leaving directory '/home/Harley/src/build-gcc/gcc'
Makefile:4113: recipe for target 'all-gcc' failed
make: *** [all-gcc] Error 2
Octocontrabass
Member
Member
Posts: 5587
Joined: Mon Mar 25, 2013 7:01 pm

Re: Build a cross compiler on Windows using MSYS2

Post by Octocontrabass »

I don't think mixing headers from two different versions of GCC will work.

If you don't need GCC 4.9.2, try removing it.
hwg
Posts: 22
Joined: Wed Nov 18, 2015 11:56 am
Libera.chat IRC: hwg

Re: Build a cross compiler on Windows using MSYS2

Post by hwg »

Ah, 4.9.2 is the version of gcc that I have. I'm gonna have to either bootstrap a new compiler or find a binary.
Octocontrabass
Member
Member
Posts: 5587
Joined: Mon Mar 25, 2013 7:01 pm

Re: Build a cross compiler on Windows using MSYS2

Post by Octocontrabass »

MSYS2 includes GCC 5.3.0. When was the last time you updated your MSYS2 installation?
hwg
Posts: 22
Joined: Wed Nov 18, 2015 11:56 am
Libera.chat IRC: hwg

Re: Build a cross compiler on Windows using MSYS2

Post by hwg »

I did it!

Code: Select all

$ i686-elf-gcc -dumpmachine
i686-elf

Code: Select all

$ i686-elf-gcc --version
i686-elf-gcc (GCC) 5.3.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
hwg
Posts: 22
Joined: Wed Nov 18, 2015 11:56 am
Libera.chat IRC: hwg

Re: Build a cross compiler on Windows using MSYS2

Post by hwg »

Reinstalling gcc from pacman helped fix the issue with the header file. So, long story short, to compile in an MSYS2 environment, you do the following:

Code: Select all

# update MSYS
pacman -Syu
# install all dependencies
pacman -S gcc make bison flex texinfo {gmp,mpfr,mpc}-devel
After that, just follow the wiki from here.
Perhaps there should be a dependency table on the wiki. The dependency lists in parentheses might get a little long.
Post Reply