I wouldn't try and install binary Lenny packes in Squeeze because the dependencies may be all screwed up. But compiling a source package with apt-get and dpkg-buildpackage is so simple that it surprises me every time. In your case:
- add the Lenny sources to /etc/apt/sources.list:
deb-src http://mirrors.kernel.org/debian/ lenny main contrib non-free - run "apt-get update" or "aptitude update" to update the cache with available packages and sources
- run "apt-cache showsrc gcc-3.4"
- find the entry with the correct gcc version if there are multiple. In my case, there was only 3.4.6ds1-9 but there might be a slightly newer one as I didn't run "aptitude update" for a few weeks
- create an empty directory for the build and change into it
- run "apt-get source gcc-3.4" in the build directory; if you need to pick a specific version, add the version number to the package like so: "apt-get source gcc-3.4=3.4.6ds1"
- change into the source directory (gcc-3.4-3.4.6ds1 in my case)
- run "dpkg-buildpackage -rfakeroot" to build the compiler
- once the build has completed successfully, you'll find binary package files to install with "dpkg -i" in the parent directory (the one above the source directory)
You may have to change configure options (e.g. to select the proper ABI) or hack the dependencies section if there are dependencies to older packages -- things should work with the versions provided by Squeeze because you recompile using those packages. Configure options can be changed in debian/rules and dependencies hacked in debian/control.
If you miss packages for the build, run "apt-get build-dep gcc-3.4" to have them automatically resolved (as far as they can be resolved with Squeeze packages). Again, if Squeeze only offers newer versions of packages needed at build time, I would install those newer packages, manually if necessary, and hack the debian/control file.
Last but not least, if you have to build again and again to get things resolved, you can add the option "-nc" (no clean) to the dpkg-buildpackage command to avoid having to start from scratch all the time.
Hope this helps (and works),
--Christian