Upstream local FreeBSD patches (#567)
authorNiclas Zeising <zeising+github@daemonic.se>
Fri, 7 Aug 2020 19:05:23 +0000 (21:05 +0200)
committerGitHub <noreply@github.com>
Fri, 7 Aug 2020 19:05:23 +0000 (15:05 -0400)
* Add support for FreeBSD mips

Add support for FreeBSD mips, this has been a local patch in the FreeBSD
ports tree for quite some time.

Originally submitted by sson, and committed by sbruno AT FreeBSD DOT org
See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=191909 for
background details.

Signed-off-by: Niclas Zeising <zeising@daemonic.se>
* Add support for FreeBSD powerpcspe

Add support for powerpcspe on FreeBSD
This has been in the FreeBSD ports tree for some time.
Originally submitted by jhibbits AT FreeBSD DOT org.

Signed-off-by: Niclas Zeising <zeising@daemonic.se>
* Fix abort() on FreeBSD arm related to __clear_cache()

This patch has been in the FreeBSD ports tree for a number of years.
Original commit by koobs AT FreeBSD DOT org

Original commit message:
> devel/libffi: Fix abort() on ARM related to __clear_cache()
>
> The current FreeBSD/ARM __clear_cache() implementation does nothing #if
> __i386__ || __x86_64__ #else abort();
>
> cognet@ advises this is an issue for anything !Apple that is using the
> libcompiler_rt provided by Clang on ARM, and requires upstreaming.

See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=149167 for some
background details.

Signed-off-by: Niclas Zeising <zeising@daemonic.se>
configure.host
src/arm/ffi.c
src/mips/ffi.c
src/mips/ffitarget.h

index 398c3b554daff9db879e9a0534fc238da087340c..c7d63fd9489e9ae0bb70c05f550d41af6e0efe71 100644 (file)
@@ -179,7 +179,7 @@ case "${host}" in
   mips-sgi-irix5.* | mips-sgi-irix6.* | mips*-*-rtems*)
        TARGET=MIPS; TARGETDIR=mips
        ;;
-  mips*-*linux* | mips*-*-openbsd*)
+  mips*-*linux* | mips*-*-openbsd* | mips*-*-freebsd*)
        # Support 128-bit long double for NewABI.
        HAVE_LONG_DOUBLE='defined(__mips64)'
        TARGET=MIPS; TARGETDIR=mips
@@ -218,6 +218,10 @@ case "${host}" in
        TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc
        HAVE_LONG_DOUBLE_VARIANT=1
        ;;
+  powerpcspe-*-freebsd*)
+       TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc
+       CFLAGS="$CFLAGS -D__NO_FPRS__"
+       ;;
   powerpc64-*-freebsd*)
        TARGET=POWERPC; TARGETDIR=powerpc
        ;;
index 4e270718a3941560a796cf4446df4377c8fabfeb..efea031f727855f5b3388b05a2d3c8ae01ebcc38 100644 (file)
@@ -55,6 +55,11 @@ extern unsigned int ffi_arm_trampoline[3] FFI_HIDDEN;
 #endif
 #endif
 
+#if defined(__FreeBSD__) && defined(__arm__)
+#include <sys/types.h>
+#include <machine/sysarch.h>
+#endif
+
 /* Forward declares. */
 static int vfp_type_p (const ffi_type *);
 static void layout_vfp_args (ffi_cif *);
@@ -569,6 +574,16 @@ void ffi_go_closure_VFP (void) FFI_HIDDEN;
 
 /* the cif must already be prep'ed */
 
+#if defined(__FreeBSD__) && defined(__arm__)
+#define __clear_cache(start, end) do { \
+               struct arm_sync_icache_args ua;                 \
+                                                               \
+               ua.addr = (uintptr_t)(start);                   \
+               ua.len = (char *)(end) - (char *)start;         \
+               sysarch(ARM_SYNC_ICACHE, &ua);                  \
+       } while (0);
+#endif
+
 ffi_status
 ffi_prep_closure_loc (ffi_closure * closure,
                      ffi_cif * cif,
index 057b0466940da6b0cfb713034086fa3aba1e1ff3..979ca49f1bd64b7b49c7f757709bc6eacc9e134c 100644 (file)
@@ -39,7 +39,9 @@
 #endif
 
 #ifndef USE__BUILTIN___CLEAR_CACHE
-#  if defined(__OpenBSD__)
+#  if defined(__FreeBSD__)
+#    include <machine/sysarch.h>
+#  elif defined(__OpenBSD__)
 #    include <mips64/sysarch.h>
 #  else
 #    include <sys/cachectl.h>
@@ -777,11 +779,13 @@ ffi_prep_closure_loc (ffi_closure *closure,
   closure->fun = fun;
   closure->user_data = user_data;
 
+#if !defined(__FreeBSD__)
 #ifdef USE__BUILTIN___CLEAR_CACHE
   __builtin___clear_cache(clear_location, clear_location + FFI_TRAMPOLINE_SIZE);
 #else
   cacheflush (clear_location, FFI_TRAMPOLINE_SIZE, ICACHE);
 #endif
+#endif /* ! __FreeBSD__ */
   return FFI_OK;
 }
 
index fffdb977b48281d243c39159c3199470866b812c..fdd5ca90ac432e271d36feea82a21ab540e6617c 100644 (file)
@@ -41,7 +41,7 @@
 #define _MIPS_SIM_ABI32                1
 #define _MIPS_SIM_NABI32       2
 #define _MIPS_SIM_ABI64                3
-#elif !defined(__OpenBSD__)
+#elif !defined(__OpenBSD__) && !defined(__FreeBSD__)
 # include <sgidefs.h>
 #endif