Fix for -mminimal-toc detection, enable BTLS on FreeBSD PowerPC (#2175)
authormonojenkins <jo.shields+jenkins@xamarin.com>
Mon, 27 Jan 2020 10:21:29 +0000 (05:21 -0500)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Mon, 27 Jan 2020 10:21:29 +0000 (11:21 +0100)
Fixes mono/mono#18554 by making autoconf actually check if `-mminimal-toc` works instead of assuming on powerpc. Tested with FreeBSD 12.x and 13.x on powerpc64 ELFv2.
While we are in here, also enable BTLS which has passed testing.

Co-authored-by: Phil Jaenke <prj@rootwyrm.com>
src/mono/configure.ac

index 1e54e1c..18218e3 100644 (file)
@@ -4465,8 +4465,21 @@ case "$host" in
                if test "x$ac_cv_sizeof_void_p" = "x8"; then
                        TARGET=POWERPC64;
                        CPPFLAGS="$CPPFLAGS -D__mono_ppc__ -D__mono_ppc64__"
+                       # mono#18554 - be more robust in testing for -mminimal-toc
+                       AC_MSG_NOTICE([Checking PowerPC ABI])
                        if ! (echo $CC | grep -q -- 'clang'); then
-                               CFLAGS="$CFLAGS -mminimal-toc"
+                               if ! (echo | cc -dM -E - | awk '/_CALL_ELF/ {print $NF}'); then
+                                       AX_CHECK_COMPILE_FLAG(
+                                               [-mminimal-toc],
+                                               [CFLAGS="$CFLAGS -mminimal-toc"],
+                                               [CFLAGS="$CFLAGS"]
+                                       )
+                                       AC_DEFINE([POWERPC_ELF], 1, [PowerPC ELFv1])
+                               else
+                                       # Do not set -mminimal-toc on ELFv2 systems
+                                       AC_DEFINE([POWERPC_ELFV2], 1, [PowerPC ELFv2])
+                                       CFLAGS="$CFLAGS"
+                               fi
                        fi
                else
                        TARGET=POWERPC;
@@ -4482,6 +4495,10 @@ case "$host" in
                        BTLS_SUPPORTED=yes
                        BTLS_PLATFORM=powerpc
                        ;;
+                 freebsd*)
+                       BTLS_SUPPORTED=yes
+                       BTLS_PLATFORM=powerpc
+                       ;;
                esac
                ;;
        armv7k-*-darwin*)