Skip to content

Please upgrade libffi to ≥ 3.4.3 #1488

@xiangzhai

Description

@xiangzhai

Hi,

Libffi v3.4.3 adds support for static trampoline for LoongArch. Earlier versions, for example, v3.4.2 is lack of loongarch*-*-linux-* for enable_exec_static_tramp:

diff --git a/native/libffi/configure.ac b/native/libffi/configure.ac
index 70f6d2c2e..c70b23bf6 100644
--- a/native/libffi/configure.ac
+++ b/native/libffi/configure.ac
@@ -373,7 +373,7 @@ if test "$enable_exec_static_tramp" != no; then
 case "$target" in
      *-cygwin*)
      ;;  
-     *arm*-*-linux-* | aarch64*-*-linux-* | i*86-*-linux-* | x86_64-*-linux-*)
+     *arm*-*-linux-* | aarch64*-*-linux-* | i*86-*-linux-* | x86_64-*-linux-* | loongarch*-*-linux-*)
        AC_DEFINE(FFI_EXEC_STATIC_TRAMP, 1,
                  [Define this if you want statically defined trampolines])
      ;;         

ffi_tramp_arch for LoongArch64 is NULL when FFI_EXEC_STATIC_TRAMP is not defined, so ffi_tramp_init in the native/libffi/src/tramp.c will early return goto dynamic trampoline instead:

/*
 * Initialize the static trampoline feature.
 */
static int 
ffi_tramp_init (void)
{
  if (tramp_globals.status == TRAMP_GLOBALS_PASSED)
    return 1;

  if (tramp_globals.status == TRAMP_GLOBALS_FAILED)
    return 0;

=>  if (ffi_tramp_arch == NULL)
    {   
      tramp_globals.status = TRAMP_GLOBALS_FAILED;
=>      return 0;
    }   
...

Just merged static trampoline for LoongArch into jna in my local enviroment, passed all Testsuites, no regression.

Thanks,
Leslie Zhai

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions