Repository navigation
gh-161475: Fix ctypes structures with float arrays returned on Linux SPARC - #161476
Conversation
…Linux SPARC On Linux, GCC and clang pass arrays of floating-point type in a structure in integer registers; only Solaris follows the vendor ABI there (GCC PR target/114416). Since pythongh-110190, ctypes described such array elements to libffi as floats on all SPARC, so libffi read structures returned by value from the FP registers on Linux.
vstinner
left a comment
There was a problem hiding this comment.
LGTM.
The changed code is already tested by ctypes. Extract of the issue:
test_ctypes fails on Linux sparc64 in test_array_in_struct
|
cc @encukou |
|
Thanks for the ping. I tested it and it (as expected) doesn't break Solaris. I believe that the original fix in gcc was done specifically to Solaris only because they wanted to be careful and we were the only ones who reported it. But now that you also encountered it, maybe they would extend that gcc fix to Linux as well? |
Thanks for testing it on Solaris! I don't think GCC will change it on Linux. The commit (1d238c84025a) says the decision was to fix it on Solaris only, and on Linux there's no vendor compiler to be compatible with, so what GCC does is effectively the ABI there. |
|
GH-161558 is a backport of this pull request to the 3.15 branch. |
|
GH-161559 is a backport of this pull request to the 3.14 branch. |
|
Merged. Thanks for your fix!
Ah thanks, I'm feeling safer with your manual test :-)
You can cc-me on your follow-up fix, I will try to review it. |
… Linux SPARC (GH-161476) (#161559) gh-161475: Fix ctypes structures with float arrays returned on Linux SPARC (GH-161476) On Linux, GCC and clang pass arrays of floating-point type in a structure in integer registers; only Solaris follows the vendor ABI there (GCC PR target/114416). Since gh-110190, ctypes described such array elements to libffi as floats on all SPARC, so libffi read structures returned by value from the FP registers on Linux. (cherry picked from commit 91ba786) Co-authored-by: Stian Halseth <33956011+shalseth@users.noreply.github.com>
… Linux SPARC (GH-161476) (#161558) gh-161475: Fix ctypes structures with float arrays returned on Linux SPARC (GH-161476) On Linux, GCC and clang pass arrays of floating-point type in a structure in integer registers; only Solaris follows the vendor ABI there (GCC PR target/114416). Since gh-110190, ctypes described such array elements to libffi as floats on all SPARC, so libffi read structures returned by value from the FP registers on Linux. (cherry picked from commit 91ba786) Co-authored-by: Stian Halseth <33956011+shalseth@users.noreply.github.com>
Thanks! The follow up has to wait a bit: its test for a struct with a single long double returns nan on x86-64, which turned out to be a libffi bug (libffi/libffi#1058). It will take while before updated libffi is available in all distros. I've parked it for now, but might get back to it in the future. |
|
Ah, maybe close the current Python issue, and create a new one for long double arrays once the libffi issue has been addressed. |
On Linux, GCC and clang pass arrays of floating-point type in a structure in integer registers, only Solaris follows the vendor ABI there (GCC PR target/114416). This describes such array elements to libffi as integers of the same size on Linux SPARC, so libffi reads them from the right registers. Solaris is unchanged.
Tested on a SPARC T7-1 (Linux, GCC 16): test_ctypes passes on main and 3.15, and the full test suite passes on main.
@kulikjak this shouldn't change anything on Solaris, but you may want to have a look since it's next to your gh-110190 change.