powerpc-link-with-math-lib.patch.conditional 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. http://gcc.gnu.org/ml/gcc-patches/2008-10/msg00269.html
  2. On glibc the libc.so carries a copy of the math function copysignl() but
  3. on uClibc math functions like copysignl() live in libm. Since libgcc_s
  4. contains unresolved symbols, any attempt to link against libgcc_s
  5. without explicitely specifying -lm fails, resulting in a broken
  6. bootstrap of the compiler.
  7. Forward port to gcc 4.5.1 by Gustavo Zacarias <gustavo@zacarias.com.ar>
  8. ---
  9. libgcc/Makefile.in | 4 +++-
  10. libgcc/configure | 32 ++++++++++++++++++++++++++++++++
  11. libgcc/configure.ac | 21 +++++++++++++++++++++
  12. 3 files changed, 56 insertions(+), 1 deletion(-)
  13. Index: gcc-4.8.0/libgcc/Makefile.in
  14. ===================================================================
  15. --- gcc-4.8.0.orig/libgcc/Makefile.in 2013-02-04 20:06:20.000000000 +0100
  16. +++ gcc-4.8.0/libgcc/Makefile.in 2013-03-24 09:12:43.000000000 +0100
  17. @@ -41,6 +41,7 @@
  18. decimal_float = @decimal_float@
  19. enable_decimal_float = @enable_decimal_float@
  20. fixed_point = @fixed_point@
  21. +LIBGCC_LIBM = @LIBGCC_LIBM@
  22. host_noncanonical = @host_noncanonical@
  23. target_noncanonical = @target_noncanonical@
  24. @@ -927,9 +928,10 @@
  25. @multilib_dir@,$(MULTIDIR),$(subst \
  26. @shlib_objs@,$(objects) libgcc.a,$(subst \
  27. @shlib_base_name@,libgcc_s,$(subst \
  28. + @libgcc_libm@,$(LIBGCC_LIBM),$(subst \
  29. @shlib_map_file@,$(mapfile),$(subst \
  30. @shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(subst \
  31. - @shlib_slibdir@,$(shlib_slibdir),$(SHLIB_LINK))))))))
  32. + @shlib_slibdir@,$(shlib_slibdir),$(SHLIB_LINK)))))))))
  33. libunwind$(SHLIB_EXT): $(libunwind-s-objects) $(extra-parts)
  34. # @multilib_flags@ is still needed because this may use
  35. Index: gcc-4.8.0/libgcc/configure
  36. ===================================================================
  37. --- gcc-4.8.0.orig/libgcc/configure 2012-11-05 00:08:42.000000000 +0100
  38. +++ gcc-4.8.0/libgcc/configure 2013-03-24 09:12:43.000000000 +0100
  39. @@ -564,6 +564,7 @@
  40. tmake_file
  41. sfp_machine_header
  42. set_use_emutls
  43. +LIBGCC_LIBM
  44. set_have_cc_tls
  45. vis_hide
  46. fixed_point
  47. @@ -4481,6 +4482,37 @@
  48. fi
  49. fi
  50. +# On powerpc libgcc_s references copysignl which is a libm function but
  51. +# glibc apparently also provides it via libc as opposed to uClibc where
  52. +# it lives in libm.
  53. +echo "$as_me:$LINENO: checking for library containing copysignl" >&5
  54. +echo $ECHO_N "checking for library containing copysignl... $ECHO_C" >&6
  55. +if test "${libgcc_cv_copysignl_lib+set}" = set; then
  56. + echo $ECHO_N "(cached) $ECHO_C" >&6
  57. +else
  58. +
  59. + echo '#include <features.h>' > conftest.c
  60. + echo 'int the_libc = __UCLIBC__ + __powerpc__;' >> conftest.c
  61. + libgcc_cv_copysignl_lib="-lc"
  62. + if { ac_try='${CC-cc} -S conftest.c -o conftest.s 1>&5'
  63. + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
  64. + (eval $ac_try) 2>&5
  65. + ac_status=$?
  66. + echo "$as_me:$LINENO: \$? = $ac_status" >&5
  67. + (exit $ac_status); }; }
  68. + then
  69. + libgcc_cv_copysignl_lib="-lm"
  70. + fi
  71. + rm -f conftest.*
  72. +
  73. +fi
  74. +echo "$as_me:$LINENO: result: $libgcc_cv_copysignl_lib" >&5
  75. +echo "${ECHO_T}$libgcc_cv_copysignl_lib" >&6
  76. +
  77. +case /${libgcc_cv_copysignl_lib}/ in
  78. + /-lm/) LIBGCC_LIBM="$LIBGCC_LIBM -lm" ;;
  79. + *) LIBGCC_LIBM= ;;
  80. +esac
  81. # Conditionalize the makefile for this target machine.
  82. tmake_file_=
  83. Index: gcc-4.8.0/libgcc/configure.ac
  84. ===================================================================
  85. --- gcc-4.8.0.orig/libgcc/configure.ac 2012-10-15 15:10:30.000000000 +0200
  86. +++ gcc-4.8.0/libgcc/configure.ac 2013-03-24 09:12:43.000000000 +0100
  87. @@ -326,6 +326,27 @@
  88. fi
  89. AC_SUBST(set_have_cc_tls)
  90. +# On powerpc libgcc_s references copysignl which is a libm function but
  91. +# glibc apparently also provides it via libc as opposed to uClibc where
  92. +# it lives in libm.
  93. +AC_CACHE_CHECK
  94. + libgcc_cv_copysignl_lib,
  95. + echo '#include <features.h>' > conftest.c
  96. + echo 'int the_libc = __UCLIBC__ + __powerpc__;' >> conftest.c
  97. + libgcc_cv_copysignl_lib="-lc"
  98. + if AC_TRY_COMMAND(${CC-cc} -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD)
  99. + then
  100. + libgcc_cv_copysignl_lib="-lm"
  101. + fi
  102. + rm -f conftest.*
  103. + ])
  104. +
  105. +case /${libgcc_cv_copysignl_lib}/ in
  106. + /-lm/) LIBGCC_LIBM="$LIBGCC_LIBM -lm" ;;
  107. + *) LIBGCC_LIBM= ;;
  108. +esac
  109. +AC_SUBST(LIBGCC_LIBM)
  110. +
  111. # See if we have emulated thread-local storage.
  112. GCC_CHECK_EMUTLS
  113. set_use_emutls=