Author Topic: GCC 4.1.2 available (now relocatable!)  (Read 74228 times)

Offline TDragon

  • Lives here!
  • ****
  • Posts: 943
    • TDM-GCC
GCC 4.1.2 available (now relocatable!)
« on: February 26, 2007, 03:20:04 am »
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.5
9. 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 install


At 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)
« Last Edit: March 16, 2007, 10:13:38 pm by TDragon »
https://jmeubank.github.io/tdm-gcc/ - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

Online stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: GCC 4.1.2 available
« Reply #1 on: February 26, 2007, 03:35:40 am »
Thanks for the link to your build and even more thanks for the directions on compiling GCC for minGW.
Tim S
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Grom

  • Almost regular
  • **
  • Posts: 206
Re: GCC 4.1.2 available
« Reply #2 on: February 26, 2007, 04:21:17 am »
Is that possible to build gcc somehow with enabled cpu instruction (i686) and full optimization to save compilation time of the finall version?
gcc+winXP+suse.

Offline TDragon

  • Lives here!
  • ****
  • Posts: 943
    • TDM-GCC
Re: GCC 4.1.2 available
« Reply #3 on: February 26, 2007, 04:45:59 am »
Is that possible to build gcc somehow with enabled cpu instruction (i686) and full optimization to save compilation time of the finall version?
Quite simply: add -mtune=i686 (or -march=i686) and whatever other flags you'd like into CFLAGS and CXXFLAGS in the make command. Given the nature of the beast, however, I doubt enabling whatever additional instructions are available in i686, such as MMX, would make any measurable difference in execution speed, or even any difference at all. The optimizations that I've enabled with -O2 usually give the best results without eating up inordinate amounts of memory.
https://jmeubank.github.io/tdm-gcc/ - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

Offline Grom

  • Almost regular
  • **
  • Posts: 206
Re: GCC 4.1.2 available
« Reply #4 on: February 27, 2007, 03:06:19 am »
On my computational algorithms -03 gives a lot
gcc+winXP+suse.

wxLearner

  • Guest
Re: GCC 4.1.2 available
« Reply #5 on: February 27, 2007, 02:18:56 pm »
Thank you very much for this!
Concerning the hardwired search paths, I've found an interesting mailing list entry. It's about compiling gdc, but I think it describes the trick to make gcc relocatable in general. I didn't try it yet, but I will do it with your gcc-4.1.2 version :)

Offline TDragon

  • Lives here!
  • ****
  • Posts: 943
    • TDM-GCC
Re: GCC 4.1.2 available
« Reply #6 on: February 27, 2007, 03:03:09 pm »
Concerning the hardwired search paths, I've found an interesting mailing list entry. It's about compiling gdc, but I think it describes the trick to make gcc relocatable in general.
Nice spotting! Rebuilding now. :)
https://jmeubank.github.io/tdm-gcc/ - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: GCC 4.1.2 available
« Reply #7 on: February 27, 2007, 03:22:04 pm »
@TDragon,

I compiled GCC-3.4.6 couple of times. It compiles applications. But there is a Problem. If I want to compile C::B, while compiling PCH it says something like "Can't open <Temp_dir>\<random_name>.s" and stops the compilation.

I did some search and got the closest match in following thread. Though it's about GCC+CygWin but the problem was similar.
Quote
http://gcc.gnu.org/ml/gcc-patches/2003-07/msg00963.html

I've never tested above solution.

My question is-
* Did you ever face such issue? If yes, please suggest me any solution.

Thanks & Regards,

Biplab
Be a part of the solution, not a part of the problem.

Offline TDragon

  • Lives here!
  • ****
  • Posts: 943
    • TDM-GCC
Re: GCC 4.1.2 available
« Reply #8 on: February 27, 2007, 03:36:06 pm »
I compiled GCC-3.4.6 couple of times. It compiles applications. But there is a Problem. If I want to compile C::B, while compiling PCH it says something like "Can't open <Temp_dir>\<random_name>.s" and stops the compilation.
...
Did you ever face such issue?
No, I haven't -- but I've never tried to use GCC 3.4.6 before. Looking over that mailing list message, I don't actually see anything to suggest that it has anything to do with your problem, either.

Once this new 4.1.2 build is finished, I think I'll try building and running 3.4.6 and see what happens.
https://jmeubank.github.io/tdm-gcc/ - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: GCC 4.1.2 available
« Reply #9 on: February 27, 2007, 03:44:57 pm »
I compiled GCC-3.4.6 couple of times. It compiles applications. But there is a Problem. If I want to compile C::B, while compiling PCH it says something like "Can't open <Temp_dir>\<random_name>.s" and stops the compilation.
...
Did you ever face such issue?
No, I haven't -- but I've never tried to use GCC 3.4.6 before. Looking over that mailing list message, I don't actually see anything to suggest that it has anything to do with your problem, either.

Once this new 4.1.2 build is finished, I think I'll try building and running 3.4.6 and see what happens.

Thanks for your reply. I forgot the exact error.  :)

I'll post it later. Shall I upload the binary (Compiled GCC) for you to some location? :)

Thanks & Regards,

Biplab
Be a part of the solution, not a part of the problem.

Offline TDragon

  • Lives here!
  • ****
  • Posts: 943
    • TDM-GCC
Re: GCC 4.1.2 available
« Reply #10 on: February 27, 2007, 04:07:59 pm »
Shall I upload the binary (Compiled GCC) for you to some location?
Sure -- then I can test it to make sure the issue's not just specific to your machine. I'm sure you already know this: what I would want is the contents of "blah" from the "make DESTDIR=blah install" command. (I don't need any of the MinGW components.)
https://jmeubank.github.io/tdm-gcc/ - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: GCC 4.1.2 available
« Reply #11 on: February 27, 2007, 04:35:37 pm »
Please download the file from the following link.

Quote
http://www.fileden.com/files/4628/GCC-3.4.6.7z

AFAIR, the build was configured with ../configure --prefix=/c/temp/gcc-3.4.6 ....

The archive has GCC, G++ and GOBJC.

Thanks & Regards,

Biplab
Be a part of the solution, not a part of the problem.

Offline TDragon

  • Lives here!
  • ****
  • Posts: 943
    • TDM-GCC
Re: GCC 4.1.2 available
« Reply #12 on: February 27, 2007, 05:56:49 pm »
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)

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.

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.
Following is the full set of steps I took: (changes marked in bold)
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.5
9. 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 install


At 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)
« Last Edit: March 16, 2007, 10:09:52 pm by TDragon »
https://jmeubank.github.io/tdm-gcc/ - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)

Offline Grom

  • Almost regular
  • **
  • Posts: 206
Re: GCC 4.1.2 available
« Reply #13 on: February 27, 2007, 05:58:11 pm »
The compilation with 4.1.2 gave me  undefined reference to `__cpu_features_init'
:: === Build finished: 1 errors, 0 warnings ===
 :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry:
gcc+winXP+suse.

Offline TDragon

  • Lives here!
  • ****
  • Posts: 943
    • TDM-GCC
Re: GCC 4.1.2 available
« Reply #14 on: February 27, 2007, 06:01:10 pm »
The compilation with 4.1.2 gave me  undefined reference to `__cpu_features_init'
Please describe how you installed 4.1.2 and give your project's full command line log (enabled from Settings->Compiler and debugger->Other settings->Compiler logging->Full command line).
https://jmeubank.github.io/tdm-gcc/ - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)