Log in

View Full Version : Compiling GCC for MinGW & Cross-Compiling with Linux


Pages : 1 [2] 3 4 5

cc979
3rd March 2007, 02:51
ive run make bootstrap and it works also. im attempting a cygwin cross-compile now (im still at the stage that im compiling/loading gmp,bison, etc). i can get 4.3 to compile and work when its in "prescott mode" its just agrivating that i cant get libavcodec to compile with core2 set.

the other issue im still having (and i loaded the binutils from sf.net already as well as my own) is that when gcc is run with -MM i still get output that has C:/msys... in it. the colon is whats causing my problem cause for some reason it isnt converting that to /c/msys and im not sure how to force that to do it. im kinda stumped on that one and i think if i fixed that then things would be much easier in this build for me.

is libavutil patched with this http://lists.mplayerhq.hu/pipermail/ffmpeg-cvslog/2006-December/005868.html

cc979
3rd March 2007, 03:02
just found that compiling gmp & mfpr using gcc-4.1.2, fail the 'make check' so the libs can't be trusted - they are fine using gcc-4.0.4

morph166955
3rd March 2007, 20:12
i havent patched it yet no...i was waiting to get a vanilla version working before going any further with patches and such. My cygwin cross-compile failed but I think its cause my cygwin isnt setup properly (ive never used it before and I just installed it).

I have a freebsd 6.1 box that im going to try to compile it on today to see if that works. assuming I can get it working I'll be happy although I have a feeling that I'm going to have a similar problem that I have now. I'm probably going to end up upgrading that box to have 4.3 locally so that it can create my core2 optimized version of 4.3 for mingw after that works.

cc979
4th March 2007, 03:45
i've successfully cross-compiled gcc 4.0.4 using linux, i'll post a guide soon - more testing first

then i'll try doing a cross-compiled 4.2 & 4.3

cheers

morph166955
4th March 2007, 03:55
can you by chance give me a cliff notes of what you did or at least your configure line to use as a base? i JUST finished upgrading gcc natively on my bsd box and im getting ready to do the cross compile in the next half hour.

cc979
4th March 2007, 04:16
it's tricky -- tuck about 2days of re-learning

you will need bison,flex libtool, and maybe others

first you compile binutils with
../configure --prefix=/mingw --target=i686-pc-mingw32
make && make install

then

PATH=$PATH:/mingw/bin
(so it knows where the new mingw32-cross is)

then you need mingw32-includes & libs in the correct folder
eg. /mingw/i686-pc-mingw32/

then compile gcc with
../configure --prefix=/mingw --target=mingw32

make && make install

then

CC=/usr/bin/gcc
and re-compile with
../configure --prefix=/mingw --build=i686-pc-linux-gnu --host=i686-pc-mingw32

then then final-recompile

$ gcc -v
Using built-in specs.
Target: i686-pc-mingw32
Configured with: ../configure --build=i686-pc-linux-gnu --host=i686-pc-mingw32 --enable-languages=c,c++ --prefix=/mingw -v --enable-optimize --enable-threads --disable-nls --disable-win32-registry --disable-shared --without-x
Thread model: win32
gcc version 4.0.4

morph166955
4th March 2007, 04:37
ok i get the first gcc compile...but why the second with --build and --host instead of --target? everything ive seen has not had that final step. also why am i setting CC=... for that phase?

cc979
4th March 2007, 04:58
build=is always the systems-compiler
host=is what system its going to run on
target=create code for the desired system

cross-compile is the target=mingw
and build=system(as it needs to run the code it makes)
and target=mingw

so the last step is a cross-compiler that can on run on its own system and produce=mingw too

there's plenty of docs on the net but hard to follow, as there scripts what never work for me

cheers

morph166955
4th March 2007, 05:06
well thats my point...none of the docs i have read online including whats on the mingw site have said anythingabout that last step that i was asking about...atleast not anything to do with changing build...i think one showed doing something to host.

