We are currently migrating from AIX and the xlC compiler to Linux and the GNU toolchain. In our C/C++ compilation process we use the -qnoweakexp
compiler flags to disable the export of weak symbols. Please see the xlc compiler reference.
I cannot find an equivalent compiler flag in the gcc Options Summary. The end goal is that no weak symbols get exported to our compilation targets. The closest gcc flag I could find was -fno-weak
, however the gcc manual states that this flag is not intended to be used in production code.
Background: We need to link with some C libraries of the framework we are using with our compilation targets, and these libraries export some of the same weak symbols, which our own code would without the use of this flag. This has caused segmentation faults to occur sporiadically. These symbols were apparently generated for some STL containers we are using, for example:
std::vector<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,std::allocator<std::basic_string<char,std::char_traits<char>,std::allocator<char> > > >::_Clear()
I.e. it is not a case of some of the symbols having been explicitly annotated as weak in the source code, and as such the problem cannot be remedied by removing the annotations.