PerlFFI / FFI-Platypus

Write Perl bindings to non-Perl libraries with FFI. No XS required.
89 stars 23 forks source link

hppa-linux: broken integer support #394

Open danglin44 opened 9 months ago

danglin44 commented 9 months ago

The last version to successfully build on Debian hppa-linux was v0.94.

Commit aa05f0f21c64b3963a4e65d04eefdc00841b4638 exposed the following integer failures:

Test Summary Report

t/type_sint64.t (Wstat: 256 (exited 1) Tests: 3 Failed: 1) Failed test: 3 Non-zero exit status: 1 t/type_uint64.t (Wstat: 256 (exited 1) Tests: 3 Failed: 1) Failed test: 3 Non-zero exit status: 1 Files=63, Tests=311, 120 wallclock secs ( 1.31 usr 1.06 sys + 95.79 cusr 19.74 csys = 117.90 CPU) Result: FAIL Failed 2/63 test programs. 2/311 subtests failed.

    # Failed test at t/type_sint64.t line 127.
    # +--------------+----+-------+
    # | GOT          | OP | CHECK |
    # +--------------+----+-------+
    # | -90371962288 | eq | -22   |
    # +--------------+----+-------+
# Failed test 'argument'
# at t/type_sint64.t line 129.
    # Failed test at t/type_sint64.t line 135.
    # +--------------+----+-------+
    # | GOT          | OP | CHECK |
    # +--------------+----+-------+
    # | -90371962288 | eq | -22   |
    # +--------------+----+-------+
# Failed test 'return value'
# at t/type_sint64.t line 136.

(gdb) p/x (long long)-22 $2 = 0xffffffffffffffea (gdb) p/x -90371962288 $3 = 0xffffffeaf5694a50

Argument and return value access alignment seem wrong.

Things got worse with commit 066068ab418d98729eef4c94869ffb74f9dd4699. See build logs here: https://buildd.debian.org/status/logs.php?pkg=libffi-platypus-perl&arch=hppa The only successful builds didn't run the test suite.

The attached patch gets us back to the type_sint64.t and type_uint64.t fails.

hppa-fix.txt

hppa-linux is 32-bit big endian. The stack grows up. 64-bit ints are double word aligned.