With many thanks to wxLearner for the tip, a new, fully relocatable build is available
directly from my site (removed due to excessive bandwidth usage) or
hosted at filefront.com. (gcc-4.1.2-c+cxx-mingw-tdm-r1.7z: 7-zip archive, 9.39 MB). For more details, see
this post.
As an extra tidbit, I have succesfully used this 7-zip archive, along with the MinGW components listed below, to install GCC 4.2.1 and successfully build and run Code::Blocks with it on two other machines, one running XP Pro SP2 and one running Win2k.
GCC 4.1.2 was officially released Feb. 13th. I was able to successfully build it in and for a Windows environment with both MinGW's GCC 3.4.5 distribution and my own previous GCC 4.1.1 build (with MinGW's binutils, mingw32-make, etc.).
You can download my build of GCC 4.1.2 for MinGW
here (direct link to the file from my website removed due to excessive bandwidth usage) or
here (hosted at filefront.com). (gcc-4.1.2-c+cxx-mingw-tdm-r1.7z: 7-zip archive, 9.39 MB). Disclaimer on behalf of MinGW: This build is not in any way endorsed by or affiliated with the MinGW project, so don't go asking the MinGW devs for help with problems when using this build.
It's compiled with support for C and C++ only, and was configured with the "--enable-fully-dynamic-string" option, which turns off a certain optimization for static std::string objects and which the developers of the Ogre engine have found necessary to correctly build and use Ogre as DLLs with MinGW/GCC.
In order to use this build with Code::Blocks, I recommend extracting it to an empty directory along with the contents of
binutils-2.17.50-20060824-1.tar.gz,
mingw32-make-3.81-1.tar.gz,
mingw-runtime-3.11.tar.gz, and
w32api-3.7.tar.gz, and then installing
gdb-6.3-2.exe to that directory.
Hints for creating a relocatable build came from
this mailing list message, although I encountered a few additional necessary steps not mentioned there. In particular, using a nonexistent path as the prefix failed; the installation required various MinGW components to already be present in the installation directory. (See the steps in bold in my build process below.)
This build includes the patch for GCC 4.1 branch attached to
this GCC bug report, which fixes the problem building wxWidgets' Media library with GCC 4. I would still recommend that you move your old MinGW installation to another folder rather than deleting it entirely, in case you encounter an error you can't fix in some other code. Final note about wxWidgets and GCC 4: the wxWidgets headers will introduce a ton of "type attributes are honored only at type definition" warnings; I recommend adding the GCC option "-Wno-attributes" to your wxWidgets project's build options to turn these warnings off.
Here is my almost completely unempirical comparison of the official MinGW GCC 3.4.5 and my GCC 4.1.2.
Host machine: Win XP with SP2, Athlon 64 3500+ CPU @ 2.2GHz, 768 MB DDR-400 RAM, 160 GB SATA/150 hard drive
Time to rebuild All in CodeBlocks.cbp:
GCC 4.1.2 -- 5 minutes, 54 seconds (-Wno-attributes added to the compiler options)
GCC 3.4.5 -- 6 minutes, 7 seconds
Final call: Far too close to make any difference.
Final size of codeblocks.exe (with -g and cbDEBUG, no optimization), in "devel" dir
GCC 4.1.2 -- 10.2 MB
GCC 3.4.5 -- 7.81 MB
Final call: A fairly noticeable difference. Does GCC 4 include more debugging info?
Final size of codeblocks.exe (-g and cbDEBUG removed from build options; -s and -O2 added), in "output" dir after running update.bat:
GCC 4.1.2 -- 1.44 MB
GCC 3.4.5 -- 1.12 MB
Final call: 3.4.5 saves a small amount on size, but I would imagine 4.1.2 includes some further speed optimizations.
I don't yet have a good way of comparing speed optimizations and such in other compiled executables, but high-performance games or apps with heavy math will probably see some performance improvement. GUI apps such as Code::Blocks won't have a noticeable gain.
Final call: Only upgrade if you know your codebase would benefit from additional compiler optimization, or if you want to ensure that it can be compiled with later versions of GCC.
For those interested, my build process:
1. Download and extract
gcc-core-4.1.2.tar.gz and
gcc-g++-4.1.2.tar.gz (creates directory "gcc-4.1.2")
2. Download
this patch and save in the same parent directory (we'll call it <gccbuildpath>)
3. Open mSYS
4. $ cd <gccbuildpath>/gcc-4.1.2
5. $ patch -b -p0 -i ../bug27067.patch
6. Exit mSYS
7. Create directory "gcc-4.1.2-obj" next to "gcc-4.1.2"
8. Ensure that C:\MinGW contains a full MinGW installation with GCC 3.4.59. Open <pathtomsys>\etc\fstab and make sure entry "c:/MinGW /mingw" exists
10. Open mSYS
11. $ cd <gccbuildpath>/gcc-4.1.2-obj
12. $ ../gcc-4.1.2/configure --with-gcc --with-gnu-ld --with-gnu-as --prefix=/mingw --enable-threads --disable-nls --enable-languages=c,c++ --disable-win32-registry --enable-fully-dynamic-string
13. $ make CFLAGS="-O2 -fomit-frame-pointer" CXXFLAGS="-mthreads -fno-omit-frame-pointer -O2" LDFLAGS=-s bootstrap 2>errlog.txt
14. Wait a few minutes. Make a pot of coffee.
15. make fails at step "Bootstrapping the compiler"; check errlog.txt to find error: Makefile:1280: *** target pattern contains no `%'.
16. Open <gccbuildpath>\gcc-4.1.2-obj\gcc\Makefile, go to line 1280, see that error is referring to $(ORIGINAL_LD_FOR_TARGET). Find definition of ORIGINAL_LD_FOR_TARGET (line 359), see that it's incorrectly set as "./c:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../mingw32/bin/ld.exe". Change to the saner "/mingw/bin/ld" (following the pattern of ORIGINAL_NM_FOR_TARGET right below it, which is correctly set). Save Makefile.
17. Return to mSYS window, repeat previous make command (make CFLAGS="-O2 -fomit-frame-pointer" CXXFLAGS="-mthreads -fno-omit-frame-pointer -O2" LDFLAGS=-s bootstrap 2>errlog2.txt)
18. Wait a lot of minutes. Prepare and consume a 5-course dinner.
19. Rename C:\MinGW as C:\MinGW-old
20. Create new C:\MinGW and extract contents of binutils-2.17.50-20060804-1.tar.gz, mingw32-make-3.81-1.tar.gz, mingw-runtime-3.11.tar.gz, and w32api-3.7.tar.gz there.
21. $ make installAt this point, C:\MinGW now contains nearly an entire MinGW installation. This is fine for people who don't want to distribute it; I had to use diff to determine the new and changed files (comparing against a copy of the contents of C:\MinGW before running make install) and separate them out by hand. There's probably a faster way of doing it.
22. Copy i686-pc-mingw32-gcc.exe to mingw32-gcc.exe and i686-pc-mingw32-g++.exe to mingw32-g++.exe (for easy compatibility)