ffmpeg
4th March 2007, 05:15
good,I will try to compile

cc979
4th March 2007, 15:23
well thats my point...none of the docs i have read online including whats on the mingw site have said anythingabout that last step that i was asking about...atleast not anything to do with changing build...i think one showed doing something to host.

true, this one was has good info http://kegel.com/crosstool/crosstool-0.43/doc/crosstool-howto.html
and
http://www.mingw.org/MinGWiki/index.php/this%20shell-Script?PHPSESSID=abce11154a632520eb

cc979
4th March 2007, 15:44
crosscompiled working mingw gcc 4.0.4 (should work from any drive)
http://www.mytempdir.com/1241176

needs testing - can anybody test this on your systems and let me of the outcome

cheers

morph166955
4th March 2007, 19:15
aite well im doing my final build now with the --build & --host lines. everything else seemed to work perfectly.

i went off of http://lists.trolltech.com/qt-interest/2006-03/thread00351-0.html (minus the parts about QT at the bottom) and that seems to have worked for me. the thing im curious about (and this may be what you were trying ot say about the build/host options) is that i didnt actually get a program called just gcc. infact everything in my bin directory is prefixed by "i686-pc-mingw32-" (eg gcc is i686-pc-mingw32-gcc).

Assuming that this thing works, and that i can get it over to mingw, and that its able to compile something (mplayer will probably be my test subject)...im going to try to do a core2 optimized version of it and see how that goes. im probably going to end up using gnu-time to see how fast it sped up the build.

cc979
8th March 2007, 03:24
anybody who is using my latest cross-compiled gcc-4.0.4 with multi-core or hyper-threading - does the compiler it self show multiple gcc c/c++ in task manager - i am curious if the compiler is multi-threaded in msys ?

cc979
10th March 2007, 06:55
building whole toolchain - binutils,gcc & cross binutils,gcc

using bison,flex,libtool maybe needed automake,autogen,autoconf

*** step 1 : binutils linux
sudo mkdir -m 777 /my-toolchain

../configure --prefix=/my-toolchain --build=i686-pc-linux-gnu -v --enable-threads --disable-nls --disable-shared

(can use -march='your-cpu' in cflags eg. -march=k8)
make "CFLAGS=-O2" CXXFLAGS="${CFLAGS}" "LDFLAGS=-s"
make install && rm -rf *

(for backup reason)
make DESTDIR=/home/user/backup-build install


*** step 2 : gcc linux

../configure --build=i686-pc-linux-gnu --enable-languages=c,c++ --prefix=/my-toolchain -v --enable-threads --disable-nls --disable-shared --without-included-gettext --with-system-zlib --enable-libstdcxx-debug

(using bootstrap re-compile gcc with the gcc it has just made - you get a faster compiler, and it checks for errors)
(can use -march='your-cpu' in cflags eg. -march=k8)
make "CFLAGS=-O2" CXXFLAGS="${CFLAGS}" "LDFLAGS=-s"
make install && rm -rf *

PATH=/my-toolchain/bin:$PATH

*** step 3 : gmp & mpfr linux

do this step in gmp & mpfr src folders

./configure --prefix=/my-toolchain --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --disable-shared

(can use -march='your-cpu' in cflags eg. -march=k8)
make CFLAGS="-O2" CXXFLAGS="${CFLAGS}" "LDFLAGS=-s"
make check
make install && make distclean

*** step 4 : binutils cross linux>mingw
sudo mkdir -m 777 /mingw

../configure --prefix=/mingw -v --target=i686-pc-mingw32 -v --enable-threads --disable-nls --disable-shared
make "CFLAGS=-O2" CXXFLAGS="${CFLAGS}" "LDFLAGS=-s"
make install && rm -rf *

PATH=/mingw/bin:$PATH

*** step 5 : setup mingw32 include & libs

