RFR: 8308293: A linker should expose the layouts it supports [v2]

Paul Sandoz psandoz at openjdk.org
Wed May 17 22:43:49 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

I wonder if we need to be stronger on the compatibility requirements for the supported canonical layouts. It seems we can make stronger claims than symbols made available by the default linker because the ABI supported by the linker will make strong (specification) claims.

So maybe this comes down to the linker supporting a subset ABI's data types, and that subset might increase over time, but never decrease? In this respect could we present a table for each supported linker ABI listing the ABI type and its canonical layout type? (in practice it might just be one table with noted adjustments.)

Then there is the possibility that a linker might change the layout corresponding to a data type. Ideally the linker support the prior layout *and* the new layout. I don't think this will arise with the current support set of supported ABI data types, but it might if we choose to add support for say the optional `__int128` data type prior to the platform adding support for a primitive value class of Int128?

[1] https://gitlab.com/x86-psABIs/x86-64-ABI

-------------

PR Review: https://git.openjdk.org/jdk/pull/14037#pullrequestreview-1431762962


More information about the core-libs-dev mailing list