aboutsummaryrefslogtreecommitdiff
path: root/toolchain/gcc/4.7.3/powerpc-link-with-math-lib.patch.conditional
blob: 2554263a007333e6af71a594abde8a1164002050 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
http://gcc.gnu.org/ml/gcc-patches/2008-10/msg00269.html

On glibc the libc.so carries a copy of the math function copysignl() but
on uClibc math functions like copysignl() live in libm. Since libgcc_s
contains unresolved symbols, any attempt to link against libgcc_s
without explicitely specifying -lm fails, resulting in a broken
bootstrap of the compiler.

Forward ported to gcc 4.7.3

Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>

diff -Nura gcc-4.7.3.orig/libgcc/config/t-slibgcc gcc-4.7.3/libgcc/config/t-slibgcc
--- gcc-4.7.3.orig/libgcc/config/t-slibgcc	2013-04-11 15:23:46.491571116 -0300
+++ gcc-4.7.3/libgcc/config/t-slibgcc	2013-04-11 15:25:06.241141824 -0300
@@ -27,7 +27,7 @@
 SHLIB_OBJS = @shlib_objs@
 SHLIB_DIR = @multilib_dir@
 SHLIB_SLIBDIR_QUAL = @shlib_slibdir_qual@
-SHLIB_LC = -lc
+SHLIB_LC = @libgcc_libm@ -lc
 SHLIB_MAKE_SOLINK = $(LN_S) $(SHLIB_SONAME) $(SHLIB_DIR)/$(SHLIB_SOLINK)
 SHLIB_INSTALL_SOLINK = $(LN_S) $(SHLIB_SONAME) \
 	$(DESTDIR)$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SOLINK)
diff -Nura gcc-4.7.3.orig/libgcc/configure gcc-4.7.3/libgcc/configure
--- gcc-4.7.3.orig/libgcc/configure	2013-04-11 15:23:46.551573051 -0300
+++ gcc-4.7.3/libgcc/configure	2013-04-11 15:25:06.243141875 -0300
@@ -563,6 +563,7 @@
 tmake_file
 sfp_machine_header
 set_use_emutls
+LIBGCC_LIBM
 set_have_cc_tls
 vis_hide
 fixed_point
@@ -4445,6 +4446,37 @@
 	fi
 fi
 
+# On powerpc libgcc_s references copysignl which is a libm function but
+# glibc apparently also provides it via libc as opposed to uClibc where
+# it lives in libm.
+echo "$as_me:$LINENO: checking for library containing copysignl" >&5
+echo $ECHO_N "checking for library containing copysignl... $ECHO_C" >&6
+if test "${libgcc_cv_copysignl_lib+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+    echo '#include <features.h>' > conftest.c
+    echo 'int the_libc = __UCLIBC__ + __powerpc__;' >> conftest.c
+    libgcc_cv_copysignl_lib="-lc"
+    if { ac_try='${CC-cc} -S conftest.c -o conftest.s 1>&5'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }
+    then
+       libgcc_cv_copysignl_lib="-lm"
+    fi
+    rm -f conftest.*
+
+fi
+echo "$as_me:$LINENO: result: $libgcc_cv_copysignl_lib" >&5
+echo "${ECHO_T}$libgcc_cv_copysignl_lib" >&6
+
+case /${libgcc_cv_copysignl_lib}/ in
+  /-lm/) LIBGCC_LIBM="$LIBGCC_LIBM -lm" ;;
+  *) LIBGCC_LIBM= ;;
+esac
 
 # Conditionalize the makefile for this target machine.
 tmake_file_=
diff -Nura gcc-4.7.3.orig/libgcc/configure.ac gcc-4.7.3/libgcc/configure.ac
--- gcc-4.7.3.orig/libgcc/configure.ac	2013-04-11 15:23:46.551573051 -0300
+++ gcc-4.7.3/libgcc/configure.ac	2013-04-11 15:25:06.244141901 -0300
@@ -324,6 +324,27 @@
 fi
 AC_SUBST(set_have_cc_tls)
 
+# On powerpc libgcc_s references copysignl which is a libm function but
+# glibc apparently also provides it via libc as opposed to uClibc where
+# it lives in libm.
+AC_CACHE_CHECK
+  libgcc_cv_copysignl_lib,
+    echo '#include <features.h>' > conftest.c
+    echo 'int the_libc = __UCLIBC__ + __powerpc__;' >> conftest.c
+    libgcc_cv_copysignl_lib="-lc"
+    if AC_TRY_COMMAND(${CC-cc} -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD)
+    then
+       libgcc_cv_copysignl_lib="-lm"
+    fi
+    rm -f conftest.*
+  ])
+
+case /${libgcc_cv_copysignl_lib}/ in
+  /-lm/) LIBGCC_LIBM="$LIBGCC_LIBM -lm" ;;
+  *) LIBGCC_LIBM= ;;
+esac
+AC_SUBST(LIBGCC_LIBM)
+
 # See if we have emulated thread-local storage.
 GCC_CHECK_EMUTLS
 set_use_emutls=
diff -Nura gcc-4.7.3.orig/libgcc/Makefile.in gcc-4.7.3/libgcc/Makefile.in
--- gcc-4.7.3.orig/libgcc/Makefile.in	2013-04-11 15:23:46.537572599 -0300
+++ gcc-4.7.3/libgcc/Makefile.in	2013-04-11 15:25:06.241141824 -0300
@@ -41,6 +41,7 @@
 decimal_float = @decimal_float@
 enable_decimal_float = @enable_decimal_float@
 fixed_point = @fixed_point@
+LIBGCC_LIBM = @LIBGCC_LIBM@
 
 host_noncanonical = @host_noncanonical@
 target_noncanonical = @target_noncanonical@
@@ -928,9 +929,10 @@
 		@multilib_dir@,$(MULTIDIR),$(subst \
 		@shlib_objs@,$(objects) libgcc.a,$(subst \
 		@shlib_base_name@,libgcc_s,$(subst \
+		@libgcc_libm@,$(LIBGCC_LIBM),$(subst \
 		@shlib_map_file@,$(mapfile),$(subst \
 		@shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(subst \
-		@shlib_slibdir@,$(shlib_slibdir),$(SHLIB_LINK))))))))
+		@shlib_slibdir@,$(shlib_slibdir),$(SHLIB_LINK)))))))))
 
 libunwind$(SHLIB_EXT): $(libunwind-s-objects) $(extra-parts)
 	# @multilib_flags@ is still needed because this may use