extract to below path and it works: mingw32-w32api & mingw32-mingw-runtime (include & libs)
into: /mingw/i686-pc-mingw32/include


*** step 6 : gmp & mpfr - cross linux>mingw - if this is not done, gcc will not find gmp & mpfr as it needs mingw versions

./configure --prefix=/mingw/i686-pc-mingw32 --build=i686-pc-linux-gnu --host=i686-pc-mingw32 --disable-shared
make CFLAGS="-O2" CXXFLAGS="${CFLAGS}" "LDFLAGS=-s"
(can't check from a linux host)
make install && make distclean


** step 7 : gcc cross linux>mingw

../configure --build=i686-pc-linux-gnu --target=i686-pc-mingw32 --enable-languages=c,c++ --prefix=/mingw -v --enable-threads --disable-nls --disable-shared --without-included-gettext --with-system-zlib --enable-libstdcxx-debug

(using bootstrap re-compile gcc with the gcc it has just made - you get a faster compiler, and it checks for errors)
(can use -march='your-cpu' in cflags eg. -march=k8)
make "CFLAGS=-O2" CXXFLAGS="${CFLAGS}" "LDFLAGS=-s"
make install && rm -rf *


*** step 8 : gcc-mingw

steps 1-7 only need doing once

(if paths not set)
PATH=/mingw/bin:/my-toolchain/bin:$PATH

(make sure all include & libs are in /mingw/i686-pc-mingw32)
../configure --enable-languages=c,c++ --prefix=/mingw --build=i686-pc-linux-gnu --host=i686-pc-mingw32 -v --enable-threads=win32 --disable-nls --disable-win32-registry --disable-shared --without-x

(can use -march=k8 in cflags)
make CFLAGS="-O2" CXXFLAGS="${CFLAGS}" "LDFLAGS=-s"

// final output for windows

**** pick one

make DESTDIR=/home/user/cc-mingw32-gcc-build-i686 install && rm -rf *



this is what have used to cross-build gcc 4.3
first build a temporary toolchain (binutils and gcc - i used gcc-4.0.4 - so not to mess-up a linux system)
then build its libs, then build a cross-toolchain - (gcc-4.0.4 & binutils) and its libs

then can cross-compile gcc-4.3

will post a better - when i know for sure its working as it should

cc979
13th March 2007, 04:07
gcc-4.0.4 md5: 8B84B4BF70AE479D3C6D82DF3F91CF58
http://www.mytempdir.com/1252231

gcc-4.1.2 md5: 9FC5307E89E73DF9CED84365EE1A9110
http://www.mytempdir.com/1252235

morph166955
16th March 2007, 23:48
ok so little delayed on my reply to this but heres what my problem has been. the cross compiles havent worked completely. im getting weird errors when using the gcc 4.3 builds that im not getting when I use a native build of gcc 4.1.2. weird errors that I shouldnt get. ive done i dont know how many different builds with different steps and different versions but nothing seems to be working nicely. just thought I'd give everyone an update while I was working on it.

I'm also going to note that another reason I'm now doing this is so that I can hopefully get my new dual E5320 quadcore xeon setup to be running as fast and as optimized as possible (im shooting for real time encoding speeds on x264, or close to it) after it all arrives and i build it. every benchmark ive seen of comparable chips plus some math to equate it to two chips instead of one say I should be able to get close depending on my settings. so we shall see. as far as i know no one else is running anything close (at least on the consumer side) to an 8 core setup so who knows!

clsid
17th March 2007, 00:11
GCC 4.3 is still in its early development phase. You are better off using 4.1.2 or even 4.0.4.

cc979
17th March 2007, 01:48
GCC 4.3 is still in its early development phase. You are better off using 4.1.2 or even 4.0.4.

i would go with 4.0.4 as some patches were not include in the official release ... thunk alias bug

gcc 4.3 is upto stage1 .. so not be to long

cc979
17th March 2007, 01:54
ok so little delayed on my reply to this but heres what my problem has been. the cross compiles havent worked completely. im getting weird errors when using the gcc 4.3 builds that im not getting when I use a native build of gcc 4.1.2. weird errors that I shouldnt get. ive done i dont know how many different builds with different steps and different versions but nothing seems to be working nicely. just thought I'd give everyone an update while I was working on it.

I'm also going to note that another reason I'm now doing this is so that I can hopefully get my new dual E5320 quadcore xeon setup to be running as fast and as optimized as possible (im shooting for real time encoding speeds on x264, or close to it) after it all arrives and i build it. every benchmark ive seen of comparable chips plus some math to equate it to two chips instead of one say I should be able to get close depending on my settings. so we shall see. as far as i know no one else is running anything close (at least on the consumer side) to an 8 core setup so who knows!

i was getting no cross builds done with 4.3 and 4.2 started giving errors was i'll just wait a while, and keep looking into the svn logs

morph166955
17th March 2007, 04:05
well just for randomness i once again tried to natively build 4.3 and it works (sorta). im still getting the same issue on mencoder with the assembly code but i have successfully compiled x264 with core2/ssse3 extensions including the new stuff they put in one of the most recent revisions with no problems. im attempting to compile ffmpeg now to see if that works so i know if its an ffmpeg bug or a mplayer bug (even thoguh they still point their fingers at gcc being the buggy compiler)

cc979
17th March 2007, 04:49
well just for randomness i once again tried to natively build 4.3 and it works (sorta). im still getting the same issue on mencoder with the assembly code but i have successfully compiled x264 with core2/ssse3 extensions including the new stuff they put in one of the most recent revisions with no problems. im attempting to compile ffmpeg now to see if that works so i know if its an ffmpeg bug or a mplayer bug (even thoguh they still point their fingers at gcc being the buggy compiler)

native as in mingw or bsd?

have you tried to cross-compile x264 or mencoder?

_xxl
17th March 2007, 07:10
Is GCC 4.3 OpenMP ready?

cc979
17th March 2007, 07:33
Is GCC 4.3 OpenMP ready?

the latest build is not cross compiling for but it did for morph using his bsd box

i could try doing it in mingw to see what happens

cc979
21st March 2007, 08:52
latest pre-release of gcc-4.2, for anyone who wants it
'thunk alias' error still happens with the baseclasses in ffdshow

http://www.mytempdir.com/1263206

let me know, how it goes for you

Lemonzest
21st March 2007, 18:11
thanks cc979 i use your gcc with mingw to build a few project's and it works great :)

morph166955
21st March 2007, 20:06
well i definitely have gcc 4.3 compiling in mingw locally with out any problems. If people want (and assuming that this doesnt break the GPL or anything like that), i can make a package with all my libs/bins that they can load onto a fresh mingw/msys setup to make it gcc 4.3 compile capable since i know how much of a pain in the butt it was to get my system to work to do it (and to find some of the libraries online that work properly!)

@cc979
When you create your packages, what are you including in them? do a make DESTDIR install to somewhere and then copy the include directory over or something of that nature? I'll package up a 4.3 version thats prescott optimized later on if people want...possibly a core2 version if that helps anyone out.

foxyshadis
22nd March 2007, 03:39
That would be awesome. I want to give lavc a shot with 4.3 - having to use 4.0 or msvc for the rest of ffdshow isn't much of a burden.

cc979
22nd March 2007, 06:04
@morph166955

yes i do, make DESTDIR=/home/user/test-build install

then zip that folder

cc979
24th March 2007, 14:49
been trying to get libgomp (open mp) gcc-4.2/4.3 to compile with mingw...no much luck as it needs pthreads

no problem in linux

morph166955
24th March 2007, 15:26
so load pthreads? its like 3 header files (pthread.h, sempahore.h, sched.h i think) you have to copy and a dll (pthreadGC2.dll).

cc979
24th March 2007, 16:09
i have tried already with pthreads-win32, it needs pthreads as in the linux version

morph166955
24th March 2007, 16:47
interesting...where can i get my hands on the copy of that with the same version your using so i can test it here?

also...im doing a new compile of gcc 4.3 today with c,c++,java,fortran,objc so assuming that works ill upload that plus ill run a diff between my copy and a "base" install of mingw/msys and pull out the libraries and stuff that i have on my box for everyone to use

cc979
24th March 2007, 16:55
the libgomp is include in gcc-4.2 & 4.3 - gcc-4_2-branch\libgomp

with pthreads-win32 it does not find the libs or .a - it does compile ok in linux tho

i've also tried to compiling me own from
http://www.mirrorservice.org/sites/sources.redhat.com/pub/pthreads-win32/

it compiles with make, and shows which version you can compile

let me know how you get on, cheers

morph166955
25th March 2007, 23:01
im doing a final run on gcc 4.3 now to make sure that it compiles successfully and all that. once I do, ill use windiff to create a folder filled of any files that differ from a base install of mingw/msys (with out ANY alteration) and then remove the useless files and zip em all up for you all to enjoy. I'll probably make a version with and a version with out gcc4.3 as well as a standalone of gcc 4.3 (so 3 packages in total) in case any of you dont want some specific things. I HIGHLY recommend going through the files that I upload to make sure you don't have your own compiles of some of them in there, I wouldn't want you to screwup your setups using my files.

morph166955
26th March 2007, 01:15
ok i got c, c++ and java (although I dont have libjava added in that yet just gcj) to compile thus far with out any issues. I'm doing a run now with libgomp enabled to see what that does. If that works, im going to do another few runs with different things. below are the things that as of the last run i'm not building (or so says configure). ignore libgomp from that cause its running now. If anyone wants any of those other then libgomp, libjava, libobjc and libgfortran or any languages other then c, c++, java, fortran, objc speak now or hold your peace until i do another build soon.

*** This configuration is not supported in the following subdirectories:
target-libmudflap target-libgomp target-libffi target-zlib target-libjava target-libada gnattools target-libgfortran target-libobjc target-boehm-gc

morph166955
26th March 2007, 02:41
steps to fix pthread for libgomp:


cd /mingw/lib
cp libpthreadGC2.a libpthread.a
ranlib libpthread.a


that makes -lpthread work and in turn makes libgomp work.

cc979
26th March 2007, 10:01
steps to fix pthread for libgomp:


cd /mingw/lib
cp libpthreadGC2.a libpthread.a
ranlib libpthread.a


that makes -lpthread work and in turn makes libgomp work.

cheers, i will try a cross-compile using that

morph166955
26th March 2007, 16:28
sounds good. I also copied pthreadGC2.dll to pthread.dll but I dont think that mattered. I've got my stuff all working except libgcj which has an issue thats apartatly a known bug so im just not going to compile it for now.

im installing my gcc build from last night into my main tree and im running a diff now on that vs a clean install of mingw and creating a folder that has all the stuff thats different. with all hope ill post up my builds later on today.

morph166955
26th March 2007, 18:46
ok these files wont be up too long but they will stay up probably at least for the next 2-3 weeks depending on how many people start to download them and how bad of a hit on my monthly bandwidth cap that I take.

EDIT: URL Removed - Files removed from server

Files:
gcc-4.3-r123209...7z - gcc 4.3, natively built in mingw, compiled with c,c++,java,fortran,objc & libgomp,libobjc,libgfortran

MINGW-DIFF-WITHGCC.7z - a full diff between my current mingw tree and a base/vanilla install of mingw INCLUDING the gcc from above


MINGW-DIFF-NOGCC.7z - a full diff between my current mingw tree and a base/vanilla install of mingw EXCLUDING the gcc from above.

I'm not sure of all of the gpl licencing or any thing like that with some of these libs and i just noticed I have an older build x264 in there also it seems so use these libs/bins at your own risk and appologies to anyone if i did break a gpl licence, it wasn't intentional. I compiled the gcc from an svn that I grabbed at about 2am last night (march 26th). If anyone wants anything else let me know. I'm going to try to get libgcj working and if I can ill upload a new file set with those in it.

morph166955
26th March 2007, 19:52
so im still getting issues compiling mplayer/mencoder/ffmpeg with the -march/-mtune being set to core2. the error i get is:

http://www.benswebs.com/libavcodec-error.jpg

it works fine when mplayer is set to compile as prescott. anyone got an idea as to why this is happening and/or what gnu changed in gcc in terms of asm for core2 that could cause this? ive googled and come up dry but im still looking.

cc979
26th March 2007, 20:20
so im still getting issues compiling mplayer/mencoder/ffmpeg with the -march/-mtune being set to core2. the error i get is:

http://www.benswebs.com/libavcodec-error.jpg

it works fine when mplayer is set to compile as prescott. anyone got an idea as to why this is happening and/or what gnu changed in gcc in terms of asm for core2 that could cause this? ive googled and come up dry but im still looking.

which binutils you using ?

morph166955
26th March 2007, 20:33
binutils is @ 2.17.

cc979
26th March 2007, 21:34
cd /mingw/lib
cp libpthreadGC2.a libpthread.a
ranlib libpthread.a

just tried in mingw with gcc-4.2 and on the configure it crash conftest.exe - i take it, it did'nt do that for you

morph166955
26th March 2007, 21:48
nope. libgomp compiled fine for me. the only other thing to try is to copy libpthreadGC2.dll to libpthread.dll and then run ranlib again on the .a file see if that does it. if not, go into the config.log for that (i wanna say its in i686-pc-mingw/libgomp in your build directory or something like that) and see whats the errors are.

morph166955
26th March 2007, 23:02
ok figured it out, its ffmpeg being stuborn. im not 100% sure what the reason is but im pretty sure it has to do with the way they wrote the transpose4x4() function in dsputil_mmx.c and how it handles the registers. theres something different with the way that the core2's registers work as opposed to the other processors to date. anyone willing to take a stab at it? its ~line 636 in libavcodec/i386/dsputil_mmx.c

cc979
27th March 2007, 14:00
i got libgomp(gcc 4.2 version) on its own cross-compiled but does not compile if i compile gcc - will try gcc 4.3 later (linux native gcc compile does include libgomp tho)

ps. under linux pthreads-win32 is not recognized if it is processed with ranlib, just renaming 'libpthreadGC2.a' to 'libpthread.a' works

morph166955
27th March 2007, 18:56
cool, glad you got pthreads to work for that. whats your configure line look like thats failing and what are you using for make (as in any options or w/e you are putting after it)?

cc979
27th March 2007, 21:33
for gomp i use
../libgomp/configure --program-suffix=-4.2 --host=i686-pc-mingw32 --build=i686-pc-linux-gnu --target=i686-pc-mingw32 --prefix=/mingw --enable-optimize --enable-threads=win32 --disable-nls --disable-win32-registry --enable-static --without-x

for gcc
../configure --program-suffix=-4.2 --host=i686-pc-mingw32 --build=i686-pc-linux-gnu --target=i686-pc-mingw32 --enable-languages=c,c++ --prefix=/mingw --enable-optimize --enable-threads=win32 --disable-nls --disable-win32-registry --enable-static --without-x

and
make LDFLAGS="-s"

on both

morph166955
28th March 2007, 00:31
just out of curiosity, why don't you try 4.2 or 4.3 natively in mingw to build libgomp either way? also could you possibly post up the results of running configure with both of those lines shows for you (specifically from the start up to and including where it says the libraries that wont work properly with that config, i think it checks bison and flex after that).