So, an update to this post. I just succeeded in backporting gcc 4.7 to Debian squeeze. To be clear, this was just the part of gcc which contains the C, C++ and Objective C compiler, but I only use C and C++ so I don’t care about the other stuff. So, perhaps it wasn’t that hard after all.
The version I used was gcc-4.7, version 4.7-20111231-1, which was in experimental, but has now been replaced by a different version.
I was able to satisfy all the build dependencies without difficulty, except that I had to rebuild the testing version of binutils on squeeze, as Debian kept insisting on that dependency, though I don’t see why an older version of binutils would not have worked. Another thing that is worth noting is that I had to disable the test suite, because it was causing errors. Not sure what was going on here. I did this by uncommenting this line in rules.def
# if you don't want to run the gcc testsuite, uncomment the next line
with_check := disabled by hand
One possible source of confusion was that I built with the squeeze version of binutils, and adjusted the control file accordingly, but was eventually forced to install 2.22 as the built packages somehow has 2.22 as a runtime dependency. I don’t know if this had anything to do with the test build failure. Anyway, I tested it a bit, and rather to my surprise everything seems to work. Here is a list of upgraded and newly installed packages
ii binutils 2.22-2 GNU assembler, linker and binary utilities
ii cpp-4.7 4.7-20111231-1 GNU C preprocessor
ii g++-4.7 4.7-20111231-1 GNU C++ compiler
ii gcc-4.7 4.7-20111231-1 GNU C compiler
ii gcc-4.7-base 4.7-20111231-1 GCC, the GNU Compiler Collection (base package)
ii libgcc1 1:4.7-20111231-1 GCC support library
ii libgomp1 4.7-20111231-1 GCC OpenMP (GOMP) support library
ii libitm1 4.7-20111231-1 GNU Transactional Memory Library
ii libquadmath0 4.7-20111231-1 GCC Quad-Precision Math Library
ii libstdc++6 4.7-20111231-1 GNU Standard C++ Library v3
ii libstdc++6-4.7-dev 4.7-20111231-1 GNU Standard C++ Library v3 (development files)
I wonder if the backports.org people would be interested.
If you have questions about this, you can reach me at faheem at faheem dot info.