diff --git a/.github/actions/setup-build-env/action.yml b/.github/actions/setup-build-env/action.yml index b5eec3923..04975f73c 100644 --- a/.github/actions/setup-build-env/action.yml +++ b/.github/actions/setup-build-env/action.yml @@ -70,3 +70,6 @@ runs: - name: Fetch prebuilt V8 shell: bash run: ./download_v8.sh + - name: Fetch prebuilt libffi + shell: bash + run: ./download_libffi.sh diff --git a/.gitignore b/.gitignore index 61e225b20..20631a082 100644 --- a/.gitignore +++ b/.gitignore @@ -81,14 +81,17 @@ v8_build !tools/v8/ !tools/v8/** +# +# libffi follows the same rule: download_libffi.sh installs the release pinned +# in LIBFFI_RELEASE, built by NativeScript/libffi-buildscripts. libffi.h is +# ours (it picks the architecture's headers) and stays tracked. /.v8-prebuilt/ +/.libffi-prebuilt/ NativeScript/lib/*/*.a -!NativeScript/lib/*/libffi.a NativeScript/lib/.v8-release-stamp +NativeScript/lib/.libffi-release-stamp NativeScript/include/** !NativeScript/include/libffi.h -!NativeScript/include/libffi/ -!NativeScript/include/libffi/** NativeScript/inspector/src/ NativeScript/inspector/third_party/ NativeScript/inspector/absl/ diff --git a/.gitmodules b/.gitmodules index 91c1df441..0170f4ed0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,3 @@ -[submodule "libffi"] - path = libffi - url = https://github.com/NativeScript/libffi.git - branch = feat/vector-types [submodule "TestRunner/app/shared"] path = TestRunner/app/shared url = https://github.com/NativeScript/common-runtime-tests-app.git diff --git a/LIBFFI_RELEASE b/LIBFFI_RELEASE new file mode 100644 index 000000000..be7034920 --- /dev/null +++ b/LIBFFI_RELEASE @@ -0,0 +1 @@ +libffi-3.8.1-1 diff --git a/NativeScript/include/libffi/arm64/ffi.h b/NativeScript/include/libffi/arm64/ffi.h deleted file mode 100644 index d281418cf..000000000 --- a/NativeScript/include/libffi/arm64/ffi.h +++ /dev/null @@ -1,575 +0,0 @@ -/* -----------------------------------------------------------------*-C-*- - libffi 3.7.1 - - Copyright (c) 2011, 2014, 2019, 2021, 2022, 2024, 2025, 2026 Anthony Green - - Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc. - - Permission is hereby granted, free of charge, to any person - obtaining a copy of this software and associated documentation - files (the ``Software''), to deal in the Software without - restriction, including without limitation the rights to use, copy, - modify, merge, publish, distribute, sublicense, and/or sell copies - of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - - ----------------------------------------------------------------------- */ - -/* ------------------------------------------------------------------- - Most of the API is documented in doc/libffi.texi. - - The raw API is designed to bypass some of the argument packing and - unpacking on architectures for which it can be avoided. Routines - are provided to emulate the raw API if the underlying platform - doesn't allow faster implementation. - - More details on the raw API can be found in: - - http://gcc.gnu.org/ml/java/1999-q3/msg00138.html - - and - - http://gcc.gnu.org/ml/java/1999-q3/msg00174.html - -------------------------------------------------------------------- */ - -#ifndef LIBFFI_H -#define LIBFFI_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Specify which architecture libffi is configured for. */ -#ifndef AARCH64 -#define AARCH64 -#endif - -/* ---- System configuration information --------------------------------- */ - -/* If these change, update src/mips/ffitarget.h. */ -#define FFI_TYPE_VOID 0 -#define FFI_TYPE_INT 1 -#define FFI_TYPE_FLOAT 2 -#define FFI_TYPE_DOUBLE 3 -#if 0 -#define FFI_TYPE_LONGDOUBLE 4 -#else -#define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE -#endif -#define FFI_TYPE_UINT8 5 -#define FFI_TYPE_SINT8 6 -#define FFI_TYPE_UINT16 7 -#define FFI_TYPE_SINT16 8 -#define FFI_TYPE_UINT32 9 -#define FFI_TYPE_SINT32 10 -#define FFI_TYPE_UINT64 11 -#define FFI_TYPE_SINT64 12 -#define FFI_TYPE_STRUCT 13 -#define FFI_TYPE_POINTER 14 -#define FFI_TYPE_COMPLEX 15 -#define FFI_TYPE_UINT128 16 -#define FFI_TYPE_SINT128 17 -#define FFI_TYPE_VECTOR 18 - -/* This should always refer to the last type code (for sanity checks). */ -#define FFI_TYPE_LAST FFI_TYPE_VECTOR - -#include "ffitarget.h" - -#ifndef LIBFFI_ASM - -#if defined(_MSC_VER) && !defined(__clang__) -#define __attribute__(X) -#endif - -#include -#include - -/* LONG_LONG_MAX is not always defined (not if STRICT_ANSI, for example). - But we can find it either under the correct ANSI name, or under GNU - C's internal name. */ - -#define FFI_64_BIT_MAX 9223372036854775807 - -#ifdef LONG_LONG_MAX -# define FFI_LONG_LONG_MAX LONG_LONG_MAX -#else -# ifdef LLONG_MAX -# define FFI_LONG_LONG_MAX LLONG_MAX -# ifdef _AIX52 /* or newer has C99 LLONG_MAX */ -# undef FFI_64_BIT_MAX -# define FFI_64_BIT_MAX 9223372036854775807LL -# endif /* _AIX52 or newer */ -# else -# ifdef __GNUC__ -# define FFI_LONG_LONG_MAX __LONG_LONG_MAX__ -# endif -# ifdef _AIX /* AIX 5.1 and earlier have LONGLONG_MAX */ -# ifndef __PPC64__ -# if defined (__IBMC__) || defined (__IBMCPP__) -# define FFI_LONG_LONG_MAX LONGLONG_MAX -# endif -# endif /* __PPC64__ */ -# undef FFI_64_BIT_MAX -# define FFI_64_BIT_MAX 9223372036854775807LL -# endif -# endif -#endif - -/* The closure code assumes that this works on pointers, i.e. a size_t - can hold a pointer. */ - -typedef struct _ffi_type -{ - size_t size; - unsigned short alignment; - unsigned short type; - struct _ffi_type **elements; -} ffi_type; - -/* Need minimal decorations for DLLs to work on Windows. GCC has - autoimport and autoexport. Always mark externally visible symbols - as dllimport for MSVC clients, even if it means an extra indirection - when using the static version of the library. - Besides, as a workaround, they can define FFI_BUILDING if they - *know* they are going to link with the static library. */ -#if defined _MSC_VER && !defined(FFI_STATIC_BUILD) -# if defined FFI_BUILDING_DLL /* Building libffi.DLL with msvcc.sh */ -# define FFI_API __declspec(dllexport) -# else /* Importing libffi.DLL */ -# define FFI_API __declspec(dllimport) -# endif -#else -# define FFI_API -#endif - -/* The externally visible type declarations also need the MSVC DLL - decorations, or they will not be exported from the object file. */ -#if defined LIBFFI_HIDE_BASIC_TYPES -# define FFI_EXTERN FFI_API -#else -# define FFI_EXTERN extern FFI_API -#endif - -#ifndef LIBFFI_HIDE_BASIC_TYPES -#if SCHAR_MAX == 127 -# define ffi_type_uchar ffi_type_uint8 -# define ffi_type_schar ffi_type_sint8 -#else - #error "char size not supported" -#endif - -#if SHRT_MAX == 32767 -# define ffi_type_ushort ffi_type_uint16 -# define ffi_type_sshort ffi_type_sint16 -#elif SHRT_MAX == 2147483647 -# define ffi_type_ushort ffi_type_uint32 -# define ffi_type_sshort ffi_type_sint32 -#else - #error "short size not supported" -#endif - -#if INT_MAX == 32767 -# define ffi_type_uint ffi_type_uint16 -# define ffi_type_sint ffi_type_sint16 -#elif INT_MAX == 2147483647 -# define ffi_type_uint ffi_type_uint32 -# define ffi_type_sint ffi_type_sint32 -#elif INT_MAX == 9223372036854775807 -# define ffi_type_uint ffi_type_uint64 -# define ffi_type_sint ffi_type_sint64 -#else - #error "int size not supported" -#endif - -#if LONG_MAX == 2147483647 -# if FFI_LONG_LONG_MAX != FFI_64_BIT_MAX - #error "no 64-bit data type supported" -# endif -#elif LONG_MAX != FFI_64_BIT_MAX - #error "long size not supported" -#endif - -#if LONG_MAX == 2147483647 -# define ffi_type_ulong ffi_type_uint32 -# define ffi_type_slong ffi_type_sint32 -#elif LONG_MAX == FFI_64_BIT_MAX -# define ffi_type_ulong ffi_type_uint64 -# define ffi_type_slong ffi_type_sint64 -#else - #error "long size not supported" -#endif - -/* These are defined in types.c. */ -FFI_EXTERN ffi_type ffi_type_void; -FFI_EXTERN ffi_type ffi_type_uint8; -FFI_EXTERN ffi_type ffi_type_sint8; -FFI_EXTERN ffi_type ffi_type_uint16; -FFI_EXTERN ffi_type ffi_type_sint16; -FFI_EXTERN ffi_type ffi_type_uint32; -FFI_EXTERN ffi_type ffi_type_sint32; -FFI_EXTERN ffi_type ffi_type_uint64; -FFI_EXTERN ffi_type ffi_type_sint64; -FFI_EXTERN ffi_type ffi_type_float; -FFI_EXTERN ffi_type ffi_type_double; -FFI_EXTERN ffi_type ffi_type_pointer; -FFI_EXTERN ffi_type ffi_type_longdouble; - -#ifdef FFI_TARGET_HAS_COMPLEX_TYPE -FFI_EXTERN ffi_type ffi_type_complex_float; -FFI_EXTERN ffi_type ffi_type_complex_double; -FFI_EXTERN ffi_type ffi_type_complex_longdouble; -#endif - -#ifdef FFI_TARGET_HAS_INT128 -FFI_EXTERN ffi_type ffi_type_uint128; -FFI_EXTERN ffi_type ffi_type_sint128; -#endif -#endif /* LIBFFI_HIDE_BASIC_TYPES */ - -typedef enum { - FFI_OK = 0, - FFI_BAD_TYPEDEF, - FFI_BAD_ABI, - FFI_BAD_ARGTYPE -} ffi_status; - -typedef struct { - ffi_abi abi; - unsigned nargs; - ffi_type **arg_types; - ffi_type *rtype; - unsigned bytes; - unsigned flags; -#ifdef FFI_EXTRA_CIF_FIELDS - FFI_EXTRA_CIF_FIELDS; -#endif -} ffi_cif; - -/* ---- Definitions for the raw API -------------------------------------- */ - -#ifndef FFI_SIZEOF_ARG -# if LONG_MAX == 2147483647 -# define FFI_SIZEOF_ARG 4 -# elif LONG_MAX == FFI_64_BIT_MAX -# define FFI_SIZEOF_ARG 8 -# endif -#endif - -#ifndef FFI_SIZEOF_JAVA_RAW -# define FFI_SIZEOF_JAVA_RAW FFI_SIZEOF_ARG -#endif - -typedef union { - ffi_sarg sint; - ffi_arg uint; - float flt; - char data[FFI_SIZEOF_ARG]; - void* ptr; -} ffi_raw; - -#if FFI_SIZEOF_JAVA_RAW == 4 && FFI_SIZEOF_ARG == 8 -/* This is a special case for mips64/n32 ABI (and perhaps others) where - sizeof(void *) is 4 and FFI_SIZEOF_ARG is 8. */ -typedef union { - signed int sint; - unsigned int uint; - float flt; - char data[FFI_SIZEOF_JAVA_RAW]; - void* ptr; -} ffi_java_raw; -#else -typedef ffi_raw ffi_java_raw; -#endif - - -FFI_API -void ffi_raw_call (ffi_cif *cif, - void (*fn)(void), - void *rvalue, - ffi_raw *avalue); - -FFI_API void ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw); -FFI_API void ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args); -FFI_API size_t ffi_raw_size (ffi_cif *cif); - -/* This is analogous to the raw API, except it uses Java parameter - packing, even on 64-bit machines. I.e. on 64-bit machines longs - and doubles are followed by an empty 64-bit word. */ - -#if !FFI_NATIVE_RAW_API -FFI_API -void ffi_java_raw_call (ffi_cif *cif, - void (*fn)(void), - void *rvalue, - ffi_java_raw *avalue) __attribute__((deprecated)); -#endif - -FFI_API -void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw) __attribute__((deprecated)); -FFI_API -void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args) __attribute__((deprecated)); -FFI_API -size_t ffi_java_raw_size (ffi_cif *cif) __attribute__((deprecated)); - -/* ---- Version API ------------------------------------------------------ */ - -#define FFI_VERSION_STRING "3.7.1" -#define FFI_VERSION_NUMBER 30701 - -#ifndef LIBFFI_ASM -/* Return a version string. */ -FFI_API const char *ffi_get_version (void); - -/* Return the version as an unsigned long value: (x * 10000 + y * 100 + z) */ -FFI_API unsigned long ffi_get_version_number (void); -#endif - -/* ---- Internals API ---------------------------------------------------- */ - -FFI_API unsigned int ffi_get_default_abi (void); -FFI_API size_t ffi_get_closure_size (void); - -/* ---- Definitions for closures ----------------------------------------- */ - -#if FFI_CLOSURES - -#ifdef _MSC_VER -__declspec(align(8)) -#endif -typedef struct { -#if 1 - void *trampoline_table; - void *trampoline_table_entry; -#else - /* Anonymous unions are C11 (a GNU extension in C99); __extension__ keeps - the field names without tripping -Wpedantic under -std=c99 (#795). */ -#ifdef __GNUC__ - __extension__ -#endif - union { - char tramp[FFI_TRAMPOLINE_SIZE]; - void *ftramp; - }; -#endif - ffi_cif *cif; - void (*fun)(ffi_cif*,void*,void**,void*); - void *user_data; -#if defined(_MSC_VER) && defined(_M_IX86) - void *padding; -#endif -} ffi_closure -#ifdef __GNUC__ - __attribute__((aligned (8))) -#endif - ; - -#ifndef __GNUC__ -# ifdef __sgi -# pragma pack 0 -# endif -#endif - -FFI_API void *ffi_closure_alloc (size_t size, void **code); -FFI_API void ffi_closure_free (void *); - -FFI_API ffi_status -ffi_prep_closure (ffi_closure*, - ffi_cif *, - void (*fun)(ffi_cif*,void*,void**,void*), - void *user_data) -#if defined(__GNUC__) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 405) - __attribute__((deprecated ("use ffi_prep_closure_loc instead"))) -#elif defined(__GNUC__) && __GNUC__ >= 3 - __attribute__((deprecated)) -#endif - ; - -FFI_API ffi_status -ffi_prep_closure_loc (ffi_closure*, - ffi_cif *, - void (*fun)(ffi_cif*,void*,void**,void*), - void *user_data, - void *codeloc); - -#ifdef __sgi -# pragma pack 8 -#endif -typedef struct { -#if 1 - void *trampoline_table; - void *trampoline_table_entry; -#else - char tramp[FFI_TRAMPOLINE_SIZE]; -#endif - ffi_cif *cif; - -#if !FFI_NATIVE_RAW_API - - /* If this is enabled, then a raw closure has the same layout - as a regular closure. We use this to install an intermediate - handler to do the translation, void** -> ffi_raw*. */ - - void (*translate_args)(ffi_cif*,void*,void**,void*); - void *this_closure; - -#endif - - void (*fun)(ffi_cif*,void*,ffi_raw*,void*); - void *user_data; - -} ffi_raw_closure; - -typedef struct { -#if 1 - void *trampoline_table; - void *trampoline_table_entry; -#else - char tramp[FFI_TRAMPOLINE_SIZE]; -#endif - - ffi_cif *cif; - -#if !FFI_NATIVE_RAW_API - - /* If this is enabled, then a raw closure has the same layout - as a regular closure. We use this to install an intermediate - handler to do the translation, void** -> ffi_raw*. */ - - void (*translate_args)(ffi_cif*,void*,void**,void*); - void *this_closure; - -#endif - - void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*); - void *user_data; - -} ffi_java_raw_closure; - -FFI_API ffi_status -ffi_prep_raw_closure (ffi_raw_closure*, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_raw*,void*), - void *user_data); - -FFI_API ffi_status -ffi_prep_raw_closure_loc (ffi_raw_closure*, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_raw*,void*), - void *user_data, - void *codeloc); - -#if !FFI_NATIVE_RAW_API -FFI_API ffi_status -ffi_prep_java_raw_closure (ffi_java_raw_closure*, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), - void *user_data) __attribute__((deprecated)); - -FFI_API ffi_status -ffi_prep_java_raw_closure_loc (ffi_java_raw_closure*, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), - void *user_data, - void *codeloc) __attribute__((deprecated)); -#endif - -#endif /* FFI_CLOSURES */ - -#ifdef FFI_GO_CLOSURES - -typedef struct { - void *tramp; - ffi_cif *cif; - void (*fun)(ffi_cif*,void*,void**,void*); -} ffi_go_closure; - -FFI_API ffi_status ffi_prep_go_closure (ffi_go_closure*, ffi_cif *, - void (*fun)(ffi_cif*,void*,void**,void*)); - -FFI_API void ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue, - void **avalue, void *closure); - -#endif /* FFI_GO_CLOSURES */ - -/* ---- Public interface definition -------------------------------------- */ - -FFI_API -ffi_status ffi_prep_cif(ffi_cif *cif, - ffi_abi abi, - unsigned int nargs, - ffi_type *rtype, - ffi_type **atypes); - -FFI_API -ffi_status ffi_prep_cif_var(ffi_cif *cif, - ffi_abi abi, - unsigned int nfixedargs, - unsigned int ntotalargs, - ffi_type *rtype, - ffi_type **atypes); - -FFI_API -void ffi_call(ffi_cif *cif, - void (*fn)(void), - void *rvalue, - void **avalue); - -/* Reusable call plans. - - A plan captures a signature's argument placement once so that repeated - calls skip the per-call work that ffi_call would otherwise redo. Build one - with ffi_call_plan_alloc, invoke it as many times as you like, and release - it with ffi_call_plan_free. - - The plan is opaque and caller-owned. The cif must outlive the plan. - ffi_call_plan_alloc returns NULL only on allocation failure; a signature - with no fast path is still valid and ffi_call_plan_invoke falls back to - ffi_call for it. A plan is immutable once built, so it may be shared and - invoked concurrently from multiple threads. */ -typedef struct ffi_call_plan ffi_call_plan; - -FFI_API -ffi_call_plan *ffi_call_plan_alloc (ffi_cif *cif); - -FFI_API -void ffi_call_plan_invoke (ffi_call_plan *plan, - void (*fn)(void), - void *rvalue, - void **avalue); - -FFI_API -void ffi_call_plan_free (ffi_call_plan *plan); - -FFI_API -ffi_status ffi_get_struct_offsets (ffi_abi abi, ffi_type *struct_type, - size_t *offsets); - -/* Convert between closure and function pointers. */ -#if defined(PA_LINUX) || defined(PA_HPUX) -#define FFI_FN(f) ((void (*)(void))((unsigned int)(f) | 2)) -#define FFI_CL(f) ((void *)((unsigned int)(f) & ~3)) -#else -#define FFI_FN(f) ((void (*)(void))f) -#define FFI_CL(f) ((void *)(f)) -#endif - -/* ---- Definitions shared with assembly code ---------------------------- */ - -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/NativeScript/include/libffi/arm64/ffitarget.h b/NativeScript/include/libffi/arm64/ffitarget.h deleted file mode 100644 index 8ba86799e..000000000 --- a/NativeScript/include/libffi/arm64/ffitarget.h +++ /dev/null @@ -1,103 +0,0 @@ -/* Copyright (c) 2009, 2010, 2011, 2012 ARM Ltd. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -``Software''), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#ifndef LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - -#ifndef LIBFFI_ASM -#ifdef __ILP32__ -#define FFI_SIZEOF_ARG 8 -#define FFI_SIZEOF_JAVA_RAW 4 -typedef unsigned long long ffi_arg; -typedef signed long long ffi_sarg; -#elif defined(_WIN32) -#define FFI_SIZEOF_ARG 8 -typedef unsigned long long ffi_arg; -typedef signed long long ffi_sarg; -#else -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; -#endif - -typedef enum ffi_abi - { - FFI_FIRST_ABI = 0, - FFI_SYSV, - FFI_WIN64, - FFI_LAST_ABI, -#if defined(_WIN32) - FFI_DEFAULT_ABI = FFI_WIN64 -#else - FFI_DEFAULT_ABI = FFI_SYSV -#endif - } ffi_abi; -#endif - -/* ---- Definitions for closures ----------------------------------------- */ - -#define FFI_CLOSURES 1 -#define FFI_NATIVE_RAW_API 0 - -#if defined (FFI_EXEC_TRAMPOLINE_TABLE) && FFI_EXEC_TRAMPOLINE_TABLE - -#ifdef __MACH__ -#define FFI_TRAMPOLINE_SIZE 16 -#define FFI_TRAMPOLINE_CLOSURE_OFFSET 16 -#else -#error "No trampoline table implementation" -#endif - -#else -#define FFI_TRAMPOLINE_SIZE 24 -#define FFI_TRAMPOLINE_CLOSURE_OFFSET FFI_TRAMPOLINE_SIZE -#endif - -#ifdef _WIN32 -#define FFI_EXTRA_CIF_FIELDS unsigned is_variadic -#endif -#define FFI_TARGET_SPECIFIC_VARIADIC - -/* ---- Internal ---- */ - -#if defined (__APPLE__) -#define FFI_EXTRA_CIF_FIELDS unsigned aarch64_nfixedargs -#elif !defined(_WIN32) && !defined(__ANDROID__) -/* iOS, Windows and Android reserve x18 for the system. Disable Go closures until - a new static chain is chosen. */ -#define FFI_GO_CLOSURES 1 -#endif - -#ifndef _WIN32 -/* No complex type on Windows */ -#define FFI_TARGET_HAS_COMPLEX_TYPE -#endif - -/* AAPCS64 passes 8- and 16-byte vectors in V/Q registers and homogeneous - vector aggregates in consecutive V/Q registers; see is_vfp_type. */ -#define FFI_TARGET_HAS_VECTOR_TYPE - -#define FFI_TARGET_HAS_INT128 1 - -#endif diff --git a/NativeScript/include/libffi/x86_64/ffi.h b/NativeScript/include/libffi/x86_64/ffi.h deleted file mode 100644 index 07044832c..000000000 --- a/NativeScript/include/libffi/x86_64/ffi.h +++ /dev/null @@ -1,575 +0,0 @@ -/* -----------------------------------------------------------------*-C-*- - libffi 3.7.1 - - Copyright (c) 2011, 2014, 2019, 2021, 2022, 2024, 2025, 2026 Anthony Green - - Copyright (c) 1996-2003, 2007, 2008 Red Hat, Inc. - - Permission is hereby granted, free of charge, to any person - obtaining a copy of this software and associated documentation - files (the ``Software''), to deal in the Software without - restriction, including without limitation the rights to use, copy, - modify, merge, publish, distribute, sublicense, and/or sell copies - of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - - ----------------------------------------------------------------------- */ - -/* ------------------------------------------------------------------- - Most of the API is documented in doc/libffi.texi. - - The raw API is designed to bypass some of the argument packing and - unpacking on architectures for which it can be avoided. Routines - are provided to emulate the raw API if the underlying platform - doesn't allow faster implementation. - - More details on the raw API can be found in: - - http://gcc.gnu.org/ml/java/1999-q3/msg00138.html - - and - - http://gcc.gnu.org/ml/java/1999-q3/msg00174.html - -------------------------------------------------------------------- */ - -#ifndef LIBFFI_H -#define LIBFFI_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Specify which architecture libffi is configured for. */ -#ifndef X86_64 -#define X86_64 -#endif - -/* ---- System configuration information --------------------------------- */ - -/* If these change, update src/mips/ffitarget.h. */ -#define FFI_TYPE_VOID 0 -#define FFI_TYPE_INT 1 -#define FFI_TYPE_FLOAT 2 -#define FFI_TYPE_DOUBLE 3 -#if 1 -#define FFI_TYPE_LONGDOUBLE 4 -#else -#define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE -#endif -#define FFI_TYPE_UINT8 5 -#define FFI_TYPE_SINT8 6 -#define FFI_TYPE_UINT16 7 -#define FFI_TYPE_SINT16 8 -#define FFI_TYPE_UINT32 9 -#define FFI_TYPE_SINT32 10 -#define FFI_TYPE_UINT64 11 -#define FFI_TYPE_SINT64 12 -#define FFI_TYPE_STRUCT 13 -#define FFI_TYPE_POINTER 14 -#define FFI_TYPE_COMPLEX 15 -#define FFI_TYPE_UINT128 16 -#define FFI_TYPE_SINT128 17 -#define FFI_TYPE_VECTOR 18 - -/* This should always refer to the last type code (for sanity checks). */ -#define FFI_TYPE_LAST FFI_TYPE_VECTOR - -#include "ffitarget.h" - -#ifndef LIBFFI_ASM - -#if defined(_MSC_VER) && !defined(__clang__) -#define __attribute__(X) -#endif - -#include -#include - -/* LONG_LONG_MAX is not always defined (not if STRICT_ANSI, for example). - But we can find it either under the correct ANSI name, or under GNU - C's internal name. */ - -#define FFI_64_BIT_MAX 9223372036854775807 - -#ifdef LONG_LONG_MAX -# define FFI_LONG_LONG_MAX LONG_LONG_MAX -#else -# ifdef LLONG_MAX -# define FFI_LONG_LONG_MAX LLONG_MAX -# ifdef _AIX52 /* or newer has C99 LLONG_MAX */ -# undef FFI_64_BIT_MAX -# define FFI_64_BIT_MAX 9223372036854775807LL -# endif /* _AIX52 or newer */ -# else -# ifdef __GNUC__ -# define FFI_LONG_LONG_MAX __LONG_LONG_MAX__ -# endif -# ifdef _AIX /* AIX 5.1 and earlier have LONGLONG_MAX */ -# ifndef __PPC64__ -# if defined (__IBMC__) || defined (__IBMCPP__) -# define FFI_LONG_LONG_MAX LONGLONG_MAX -# endif -# endif /* __PPC64__ */ -# undef FFI_64_BIT_MAX -# define FFI_64_BIT_MAX 9223372036854775807LL -# endif -# endif -#endif - -/* The closure code assumes that this works on pointers, i.e. a size_t - can hold a pointer. */ - -typedef struct _ffi_type -{ - size_t size; - unsigned short alignment; - unsigned short type; - struct _ffi_type **elements; -} ffi_type; - -/* Need minimal decorations for DLLs to work on Windows. GCC has - autoimport and autoexport. Always mark externally visible symbols - as dllimport for MSVC clients, even if it means an extra indirection - when using the static version of the library. - Besides, as a workaround, they can define FFI_BUILDING if they - *know* they are going to link with the static library. */ -#if defined _MSC_VER && !defined(FFI_STATIC_BUILD) -# if defined FFI_BUILDING_DLL /* Building libffi.DLL with msvcc.sh */ -# define FFI_API __declspec(dllexport) -# else /* Importing libffi.DLL */ -# define FFI_API __declspec(dllimport) -# endif -#else -# define FFI_API -#endif - -/* The externally visible type declarations also need the MSVC DLL - decorations, or they will not be exported from the object file. */ -#if defined LIBFFI_HIDE_BASIC_TYPES -# define FFI_EXTERN FFI_API -#else -# define FFI_EXTERN extern FFI_API -#endif - -#ifndef LIBFFI_HIDE_BASIC_TYPES -#if SCHAR_MAX == 127 -# define ffi_type_uchar ffi_type_uint8 -# define ffi_type_schar ffi_type_sint8 -#else - #error "char size not supported" -#endif - -#if SHRT_MAX == 32767 -# define ffi_type_ushort ffi_type_uint16 -# define ffi_type_sshort ffi_type_sint16 -#elif SHRT_MAX == 2147483647 -# define ffi_type_ushort ffi_type_uint32 -# define ffi_type_sshort ffi_type_sint32 -#else - #error "short size not supported" -#endif - -#if INT_MAX == 32767 -# define ffi_type_uint ffi_type_uint16 -# define ffi_type_sint ffi_type_sint16 -#elif INT_MAX == 2147483647 -# define ffi_type_uint ffi_type_uint32 -# define ffi_type_sint ffi_type_sint32 -#elif INT_MAX == 9223372036854775807 -# define ffi_type_uint ffi_type_uint64 -# define ffi_type_sint ffi_type_sint64 -#else - #error "int size not supported" -#endif - -#if LONG_MAX == 2147483647 -# if FFI_LONG_LONG_MAX != FFI_64_BIT_MAX - #error "no 64-bit data type supported" -# endif -#elif LONG_MAX != FFI_64_BIT_MAX - #error "long size not supported" -#endif - -#if LONG_MAX == 2147483647 -# define ffi_type_ulong ffi_type_uint32 -# define ffi_type_slong ffi_type_sint32 -#elif LONG_MAX == FFI_64_BIT_MAX -# define ffi_type_ulong ffi_type_uint64 -# define ffi_type_slong ffi_type_sint64 -#else - #error "long size not supported" -#endif - -/* These are defined in types.c. */ -FFI_EXTERN ffi_type ffi_type_void; -FFI_EXTERN ffi_type ffi_type_uint8; -FFI_EXTERN ffi_type ffi_type_sint8; -FFI_EXTERN ffi_type ffi_type_uint16; -FFI_EXTERN ffi_type ffi_type_sint16; -FFI_EXTERN ffi_type ffi_type_uint32; -FFI_EXTERN ffi_type ffi_type_sint32; -FFI_EXTERN ffi_type ffi_type_uint64; -FFI_EXTERN ffi_type ffi_type_sint64; -FFI_EXTERN ffi_type ffi_type_float; -FFI_EXTERN ffi_type ffi_type_double; -FFI_EXTERN ffi_type ffi_type_pointer; -FFI_EXTERN ffi_type ffi_type_longdouble; - -#ifdef FFI_TARGET_HAS_COMPLEX_TYPE -FFI_EXTERN ffi_type ffi_type_complex_float; -FFI_EXTERN ffi_type ffi_type_complex_double; -FFI_EXTERN ffi_type ffi_type_complex_longdouble; -#endif - -#ifdef FFI_TARGET_HAS_INT128 -FFI_EXTERN ffi_type ffi_type_uint128; -FFI_EXTERN ffi_type ffi_type_sint128; -#endif -#endif /* LIBFFI_HIDE_BASIC_TYPES */ - -typedef enum { - FFI_OK = 0, - FFI_BAD_TYPEDEF, - FFI_BAD_ABI, - FFI_BAD_ARGTYPE -} ffi_status; - -typedef struct { - ffi_abi abi; - unsigned nargs; - ffi_type **arg_types; - ffi_type *rtype; - unsigned bytes; - unsigned flags; -#ifdef FFI_EXTRA_CIF_FIELDS - FFI_EXTRA_CIF_FIELDS; -#endif -} ffi_cif; - -/* ---- Definitions for the raw API -------------------------------------- */ - -#ifndef FFI_SIZEOF_ARG -# if LONG_MAX == 2147483647 -# define FFI_SIZEOF_ARG 4 -# elif LONG_MAX == FFI_64_BIT_MAX -# define FFI_SIZEOF_ARG 8 -# endif -#endif - -#ifndef FFI_SIZEOF_JAVA_RAW -# define FFI_SIZEOF_JAVA_RAW FFI_SIZEOF_ARG -#endif - -typedef union { - ffi_sarg sint; - ffi_arg uint; - float flt; - char data[FFI_SIZEOF_ARG]; - void* ptr; -} ffi_raw; - -#if FFI_SIZEOF_JAVA_RAW == 4 && FFI_SIZEOF_ARG == 8 -/* This is a special case for mips64/n32 ABI (and perhaps others) where - sizeof(void *) is 4 and FFI_SIZEOF_ARG is 8. */ -typedef union { - signed int sint; - unsigned int uint; - float flt; - char data[FFI_SIZEOF_JAVA_RAW]; - void* ptr; -} ffi_java_raw; -#else -typedef ffi_raw ffi_java_raw; -#endif - - -FFI_API -void ffi_raw_call (ffi_cif *cif, - void (*fn)(void), - void *rvalue, - ffi_raw *avalue); - -FFI_API void ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw); -FFI_API void ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args); -FFI_API size_t ffi_raw_size (ffi_cif *cif); - -/* This is analogous to the raw API, except it uses Java parameter - packing, even on 64-bit machines. I.e. on 64-bit machines longs - and doubles are followed by an empty 64-bit word. */ - -#if !FFI_NATIVE_RAW_API -FFI_API -void ffi_java_raw_call (ffi_cif *cif, - void (*fn)(void), - void *rvalue, - ffi_java_raw *avalue) __attribute__((deprecated)); -#endif - -FFI_API -void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw) __attribute__((deprecated)); -FFI_API -void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args) __attribute__((deprecated)); -FFI_API -size_t ffi_java_raw_size (ffi_cif *cif) __attribute__((deprecated)); - -/* ---- Version API ------------------------------------------------------ */ - -#define FFI_VERSION_STRING "3.7.1" -#define FFI_VERSION_NUMBER 30701 - -#ifndef LIBFFI_ASM -/* Return a version string. */ -FFI_API const char *ffi_get_version (void); - -/* Return the version as an unsigned long value: (x * 10000 + y * 100 + z) */ -FFI_API unsigned long ffi_get_version_number (void); -#endif - -/* ---- Internals API ---------------------------------------------------- */ - -FFI_API unsigned int ffi_get_default_abi (void); -FFI_API size_t ffi_get_closure_size (void); - -/* ---- Definitions for closures ----------------------------------------- */ - -#if FFI_CLOSURES - -#ifdef _MSC_VER -__declspec(align(8)) -#endif -typedef struct { -#if 0 - void *trampoline_table; - void *trampoline_table_entry; -#else - /* Anonymous unions are C11 (a GNU extension in C99); __extension__ keeps - the field names without tripping -Wpedantic under -std=c99 (#795). */ -#ifdef __GNUC__ - __extension__ -#endif - union { - char tramp[FFI_TRAMPOLINE_SIZE]; - void *ftramp; - }; -#endif - ffi_cif *cif; - void (*fun)(ffi_cif*,void*,void**,void*); - void *user_data; -#if defined(_MSC_VER) && defined(_M_IX86) - void *padding; -#endif -} ffi_closure -#ifdef __GNUC__ - __attribute__((aligned (8))) -#endif - ; - -#ifndef __GNUC__ -# ifdef __sgi -# pragma pack 0 -# endif -#endif - -FFI_API void *ffi_closure_alloc (size_t size, void **code); -FFI_API void ffi_closure_free (void *); - -FFI_API ffi_status -ffi_prep_closure (ffi_closure*, - ffi_cif *, - void (*fun)(ffi_cif*,void*,void**,void*), - void *user_data) -#if defined(__GNUC__) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 405) - __attribute__((deprecated ("use ffi_prep_closure_loc instead"))) -#elif defined(__GNUC__) && __GNUC__ >= 3 - __attribute__((deprecated)) -#endif - ; - -FFI_API ffi_status -ffi_prep_closure_loc (ffi_closure*, - ffi_cif *, - void (*fun)(ffi_cif*,void*,void**,void*), - void *user_data, - void *codeloc); - -#ifdef __sgi -# pragma pack 8 -#endif -typedef struct { -#if 0 - void *trampoline_table; - void *trampoline_table_entry; -#else - char tramp[FFI_TRAMPOLINE_SIZE]; -#endif - ffi_cif *cif; - -#if !FFI_NATIVE_RAW_API - - /* If this is enabled, then a raw closure has the same layout - as a regular closure. We use this to install an intermediate - handler to do the translation, void** -> ffi_raw*. */ - - void (*translate_args)(ffi_cif*,void*,void**,void*); - void *this_closure; - -#endif - - void (*fun)(ffi_cif*,void*,ffi_raw*,void*); - void *user_data; - -} ffi_raw_closure; - -typedef struct { -#if 0 - void *trampoline_table; - void *trampoline_table_entry; -#else - char tramp[FFI_TRAMPOLINE_SIZE]; -#endif - - ffi_cif *cif; - -#if !FFI_NATIVE_RAW_API - - /* If this is enabled, then a raw closure has the same layout - as a regular closure. We use this to install an intermediate - handler to do the translation, void** -> ffi_raw*. */ - - void (*translate_args)(ffi_cif*,void*,void**,void*); - void *this_closure; - -#endif - - void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*); - void *user_data; - -} ffi_java_raw_closure; - -FFI_API ffi_status -ffi_prep_raw_closure (ffi_raw_closure*, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_raw*,void*), - void *user_data); - -FFI_API ffi_status -ffi_prep_raw_closure_loc (ffi_raw_closure*, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_raw*,void*), - void *user_data, - void *codeloc); - -#if !FFI_NATIVE_RAW_API -FFI_API ffi_status -ffi_prep_java_raw_closure (ffi_java_raw_closure*, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), - void *user_data) __attribute__((deprecated)); - -FFI_API ffi_status -ffi_prep_java_raw_closure_loc (ffi_java_raw_closure*, - ffi_cif *cif, - void (*fun)(ffi_cif*,void*,ffi_java_raw*,void*), - void *user_data, - void *codeloc) __attribute__((deprecated)); -#endif - -#endif /* FFI_CLOSURES */ - -#ifdef FFI_GO_CLOSURES - -typedef struct { - void *tramp; - ffi_cif *cif; - void (*fun)(ffi_cif*,void*,void**,void*); -} ffi_go_closure; - -FFI_API ffi_status ffi_prep_go_closure (ffi_go_closure*, ffi_cif *, - void (*fun)(ffi_cif*,void*,void**,void*)); - -FFI_API void ffi_call_go (ffi_cif *cif, void (*fn)(void), void *rvalue, - void **avalue, void *closure); - -#endif /* FFI_GO_CLOSURES */ - -/* ---- Public interface definition -------------------------------------- */ - -FFI_API -ffi_status ffi_prep_cif(ffi_cif *cif, - ffi_abi abi, - unsigned int nargs, - ffi_type *rtype, - ffi_type **atypes); - -FFI_API -ffi_status ffi_prep_cif_var(ffi_cif *cif, - ffi_abi abi, - unsigned int nfixedargs, - unsigned int ntotalargs, - ffi_type *rtype, - ffi_type **atypes); - -FFI_API -void ffi_call(ffi_cif *cif, - void (*fn)(void), - void *rvalue, - void **avalue); - -/* Reusable call plans. - - A plan captures a signature's argument placement once so that repeated - calls skip the per-call work that ffi_call would otherwise redo. Build one - with ffi_call_plan_alloc, invoke it as many times as you like, and release - it with ffi_call_plan_free. - - The plan is opaque and caller-owned. The cif must outlive the plan. - ffi_call_plan_alloc returns NULL only on allocation failure; a signature - with no fast path is still valid and ffi_call_plan_invoke falls back to - ffi_call for it. A plan is immutable once built, so it may be shared and - invoked concurrently from multiple threads. */ -typedef struct ffi_call_plan ffi_call_plan; - -FFI_API -ffi_call_plan *ffi_call_plan_alloc (ffi_cif *cif); - -FFI_API -void ffi_call_plan_invoke (ffi_call_plan *plan, - void (*fn)(void), - void *rvalue, - void **avalue); - -FFI_API -void ffi_call_plan_free (ffi_call_plan *plan); - -FFI_API -ffi_status ffi_get_struct_offsets (ffi_abi abi, ffi_type *struct_type, - size_t *offsets); - -/* Convert between closure and function pointers. */ -#if defined(PA_LINUX) || defined(PA_HPUX) -#define FFI_FN(f) ((void (*)(void))((unsigned int)(f) | 2)) -#define FFI_CL(f) ((void *)((unsigned int)(f) & ~3)) -#else -#define FFI_FN(f) ((void (*)(void))f) -#define FFI_CL(f) ((void *)(f)) -#endif - -/* ---- Definitions shared with assembly code ---------------------------- */ - -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/NativeScript/include/libffi/x86_64/ffitarget.h b/NativeScript/include/libffi/x86_64/ffitarget.h deleted file mode 100644 index 734ac955c..000000000 --- a/NativeScript/include/libffi/x86_64/ffitarget.h +++ /dev/null @@ -1,172 +0,0 @@ -/* -----------------------------------------------------------------*-C-*- - ffitarget.h - Copyright (c) 2012, 2014, 2018, 2026 Anthony Green - Copyright (c) 1996-2003, 2010 Red Hat, Inc. - Copyright (C) 2008 Free Software Foundation, Inc. - - Target configuration macros for x86 and x86-64. - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - ``Software''), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - - ----------------------------------------------------------------------- */ - -#ifndef LIBFFI_TARGET_H -#define LIBFFI_TARGET_H - -#ifndef LIBFFI_H -#error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." -#endif - -/* ---- System specific configurations ----------------------------------- */ - -/* For code common to all platforms on x86 and x86_64. */ -#define X86_ANY - -#if defined (X86_64) && defined (__i386__) -#undef X86_64 -#define X86 -#endif - -#ifdef X86_WIN64 -#define FFI_SIZEOF_ARG 8 -#define USE_BUILTIN_FFS 0 /* not yet implemented in mingw-64 */ -#endif - -#define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION -#ifndef _MSC_VER -#define FFI_TARGET_HAS_COMPLEX_TYPE -#endif - -#ifdef X86_64 -#define FFI_TARGET_HAS_INT128 -#endif - -/* The System V x86-64 psABI passes 8- and 16-byte vectors in SSE registers; - this is implemented by the ffi64.c (FFI_UNIX64) backend only. 32-bit x86 - and the Windows x86-64 backend (ffiw64.c) do not marshal vectors. */ -#if defined(X86_64) && !defined(X86_WIN64) -#define FFI_TARGET_HAS_VECTOR_TYPE -#endif - -/* ---- Generic type definitions ----------------------------------------- */ - -#ifndef LIBFFI_ASM -#ifdef X86_WIN64 -#ifdef _MSC_VER -typedef unsigned __int64 ffi_arg; -typedef __int64 ffi_sarg; -#else -typedef unsigned long long ffi_arg; -typedef long long ffi_sarg; -#endif -#else -#if defined __x86_64__ && defined __ILP32__ -#define FFI_SIZEOF_ARG 8 -#define FFI_SIZEOF_JAVA_RAW 4 -typedef unsigned long long ffi_arg; -typedef long long ffi_sarg; -#else -typedef unsigned long ffi_arg; -typedef signed long ffi_sarg; -#endif -#endif - -typedef enum ffi_abi { -#if defined(X86_WIN64) - FFI_FIRST_ABI = 0, - FFI_WIN64, /* sizeof(long double) == 8 - microsoft compilers */ - FFI_GNUW64, /* sizeof(long double) == 16 - GNU compilers */ - FFI_LAST_ABI, -#ifdef __GNUC__ - FFI_DEFAULT_ABI = FFI_GNUW64 -#else - FFI_DEFAULT_ABI = FFI_WIN64 -#endif - -#elif defined(X86_64) || (defined (__x86_64__) && defined (X86_DARWIN)) - FFI_FIRST_ABI = 1, - FFI_UNIX64, - FFI_WIN64, - FFI_EFI64 = FFI_WIN64, - FFI_GNUW64, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_UNIX64 - -#elif defined(X86_WIN32) - FFI_FIRST_ABI = 0, - FFI_SYSV = 1, - FFI_STDCALL = 2, - FFI_THISCALL = 3, - FFI_FASTCALL = 4, - FFI_MS_CDECL = 5, - FFI_PASCAL = 6, - FFI_REGISTER = 7, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_MS_CDECL -#else - FFI_FIRST_ABI = 0, - FFI_SYSV = 1, - FFI_THISCALL = 3, - FFI_FASTCALL = 4, - FFI_STDCALL = 5, - FFI_PASCAL = 6, - FFI_REGISTER = 7, - FFI_MS_CDECL = 8, - FFI_LAST_ABI, - FFI_DEFAULT_ABI = FFI_SYSV -#endif -} ffi_abi; -#endif - -/* ---- Definitions for closures ----------------------------------------- */ - -#define FFI_CLOSURES 1 -#define FFI_GO_CLOSURES 1 - -#define FFI_TYPE_SMALL_STRUCT_1B (FFI_TYPE_LAST + 1) -#define FFI_TYPE_SMALL_STRUCT_2B (FFI_TYPE_LAST + 2) -#define FFI_TYPE_SMALL_STRUCT_4B (FFI_TYPE_LAST + 3) -#define FFI_TYPE_MS_STRUCT (FFI_TYPE_LAST + 4) - -#if defined (X86_64) || defined(X86_WIN64) \ - || (defined (__x86_64__) && defined (X86_DARWIN)) -/* 4 bytes of ENDBR64 + 7 bytes of LEA + 6 bytes of JMP + 7 bytes of NOP - + 8 bytes of pointer. */ -# define FFI_TRAMPOLINE_SIZE 32 -# define FFI_NATIVE_RAW_API 0 -#else -/* 4 bytes of ENDBR32 + 5 bytes of MOV + 5 bytes of JMP + 2 unused - bytes. */ -# define FFI_TRAMPOLINE_SIZE 16 -# define FFI_NATIVE_RAW_API 1 /* x86 has native raw api support */ -#endif - -#if !defined(GENERATE_LIBFFI_MAP) && defined(__CET__) -# include -# if (__CET__ & 1) != 0 -# define ENDBR_PRESENT -# endif -# define _CET_NOTRACK notrack -#else -# define _CET_ENDBR -# define _CET_NOTRACK -#endif - -#endif diff --git a/NativeScript/lib/arm64-iphoneos/libffi.a b/NativeScript/lib/arm64-iphoneos/libffi.a deleted file mode 100644 index 6243c781f..000000000 Binary files a/NativeScript/lib/arm64-iphoneos/libffi.a and /dev/null differ diff --git a/NativeScript/lib/arm64-iphonesimulator/libffi.a b/NativeScript/lib/arm64-iphonesimulator/libffi.a deleted file mode 100644 index 65011a747..000000000 Binary files a/NativeScript/lib/arm64-iphonesimulator/libffi.a and /dev/null differ diff --git a/NativeScript/lib/arm64-maccatalyst/libffi.a b/NativeScript/lib/arm64-maccatalyst/libffi.a deleted file mode 100644 index ab876e2f8..000000000 Binary files a/NativeScript/lib/arm64-maccatalyst/libffi.a and /dev/null differ diff --git a/NativeScript/lib/arm64-xros/libffi.a b/NativeScript/lib/arm64-xros/libffi.a deleted file mode 100644 index 79cbbb770..000000000 Binary files a/NativeScript/lib/arm64-xros/libffi.a and /dev/null differ diff --git a/NativeScript/lib/arm64-xrsimulator/libffi.a b/NativeScript/lib/arm64-xrsimulator/libffi.a deleted file mode 100644 index 90ed38178..000000000 Binary files a/NativeScript/lib/arm64-xrsimulator/libffi.a and /dev/null differ diff --git a/NativeScript/lib/x86_64-iphonesimulator/libffi.a b/NativeScript/lib/x86_64-iphonesimulator/libffi.a deleted file mode 100644 index 4823c0ccf..000000000 Binary files a/NativeScript/lib/x86_64-iphonesimulator/libffi.a and /dev/null differ diff --git a/NativeScript/lib/x86_64-maccatalyst/libffi.a b/NativeScript/lib/x86_64-maccatalyst/libffi.a deleted file mode 100644 index b9d574402..000000000 Binary files a/NativeScript/lib/x86_64-maccatalyst/libffi.a and /dev/null differ diff --git a/README.md b/README.md index e34660f82..4a16fb412 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,9 @@ git submodule update --init # (set V8_SKIP_DOWNLOAD=1 to keep a local V8 build instead) ./download_v8.sh +# Fetch the prebuilt libffi libraries and headers for the release pinned in LIBFFI_RELEASE +./download_libffi.sh + sudo gem install xcodeproj sudo gem install cocoapods @@ -143,6 +146,24 @@ release assets — which it has to, because the full matrix cannot be produced o any single machine: the 32-bit Android ABIs need an ia32-capable host and the Apple variants need macOS. +# Updating libffi + +libffi is installed the same way. `./download_libffi.sh` installs the libraries +and the per-architecture `ffi.h`/`ffitarget.h` from the release pinned in +`LIBFFI_RELEASE`, after checking them against the release's checksums. +`build_nativescript.sh` calls it for you. + +``` +./download_libffi.sh # install the pinned release +./download_libffi.sh --release # install a different one +./download_libffi.sh --from-dir /dist # install a local build +``` + +The releases come from +[NativeScript/libffi-buildscripts](https://github.com/NativeScript/libffi-buildscripts), +which builds upstream's release tarball for every Apple variant. To move to a +new libffi version, cut a release there and update `LIBFFI_RELEASE`. + # Building a Distribution Package diff --git a/build_libffi.sh b/build_libffi.sh deleted file mode 100755 index f25cd0419..000000000 --- a/build_libffi.sh +++ /dev/null @@ -1,184 +0,0 @@ -#!/bin/bash -set -euo pipefail - -# Builds static libffi slices from the ./libffi submodule for every platform -# the runtime ships, using the currently selected Xcode (xcode-select / -# DEVELOPER_DIR) instead of hardcoded /Applications/Xcode.app paths. -# -# Builds run out-of-tree under build/libffi/ (gitignored) so the libffi -# submodule stays clean. Artifacts land in build/libffi/dist// -# {lib/libffi.a,include}. With --install they are also copied into -# NativeScript/lib// and NativeScript/include/libffi// (the -# vendored locations the Xcode project links against). -# -# Note: all slices build from the same libffi source. On x86_64 the vector -# (SIMD) support caps at 16-byte vectors — wider vectors are rejected with -# FFI_BAD_TYPEDEF at prep time (documented libffi port limitation). - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -LIBFFI_DIR="$SCRIPT_DIR/libffi" -BUILD_ROOT="$SCRIPT_DIR/build/libffi" -DIST_DIR="$BUILD_ROOT/dist" - -ALL_SLICES=( - arm64-iphoneos - arm64-iphonesimulator - arm64-xros - arm64-xrsimulator - x86_64-iphonesimulator - arm64-maccatalyst - x86_64-maccatalyst -) - -IOS_MIN=13.0 -XROS_MIN=2.0 -CATALYST_MIN=13.3 -# The arm64 macabi triple has no deployment targets below 14.0. -CATALYST_ARM64_MIN=14.0 - -usage() { - cat </ and NativeScript/include/libffi// - --jobs N parallel make jobs (default: number of CPUs) - -h, --help show this help -EOF -} - -INSTALL=0 -JOBS="$(sysctl -n hw.ncpu)" -SLICES=() - -while [[ $# -gt 0 ]]; do - case "$1" in - --install) - INSTALL=1 - ;; - --jobs) - shift - if [ $# -eq 0 ] || ! [[ "$1" =~ ^[0-9]+$ ]]; then - echo "--jobs requires a numeric argument" >&2 - usage - exit 1 - fi - JOBS="$1" - ;; - -h|--help) - usage - exit 0 - ;; - -*) - echo "Unknown option: $1" >&2 - usage - exit 1 - ;; - *) - SLICES+=("$1") - ;; - esac - shift -done - -if [ ${#SLICES[@]} -eq 0 ]; then - SLICES=("${ALL_SLICES[@]}") -fi - -CLANG="$(xcrun -f clang)" -CLANGXX="$(xcrun -f clang++)" - -# slice -> "sdk|host triple|target cflags" -slice_config() { - case "$1" in - arm64-iphoneos) - echo "iphoneos|aarch64-apple-darwin|-arch arm64 -miphoneos-version-min=$IOS_MIN" - ;; - arm64-iphonesimulator) - echo "iphonesimulator|aarch64-apple-darwin|-arch arm64 -mios-simulator-version-min=$IOS_MIN" - ;; - arm64-xros) - echo "xros|aarch64-apple-darwin|-target arm64-apple-xros$XROS_MIN" - ;; - arm64-xrsimulator) - echo "xrsimulator|aarch64-apple-darwin|-target arm64-apple-xros$XROS_MIN-simulator" - ;; - x86_64-iphonesimulator) - echo "iphonesimulator|x86_64-apple-darwin|-arch x86_64 -mios-simulator-version-min=$IOS_MIN" - ;; - arm64-maccatalyst) - echo "macosx|aarch64-apple-darwin|-target arm64-apple-ios$CATALYST_ARM64_MIN-macabi" - ;; - x86_64-maccatalyst) - echo "macosx|x86_64-apple-darwin|-target x86_64-apple-ios$CATALYST_MIN-macabi" - ;; - *) - echo "" - ;; - esac -} - -for slice in "${SLICES[@]}"; do - if [ -z "$(slice_config "$slice")" ]; then - echo "Unknown slice: $slice (known: ${ALL_SLICES[*]})" >&2 - exit 1 - fi -done - -pushd "$LIBFFI_DIR" >/dev/null -# Regenerate the build system so a submodule bump can never pair stale -# configure output with new sources. macOS installs GNU libtoolize as -# glibtoolize (via Homebrew). -LIBTOOLIZE="${LIBTOOLIZE:-glibtoolize}" ./autogen.sh -popd >/dev/null - -rm -rf "$DIST_DIR" - -for slice in "${SLICES[@]}"; do - IFS='|' read -r sdk host target_cflags <<< "$(slice_config "$slice")" - sdk_path="$(xcrun --sdk "$sdk" --show-sdk-path)" - build_dir="$BUILD_ROOT/build-$slice" - out_dir="$DIST_DIR/$slice" - - echo "==> $slice (sdk: $(basename "$sdk_path"))" - - rm -rf "$build_dir" - mkdir -p "$build_dir" "$out_dir/lib" "$out_dir/include" - - pushd "$build_dir" >/dev/null - CC="$CLANG $target_cflags -isysroot $sdk_path" \ - CXX="$CLANGXX $target_cflags -isysroot $sdk_path" \ - "$LIBFFI_DIR/configure" --disable-shared --disable-docs --host="$host" >/dev/null - - make -j"$JOBS" >/dev/null - - cp .libs/libffi.a "$out_dir/lib/libffi.a" - cp include/ffi.h include/ffitarget.h "$out_dir/include/" - popd >/dev/null - - rm -rf "$build_dir" -done - -if [ "$INSTALL" -eq 1 ]; then - for slice in "${SLICES[@]}"; do - arch="${slice%%-*}" - echo "==> installing $slice" - mkdir -p "$SCRIPT_DIR/NativeScript/lib/$slice" "$SCRIPT_DIR/NativeScript/include/libffi/$arch" - cp "$DIST_DIR/$slice/lib/libffi.a" "$SCRIPT_DIR/NativeScript/lib/$slice/libffi.a" - # The generated headers are identical for every slice of the same arch. - cp "$DIST_DIR/$slice/include/ffi.h" "$DIST_DIR/$slice/include/ffitarget.h" \ - "$SCRIPT_DIR/NativeScript/include/libffi/$arch/" - # Upstream ffi.h includes its sibling with angle brackets, which only - # resolves in Xcode via basename headermaps — ambiguous with two arch - # copies of ffitarget.h in the project. Use a quoted include so each - # ffi.h deterministically picks up the ffitarget.h next to it. - sed -i '' 's|#include |#include "ffitarget.h"|' \ - "$SCRIPT_DIR/NativeScript/include/libffi/$arch/ffi.h" - done -fi - -echo "Done. Artifacts in $DIST_DIR" diff --git a/build_nativescript.sh b/build_nativescript.sh index 34a32a723..fb0b82a11 100755 --- a/build_nativescript.sh +++ b/build_nativescript.sh @@ -2,9 +2,11 @@ set -e source "$(dirname "$0")/build_utils.sh" -# The V8 libraries and headers are not committed; fetch the pinned release. -# No-ops once they are in place, and honours V8_SKIP_DOWNLOAD=1. +# The V8 and libffi libraries and headers are not committed; fetch the pinned +# releases. Both no-op once they are in place; download_v8.sh honours +# V8_SKIP_DOWNLOAD=1. "$(dirname "$0")/download_v8.sh" +"$(dirname "$0")/download_libffi.sh" function to_bool() { local arg="$1" diff --git a/download_libffi.sh b/download_libffi.sh new file mode 100755 index 000000000..09e029f8f --- /dev/null +++ b/download_libffi.sh @@ -0,0 +1,190 @@ +#!/bin/bash +set -euo pipefail +# +# Installs the prebuilt libffi libraries and headers for the pinned release. +# +# The artifacts are built by NativeScript/libffi-buildscripts from upstream's +# checksummed release tarball and published as GitHub release assets rather +# than committed here, so every binary traces back to a CI run and a source +# checksum. +# +# Like download_v8.sh, this is a standalone prerequisite rather than an Xcode +# build phase: run it once; it is a no-op while the pinned release is in place. +# +# Usage: download_libffi.sh [--release ] [--from-dir ] [--force] +# + +REPO_ROOT="$(cd "$(dirname "$0")" && pwd)" +UPSTREAM="NativeScript/libffi-buildscripts" +RELEASE_FILE="$REPO_ROOT/LIBFFI_RELEASE" +CACHE_DIR="${LIBFFI_PREBUILT_CACHE:-$REPO_ROOT/.libffi-prebuilt}" + +NS_DIR="$REPO_ROOT/NativeScript" +LIB_DIR="$NS_DIR/lib" +INC_DIR="$NS_DIR/include/libffi" +STAMP="$LIB_DIR/.libffi-release-stamp" + +RELEASE="" +FROM_DIR="" +FORCE=0 + +usage() { + cat <] [--from-dir ] [--force] + + --release Release to install (default: contents of LIBFFI_RELEASE) + --from-dir Install from a local libffi-buildscripts build instead: the + directory holding its ios-/ folders (its dist/). + Later runs without --force leave that install alone. + --force Reinstall even if the pinned release is already in place + +Downloads are cached in $CACHE_DIR (override with \$LIBFFI_PREBUILT_CACHE). +EOF +} + +while [ $# -gt 0 ]; do + case "$1" in + --release) RELEASE="$2"; shift 2 ;; + --release=*) RELEASE="${1#*=}"; shift ;; + --from-dir) FROM_DIR="$2"; shift 2 ;; + --from-dir=*) FROM_DIR="${1#*=}"; shift ;; + --force) FORCE=1; shift ;; + -h|--help) usage; exit 0 ;; + *) echo "Unknown argument: $1" >&2; usage >&2; exit 1 ;; + esac +done + +if [ -n "$RELEASE" ] && [ -n "$FROM_DIR" ]; then + echo "--release and --from-dir are mutually exclusive" >&2 + exit 1 +fi + +if [ -z "$RELEASE" ] && [ -z "$FROM_DIR" ]; then + [ -f "$RELEASE_FILE" ] || { echo "Missing $RELEASE_FILE" >&2; exit 1; } + RELEASE="$(tr -d '[:space:]' < "$RELEASE_FILE")" +fi + +# Release variant -> the runtime's library directories it is installed into. +VARIANTS=( + "arm64-device:arm64-iphoneos" + "arm64-simulator:arm64-iphonesimulator" + "x64-simulator:x86_64-iphonesimulator" + "arm64-catalyst:arm64-maccatalyst" + "x64-catalyst:x86_64-maccatalyst" + "arm64-xrdevice:arm64-xros" + "arm64-xrsimulator:arm64-xrsimulator" +) +# The generated headers depend only on the architecture. +HEADER_SOURCES=( + "arm64:arm64-device" + "x86_64:x64-simulator" +) + +# The stamp alone is not enough: it says what was installed, not that the +# files are still on disk. +files_present() { + local entry + for entry in "${VARIANTS[@]}"; do + [ -f "$LIB_DIR/${entry#*:}/libffi.a" ] || return 1 + done + for entry in "${HEADER_SOURCES[@]}"; do + [ -f "$INC_DIR/${entry%%:*}/ffi.h" ] && [ -f "$INC_DIR/${entry%%:*}/ffitarget.h" ] || return 1 + done +} + +if [ "$FORCE" = "0" ] && [ -z "$FROM_DIR" ] && [ -f "$STAMP" ] && files_present; then + installed="$(cat "$STAMP")" + if [ "$installed" = "$RELEASE" ]; then + echo "libffi $RELEASE already installed. Use --force to reinstall." + exit 0 + fi + case "$installed" in + local:*) + echo "libffi from ${installed#local:} is installed; leaving it in place." + echo "Use --force to install $RELEASE instead." + exit 0 + ;; + esac +fi + +STAGE="$(mktemp -d)" +trap 'rm -rf "$STAGE"' EXIT + +if [ -n "$FROM_DIR" ]; then + FROM_DIR="$(cd "$FROM_DIR" && pwd)" + echo "Installing libffi from $FROM_DIR" + for entry in "${VARIANTS[@]}"; do + variant="${entry%%:*}" + [ -d "$FROM_DIR/ios-$variant" ] || { echo "$FROM_DIR has no ios-$variant/" >&2; exit 1; } + cp -R "$FROM_DIR/ios-$variant" "$STAGE/" + done + STAMP_VALUE="local:$FROM_DIR" +else + BASE_URL="https://github.com/$UPSTREAM/releases/download/$RELEASE" + DL="$CACHE_DIR/$RELEASE" + mkdir -p "$DL" + + fetch() { + local name="$1" + [ -f "$DL/$name" ] && return 0 + echo " downloading $name" + curl -fSL --retry 3 -o "$DL/$name.part" "$BASE_URL/$name" + mv "$DL/$name.part" "$DL/$name" + } + + echo "Installing libffi $RELEASE from $UPSTREAM" + fetch SHA256SUMS + + ASSETS=() + for entry in "${VARIANTS[@]}"; do + variant="${entry%%:*}" + asset="$(grep -oE "libffi-[^ ]*-ios-$variant\.tar\.gz" "$DL/SHA256SUMS" | head -1 || true)" + [ -n "$asset" ] || { echo "Release $RELEASE has no ios-$variant archive." >&2; exit 1; } + ASSETS+=("$asset") + fetch "$asset" + done + + # Verify before unpacking anything: a release is only trustworthy because + # the archive matches the checksum published with it. + if command -v sha256sum > /dev/null 2>&1; then + SHA256_CHECK="sha256sum -c -" + else + SHA256_CHECK="shasum -a 256 -c -" + fi + echo "Verifying checksums" + ( cd "$DL" && grep -E "$(printf '%s|' "${ASSETS[@]}" | sed 's/|$//')" SHA256SUMS | $SHA256_CHECK ) \ + || { echo "Checksum verification FAILED for $RELEASE" >&2; exit 1; } + + for a in "${ASSETS[@]}"; do tar -xzf "$DL/$a" -C "$STAGE"; done + STAMP_VALUE="$RELEASE" +fi + +# Cleared before the first file is replaced, so an install that fails partway +# is redone by the next run instead of passing as the previous one. +rm -f "$STAMP" + +echo "Installing libraries" +for entry in "${VARIANTS[@]}"; do + variant="${entry%%:*}" + dest="$LIB_DIR/${entry#*:}" + src="$STAGE/ios-$variant/lib/libffi.a" + [ -f "$src" ] || { echo "ios-$variant has no lib/libffi.a" >&2; exit 1; } + mkdir -p "$dest" + cp "$src" "$dest/libffi.a" +done + +echo "Installing headers" +for entry in "${HEADER_SOURCES[@]}"; do + arch="${entry%%:*}" + src="$STAGE/ios-${entry#*:}/include" + [ -f "$src/ffi.h" ] && [ -f "$src/ffitarget.h" ] || { echo "ios-${entry#*:} has no ffi headers" >&2; exit 1; } + mkdir -p "$INC_DIR/$arch" + cp "$src/ffi.h" "$src/ffitarget.h" "$INC_DIR/$arch/" + # Upstream's ffi.h includes , which Xcode resolves through a + # basename headermap -- ambiguous with both architectures' copies in the + # project. A quoted include always picks the ffitarget.h beside it. + sed -i '' 's|#include |#include "ffitarget.h"|' "$INC_DIR/$arch/ffi.h" +done + +echo "$STAMP_VALUE" > "$STAMP" +echo "Installed libffi ${STAMP_VALUE}" diff --git a/download_v8.sh b/download_v8.sh index aa85bc49b..1418fba91 100755 --- a/download_v8.sh +++ b/download_v8.sh @@ -140,7 +140,7 @@ for entry in "${VARIANTS[@]}"; do [ -d "$src" ] || { echo "Archive for $variant has no lib/" >&2; exit 1; } for dest in ${entry#*:}; do mkdir -p "$LIB_DIR/$dest" - # libffi.a is built by build_libffi.sh and lives in the same directory, + # libffi.a is installed by download_libffi.sh into the same directory, # so only the V8 archives are replaced. find "$LIB_DIR/$dest" -maxdepth 1 -name '*.a' ! -name 'libffi.a' -delete cp "$src"/*.a "$LIB_DIR/$dest/" @@ -148,8 +148,8 @@ for entry in "${VARIANTS[@]}"; do done echo "Installing public headers" -# libffi's headers live in the same directory, so V8's are replaced selectively -# rather than by wiping include/. +# libffi's headers (installed by download_libffi.sh) live in the same directory, +# so V8's are replaced selectively rather than by wiping include/. SRC_INC="$STAGE/ios-arm64-device/include" [ -d "$SRC_INC" ] || { echo "Archive has no include/" >&2; exit 1; } for entry in cppgc libplatform inspector; do diff --git a/libffi b/libffi deleted file mode 160000 index 71a95a2cd..000000000 --- a/libffi +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 71a95a2cd433b151b3fcf83a0a830eb9aa38fa3a