Configured with: ../sco/gcc-3.2.3/configure --prefix=/usr/local/gcc-3.2.3 -- enable-languages=c++ --with-gnu-as Thread model: single gcc version 3.2.3 System: SCO Unix 5.0.5 Compilation of source programs with declared but unitialised global data on the SCO system seems to cause the program to grow in proportion with the size of the data. Uninitialised data should be stored under BSS or the common section of a program. This seems to be the case for Linux but not on SCO. ----- Test program: foo.cpp struct My_t { char myData[2048]; }; My_t myArr[10240]; int main () { return 0; } ----- Compilation: gcc -O -fconserve-space foo.cpp -lstdc++ Size listing (ls -l a.out) on SCO: 20977120 Size listing (ls -l a.out) on RedHat: 11341 However, converting the same program to a C standard and compiling with gcc on SCO produces the expected object code size as follows: ----- Test program: foo.c struct My_t { char myData[2048]; }; struct My_t myArr[10240]; int main () { return 0; } ----- Compilation: gcc foo.c Size listing (ls -l a.out) on SCO: 5604
Follow up on the earlier report, the size problem goes away when the global variables are declared as static: struct My_t { char myData[2048]; }; static My_t myArr[10240]; int main () { return 0; } Using nm on the object files that were generated: without static keyword: Symbols from foo.o: [Index] Value Size Type Bind Other Shndx Name [1] | 0| 0|FILE |LOCL |0 |ABS |foo.cpp [2] | 0| 0|SECT |LOCL |0 |2 | [3] | 0| 0|SECT |LOCL |0 |4 | [4] | 0| 0|SECT |LOCL |0 |5 | [5] | 0| 0|SECT |LOCL |0 |1 | [6] | 0| 0|SECT |LOCL |0 |6 | [7] | 0|20971520|OBJT |GLOB |0 |4 |myArr [8] | 0| 30|FUNC |GLOB |0 |2 |main with static keyword: Symbols from foo.o: [Index] Value Size Type Bind Other Shndx Name [1] | 0| 0|FILE |LOCL |0 |ABS |foo.cpp [2] | 0| 0|SECT |LOCL |0 |2 | [3] | 0| 0|SECT |LOCL |0 |4 | [4] | 0| 0|SECT |LOCL |0 |5 | [5] | 0|20971520|OBJT |LOCL |0 |5 |myArr [6] | 0| 0|SECT |LOCL |0 |1 | [7] | 0| 0|SECT |LOCL |0 |6 | [8] | 0| 30|FUNC |GLOB |0 |2 |main The array was bound locally. Still doesn't solve the problem but its a work around for programs with a main line entry point. NOTE: static is deprecated in a global context. Not that its going to go away or anything...
Bugs for gcc 3.2.3 are not going to be fixed. Are you seeing this problem with more recent versions of GCC as well?
Have been trying to upgrade to a newer version of gcc (3.3.3 and above). But I am getting an error during compilation: checking whether the C compiler ( /usr/byg/src/bld-gcc/gcc/xgcc -B/usr/byg/src/b ld-gcc/gcc/ -B/usr/local/gcc-3.3.4/i386-pc-sco3.2v5.0.5/bin/ -B/usr/local/gcc-3. 3.4/i386-pc-sco3.2v5.0.5/lib/ -isystem /usr/local/gcc-3.3.4/i386-pc-sco3.2v5.0.5 /include -O2 -O2 ) works... no configure: error: installation or configuration problem: C compiler cannot creat e executables. gmake: *** [configure-target-libiberty] Error 1 Any idea how to get past this? Configured and built with: $ configure --prefix=/usr/local/gcc-3.3.4 --enable-languages="c++" $ gmake CFLAGS="-O2" LANGUAGES="c c++"
No useful feedback in 3 months.