When you compile with -g, function inlining is disabled. You can debug inline functions, but program performance is reduced, often drastically. You might want to try -g0 (g zero) instead, which allows function inlining.
You say the optimized program is 9MB but the debug version is 500Mb. The size difference is due to debugging information, which is not loaded into the program address space at run time. But the debug data contains relocatable information that must be processed by the linker, which is why you were running into space limitations at link time. What was the size of the program compiled with -g using Studio 10? The C++ compiler in Sun Studio 12 changed from using stabs for debugging to using DWARF debug format by default. DWARF provides better debugging capability, but the debugging data is larger. It would be interesting to know how much larger in your case. When you compile for debugging, the compiler globalizes static symbols. Symbols declared static are given a hashed prefix and made global. Making them global allows dbx fix-and-continue to work. In some cases, you can get a lot of extra global symbols, adding to the amount of data the linker must process. In private email, Rod (rie) pointed me to a bug report about globalization, which mentioned an undocumented -xglobalstatic option. The option is potentially dangerous (which is why it is not documented), but in any case is not relevant to your problem. A bug report for this problem has been filed, # 6692427. It will be visible at http://bugs.sun.com in a day or two. We can track progress via that report. Steve Clamage Sun C++ compiler team This message posted from opensolaris.org