I recently discovered that after moving to the C++ bootstrap, the IA64 HP-UX GCC compiler would build and test OK, but if you tried to run the installed compiler you would get an error about not being able to find libgcc_s.so.0.
Joseph and Rainer pointed me at definining gcc_cv_ld_static_dynamic, gcc_cv_ld_static_option, and gcc_cv_ld_dynamic_option in the configure.ac script and that helped but resulted in a new problem. In addition to allowing GCC to link with the static libgcc and libstdc++ these changes resulted in GCC trying to link in a static libunwind. On IA64 HP-UX we use the system libunwind and it only comes in a shared version. So my solution was to change gcc.c so that we only link in the archive libunwind if we are not using the system libunwind. I did this by having unwind_ipinfo.m4 set a new macro (USE_SYSTEM_LIBUNWIND) when we are using the system libunwind and then checking for this in gcc.c. I am not sure if any other platforms use the system libunwind and if this will cause them problem, IA64 HP-UX is the only platform to use the system libunwind by default and I'd rather not invent a new config flag to handle the static vs. dynamic libunwind issue unless we need to. In addition to this problem on IA64 I found that the 32 bit PA compiler was not building (due to a problem with not finding libgcc_s) and that the 64 bit PA compiler was not handling -static-libstdc. This patch fixes those problems as well with the change to configure.ac. Hopefully, there is no issue with the configure.ac change, but I would like some feedback on the unwind_ipinfo.m4 and gcc.c changes for USE_SYSTEM_LIBUNWIND. I don't know if there is a better way to handle this or not. Tested on IA64 HP-UX and Linux and on 32 and 64 bit PA. OK for checkin? Steve Ellcey s...@cup.hp.com config/ChangeLog 2011-07-28 Steve Ellcey <s...@cup.hp.com> * unwind_ipinfo.m4 (USE_SYSTEM_LIBUNWIND): Define. gcc/ChangeLog 2011-07-28 Steve Ellcey <s...@cup.hp.com> * configure.ac (gcc_cv_ld_static_dynamic): Define for *-*-hpux*. (gcc_cv_ld_static_option): Ditto. (gcc_cv_ld_dynamic_option): Ditto. * gcc.c (init_spec): Use USE_SYSTEM_LIBUNWIND. Index: config/unwind_ipinfo.m4 =================================================================== --- config/unwind_ipinfo.m4 (revision 176899) +++ config/unwind_ipinfo.m4 (working copy) @@ -34,4 +34,8 @@ if test x$have_unwind_getipinfo = xyes; then AC_DEFINE(HAVE_GETIPINFO, 1, [Define if _Unwind_GetIPInfo is available.]) fi + + if test x$with_system_libunwind = xyes; then + AC_DEFINE(USE_SYSTEM_LIBUNWIND, 1, [Define if using system unwind library.]) + fi ]) Index: gcc/configure.ac =================================================================== --- gcc/configure.ac (revision 176899) +++ gcc/configure.ac (working copy) @@ -3240,6 +3240,13 @@ *-*-solaris2*) gcc_cv_ld_static_dynamic=yes ;; + *-*-hpux*) + if test x"$gnu_ld" = xno; then + gcc_cv_ld_static_dynamic=yes + gcc_cv_ld_static_option="-aarchive" + gcc_cv_ld_dynamic_option="-adefault" + fi + ;; esac fi fi Index: gcc/gcc.c =================================================================== --- gcc/gcc.c (revision 176899) +++ gcc/gcc.c (working copy) @@ -1389,7 +1389,7 @@ "-lgcc", "-lgcc_eh" #ifdef USE_LIBUNWIND_EXCEPTIONS -# ifdef HAVE_LD_STATIC_DYNAMIC +# if defined(HAVE_LD_STATIC_DYNAMIC) && !defined(USE_SYSTEM_LIBUNWIND) " %{!static:" LD_STATIC_OPTION "} -lunwind" " %{!static:" LD_DYNAMIC_OPTION "}" # else