RFR: 8308293: A linker should expose the layouts it supports [v2]
Paul Sandoz
psandoz at openjdk.org
Thu May 18 16:54:55 UTC 2023
On Wed, 17 May 2023 18:18:03 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> This patch adds an instance method on `Linker`, namely `Linker::canonicalLayouts` which returns all the layouts known by the linker as implementing some ABI type. For instance, if I call this on my machine (Linux/x64) I get this:
>>
>>
>> jshell> import java.lang.foreign.*;
>>
>> jshell> Linker.nativeLinker().canonicalLayouts()
>> $2 ==> {char16_t=c16, int8_t=b8, long=j64, size_t=j64, bool=z8, int=i32, long long=j64, int64_t=j64, void*=a64, float=f32, char=b8, int16_t=s16, int32_t=i32, short=s16, double=d64}
>>
>>
>> This can be useful to discover the ABI types supported by a linker implementation, as well as for, in the future, add support for more exotic (and platform-dependent) linker types, such as `long double` or `complex long`.
>
> Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:
>
> Tweak javadoc
Here's the crux of what i am wondering about. Can we specify native linker support for a subset of the System V Application Binary Interface (e.g., LP64 and ILP32 programming models for all non-optional scalar types, sequences of, and groups of) such that a developer can write code using the FFM API and it will work across all JDK implementations supporting that native linker?
AFAICT the closest we have to that is the table in the Linker doc, and that table references C type names. Perhaps we can use C type name as the ABI type name for the System V Application Binary Interface? (literally copy the name used in Figure 3.1 C column of the ABI specification).
Then can do we the same and specify the equivalent native linker support for ABIs of Windows 64/32 and ARM?
-------------
PR Comment: https://git.openjdk.org/jdk/pull/14037#issuecomment-1553337761
More information about the core-libs-dev
mailing list