I have the same code compiled with different arch options (FMV does not work as the functions return sse and i can't change "default" to something with sse) How can i make a meta-library that at load time checks the cpu capability and load the corresponding lib? (without any dlsym machinery)?
One way to achieve what you want is to link against dummy wrapper library which checks CPU capabilities at startup, loads matching shared library and then forwards all function calls to their implementations in this shared library.
Such dummy library may be implemented by hand or generated via custom script. Or you can use Implib.so to generate it automatically:
$ implib-gen.py --dlopen-callback=load_mylib mylib_avx.so
You'll need to implement load_mylib
(to analyze CPUID and dlopen
appropriate implementation) and link your app with generated files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With