Skip to content

libffi dependency fails to compile on newer compilers: both clang and gcc #5344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
JamesClarke7283 opened this issue Jun 24, 2024 · 3 comments
Labels
C-bug Something isn't working

Comments

@JamesClarke7283
Copy link
Contributor

Summary

The libffi dependency inside the rustpython-jit crate, fails to compile on newer compilers like those on Archlinux.

Expected

Compilation of rustpython-jit suceeds

Actual

error:

--- stderr
  ../src/java_raw_api.c: In function 'ffi_java_raw_call':
  ../src/java_raw_api.c:317:3: warning: 'ffi_java_raw_to_ptrarray' is deprecated [-Wdeprecated-declarations]
    317 |   ffi_java_raw_to_ptrarray (cif, raw, avalue);
        |   ^~~~~~~~~~~~~~~~~~~~~~~~
  ../src/java_raw_api.c:76:1: note: declared here
     76 | ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_java_raw *raw, void **args)
        | ^~~~~~~~~~~~~~~~~~~~~~~~
  ../src/java_raw_api.c: In function 'ffi_java_translate_args':
  ../src/java_raw_api.c:328:3: warning: 'ffi_java_raw_size' is deprecated [-Wdeprecated-declarations]
    328 |   ffi_java_raw *raw = (ffi_java_raw*)alloca (ffi_java_raw_size (cif));
        |   ^~~~~~~~~~~~
  ../src/java_raw_api.c:45:1: note: declared here
     45 | ffi_java_raw_size (ffi_cif *cif)
        | ^~~~~~~~~~~~~~~~~
  ../src/java_raw_api.c:331:3: warning: 'ffi_java_ptrarray_to_raw' is deprecated [-Wdeprecated-declarations]
    331 |   ffi_java_ptrarray_to_raw (cif, avalue, raw);
        |   ^~~~~~~~~~~~~~~~~~~~~~~~
  ../src/java_raw_api.c:157:1: note: declared here
    157 | ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_java_raw *raw)
        | ^~~~~~~~~~~~~~~~~~~~~~~~
  ../src/java_raw_api.c: In function 'ffi_prep_java_raw_closure':
  ../src/java_raw_api.c:369:3: warning: 'ffi_prep_java_raw_closure_loc' is deprecated [-Wdeprecated-declarations]
    369 |   return ffi_prep_java_raw_closure_loc (cl, cif, fun, user_data, cl);
        |   ^~~~~~
  ../src/java_raw_api.c:337:1: note: declared here
    337 | ffi_prep_java_raw_closure_loc (ffi_java_raw_closure* cl,
        | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ../src/tramp.c: In function 'ffi_tramp_get_temp_file':
  ../src/tramp.c:262:22: error: implicit declaration of function 'open_temp_exec_file' [-Wimplicit-function-declaration]
    262 |   tramp_globals.fd = open_temp_exec_file ();
        |                      ^~~~~~~~~~~~~~~~~~~
  make[2]: *** [Makefile:1320: src/tramp.lo] Error 1
  make[1]: *** [Makefile:1397: install-recursive] Error 1
  make: *** [Makefile:3158: install] Error 2

Python Documentation

N/A

Program versions/System info

gcc (GCC) 14.1.1 20240522
clang version 17.0.6
Linux desktop 6.6.14-gnu-1-lts #1 SMP PREEMPT_DYNAMIC Wed, 31 Jan 2024 02:02:54 +0000 x86_64 GNU/Linux

Solution

Replace libffi dependency with version specifying system version of libffi.
Like so:

[dependencies.libffi]
version = "2.3.0"
features = ["system"]

The downside is the user would need libffi installed on their system, but at least this issue would go.

Alternate solution

clearly this does not work:
tov/libffi-rs@ce05302
So we could get upstream to fix it on their bundled version of libffi.

@JamesClarke7283 JamesClarke7283 added the C-bug Something isn't working label Jun 24, 2024
@jackoconnordev
Copy link

I've encountered this problem too when following the instructions in DEVELOPMENT.md.

There is a recent open issue in tov/libffi-rs where @arihant2math and one other user mentioned they could help maintain the library, so a long-term fix here could be on the way.

My compilation error

error: linking with `cc` failed: exit status: 1
  |
  = note:  "cc" "-m64" "/tmp/rustcIwceHV/symbols.o" "<621 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/{libcompiler_builtins-*}.rlib" "-Wl,-Bdynamic" "-lc" "-ldl" "-lffi" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/jackoconnordev/Code/open-source/RustPython/target/release/deps/rustpython-87f0c4e46fc367e7" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-Wl,--strip-debug" "-nodefaultlibs"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: /usr/bin/ld: cannot find -lffi: No such file or directory
          collect2: error: ld returned 1 exit status

@arihant2math
Copy link
Collaborator

arihant2math commented Apr 29, 2025

That issue is not related.
I think adding a feature for vendoring libffi is the best way forward.
Something like:

libffi-system = ["libffi/system"]

@youknowone
Copy link
Member

Does #5759 help to fix this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants