[cmake-developers] CMake adds libgcc_eh.a to the linker line on AIX
Hi I'm building binaries for AIX using GCC and native ld (also testing with GCC cross-compiler with GNU binutils) and I get issues with exceptions not being caught like they should. I'm linking a number of static C and C++ archives into several binaries and I notice that under certain conditions CMake adds libgcc_eh.a to the linker line. It actually appears twice in between target_link_libraries libs and the RPATH section at the end. Something like this: c++ -g object_files -o executable -Wl,-brtl,-bexpall \ link_libraries \ full_path_to/libgcc_eh.a \ full_path_to/libgcc_eh.a \ -Wl,-blibpath:rpath If I manually add libsupc++.a to the linker line my program links and runs correctly, BUT if I strip both libgcc_eh.a and libsupc++.a from the linker command it also links and runs correctly. Since supc++ is a subset of stdc++ I thought I wouldn't need that anyway. Is this expected behavior? Is libgcc_eh.a really needed here or is there a way to avoid it? Or should CMake also add libsupc++? Best Regards, Ådne Hovda -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers
Re: [cmake-developers] CMake adds libgcc_eh.a to the linker line on AIX
On 02/07/2014 09:03 AM, Ådne Hovda wrote: I notice that under certain conditions CMake adds libgcc_eh.a to the linker line. CMake has no builtin knowledge of this library so it must be coming the detection of libraries implicitly added by the compiler front-end. Take a look at CMakeFiles/cmake-version/CMake(C|CXX)Compiler.cmake files in the build tree. There should be lines that set variables like CMAKE_C_IMPLICIT_LINK_LIBRARIES. Does libgcc_eh.a appear in any of them? Also look at CMakeFiles/CMakeOutput.log for content following lines like Parsed C implicit link information from above output and Parsed CXX implicit link information from above output That has verbose information about how CMake detects these libraries. This is related to the mixed-language support, usually used for linking C++/Fortran together. When computing a link line CMake looks at all the languages that it knows have been compiled into object files involved in the link. It wants to ensure that the libraries normally added by the compiler for each language will appear. Whatever lang's compiler is used to drive the link has a known set of libraries. All other libraries implicitly used by the other languages will be added to the link line explicitly. -Brad -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers
Re: [cmake-developers] CMake adds libgcc_eh.a to the linker line on AIX
On 2/7/2014 3:33 PM, Brad King wrote: like CMAKE_C_IMPLICIT_LINK_LIBRARIES. Does libgcc_eh.a appear in any of them? You are right, it's there. If I run powerpc-ibm-aix5.3.0.0-gcc /opt/cmake/share/cmake-2.8/Modules/CMakeCCompilerABI.c -v I see libgcc_eh.as among collect2's args. For powerpc-ibm-aix5.3.0.0-g++ /opt/cmake/share/cmake-2.8/Modules/CMakeCXXCompilerABI.cpp -v it is indeed not present. Whatever lang's compiler is used to drive the link has a known set of libraries. All other libraries implicitly used by the other languages will be added to the link line explicitly. Turns out gcc would try to link libgcc statically by default, and brought in libgcc_eh.a, but that's not working well when linked with C++ code using exceptions. Had I only read the docs... http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#index-shared-libgcc-1093 . I'll try to set the -shared-libgcc flag in my toolchain file and hopefully have it work. Thanks! Ådne -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers