On Mon, 25 Mar 2024 09:24:16 GMT, Magnus Ihse Bursie <i...@openjdk.org> wrote:
> > > But that raises an interesting question. What happens if you try to load > > > a library compiled with `-march=armv8-a+sve` on a non-SVE system? Is the > > > ELF flagged to require SVE so it will fail to load? I'm hoping this is > > > the case -- if so, everything will work as it should in this PR, but I > > > honestly don't know. (After spending like 10 years working with building, > > > I still discover things I need to learn...). > > > > > > I think we can handle it, when a jdk built with sve support runs on a > > non-sve machine, the sve related code will not be executed with the > > protection of UseSVE vm flag which is detected at runtime startup. > > You misunderstand me; perhaps I'm not clear enough here. > > First of all, my question was of a more general nature. Is there such a > mechanism in the dynamic linker that protects us from loading libraries that > will fail if an ISA extension is used that is missing on the running system? > Or do the linker just check that the ELF is for the right CPU? IMHO, Ithe dymic linker will not check ISA extension. > > Secondly, I assume that libsleef.so proper needs to be compiled with SVE > support as well. So if we were to skip the shim vectormath library and load > libsleef directly from hotspot, what would happen then? > > Thirdly, the check with UseSVE happens _after_ you load the library. If there > is a DL verification, you will not even reach this check, but get a DLL > loading failure before that. Sure, regardless of which happens, you will not > execute bad code, but I'd like to know which is the case. In that situation, I think UseSVE check will return false to avoid set functions pointer (e.g. StubRoutines::_vector_f_math[VectorSupport::VEC_SIZE_SCALABLE][op]) when running on non-SVE matchine. ------------- PR Comment: https://git.openjdk.org/jdk/pull/18294#issuecomment-2018827762