(Maybe that's not a bug, I have no idea). I'm trying to produce binaries that would work also on RHEL4. One symbol gets in the way: __stack_chk_fail. Adding -fno-stack-protector doesn't change anything. This is devtoolset specific, the system compiler doesn't reference this symbol. It happens only with -O[1-3] and with <iostream> included. How reproducible: always on i386 and x86 RHEL5 clones (sorry, I don't have access to RHEL5 atm) Steps to Reproduce: $ cat foo.cc #include <iostream> int main(int argc, char *argv[]) { for(int i=0; i < argc; i++) std::cout << " " << argv[i]; return 0; } $ g++ -fno-stack-protector -O2 foo.cc $ readelf -s a.out | grep chk 15: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __stack_chk_fail (5) 105: 0000000000000000 0 FUNC GLOBAL DEFAULT UND __stack_chk_fail@@GLIBC_2 Do you know why this happens (and why only with -O)?
This is indeend not a bug, libstdc++_nonshared.a (and other libraries) are intentionally built with -fstack-protector for security reasons. Developer Toolset is not the product to use if you want to build on newer RHEL and deploy on older RHEL, after all the system libstdc++.so.6 on RHEL4 doesn't have many of the symbols you might need and DTS on RHEL5 depends on. To build (limited amount of) programs on RHEL5 that can run on RHEL4 you need to use compat-gcc-34 and compat-glibc packages and gcc34 or g++34.
aha, I just didn't know that *_nonshared.a archives are linked, I thought that everything is in shared libraries. Thanks for explanation.