On Fri, Jul 8, 2022 at 8:41 PM Alexander Monakov <amona...@ispras.ru> wrote: > > > On Fri, 8 Jul 2022, Martin Liška wrote: > > > Hi. > > > > All right, there's updated version of the patch that reflects the following > > suggestions: > > > > 1) strings are used for version identification > > 2) thread-safe API version (1) is not used if target does not support > > locking via pthreads > > > > Patch can bootstrap on x86_64-linux-gnu and survives regression tests. > > > > Ready to be installed? > > Note that mold side will need to be adjusted, because it did not really > implement the proposed contract. Maybe we should be more clear how the > linker is supposed to implement this? Preliminary mold patch does this: > > static PluginLinkerAPIVersion > get_api_version(const char *plugin_identifier, > unsigned plugin_version, > PluginLinkerAPIVersion minimal_api_supported, > PluginLinkerAPIVersion maximal_api_supported, > const char **linker_identifier, > unsigned *linker_version) { > assert(maximal_api_supported >= LAPI_V1); > *linker_identifier = "mold"; > *linker_version = get_mold_version(); > is_gcc_linker_api_v1 = true; > return LAPI_V1; > } > > but ignoring min_api_supported is wrong, and assuming max_api_supported > 0 > is also wrong. It really should check how given [min; max] range intersects > with its own range of supported versions.
Currently only one version is defined which is LAPI_V1. I don't think LAPI_UNSPECIFIED is a version number; rather, it's an unspecified value. No ordering should be defined between a defined value and an unspecified value. If LAPI_UNSPECIFIED < LAPI_V1, it should be renamed LAPI_V0.