Thiago Macieira
2018-10-17 18:05:41 UTC
Ref: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0275r4.html
Hello Antony
Thank you for your proposal. This is an important library addition for
something low-level that has been awfully OS-specific for a long time. I don't
have a comment on questions on whether discussing shared libraries without
specifying TLS, globals, exceptions, ODR violations, etc. is acceptable.
Hopefully you'll get feedback from others on that.
I just wanted to raise the point of having the ability to insert version
numbers in library names, especially when shared_library::add_decorations and/
or shared_library::search_system_directories are in effect. In short, it is
the ability to specify both the library's base name and the expected version
decoration and let the implementation figure out how to properly load them.
QLibrary has this API:
QLibrary libc("c", 6);
QLibrary libssl("ssl", SHLIB_VERSION_NUMBER);
Let me give you a concrete example: loading OpenSSL at runtime (which is the
second line above). Given its licensing and export restrictions that some
countries place on cryptographic code, a common solution is to compile against
OpenSSL headers but not link to it. Instead of calling its functions,
applications and libraries instead load the library at runtime and resolve the
functions they need to call.
But in the presence of multiple ABI-incompatible libraries, one needs to know
which library to load. OpenSSL helpfully provides us with that in the
SHLIB_VERSION_NUMBER macro:
$ grep -r SHLIB_VERSION_NUMBER /usr/include/openssl
/usr/include/openssl/opensslv.h:# define SHLIB_VERSION_NUMBER "1.1"
And that matches the file we need to load:
$ eu-readelf -d /usr/lib64/libssl.so | grep SONAME
SONAME Library soname: [libssl.so.1.1]
Given this need, the ask for shared_library class is to be able to specify
both pieces of information separately and let the implementation reconstruct
the actual file name according to OS details. Like in my QLibrary example, I
want to specify "ssl" plus the "1.1" string only.
I don't want to specify the ".so" part in the name, since this can be
different in different OSes. Notably, it IS different on macOS, which use
"dylib" instead of "so". Not only that, the version number is often placed as
an infix instead of a suffix:
$ ls -l /usr/lib/libssl*
-rwxr-xr-x 1 root wheel 392912 Jan 18 2018 /usr/lib/libssl.0.9.7.dylib
-rwxr-xr-x 1 root wheel 630144 Mai 29 16:36 /usr/lib/libssl.0.9.8.dylib
-rw-r--r-- 1 root wheel 947104 Mai 29 16:36 /usr/lib/libssl.35.dylib
-rw-r--r-- 1 root wheel 890800 Mai 29 16:36 /usr/lib/libssl.43.dylib
lrwxr-xr-x 1 root wheel 15 Mar 15 2018 /usr/lib/libssl.dylib -> libssl.
35.dylib
I also don't want to depend on the unversioned link. As seen in the ls output
above, it can be pointing to the wrong library. Moreover, on Linux systems,
the .so file is often not present unless the optional development headers are
too.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
Hello Antony
Thank you for your proposal. This is an important library addition for
something low-level that has been awfully OS-specific for a long time. I don't
have a comment on questions on whether discussing shared libraries without
specifying TLS, globals, exceptions, ODR violations, etc. is acceptable.
Hopefully you'll get feedback from others on that.
I just wanted to raise the point of having the ability to insert version
numbers in library names, especially when shared_library::add_decorations and/
or shared_library::search_system_directories are in effect. In short, it is
the ability to specify both the library's base name and the expected version
decoration and let the implementation figure out how to properly load them.
QLibrary has this API:
QLibrary libc("c", 6);
QLibrary libssl("ssl", SHLIB_VERSION_NUMBER);
Let me give you a concrete example: loading OpenSSL at runtime (which is the
second line above). Given its licensing and export restrictions that some
countries place on cryptographic code, a common solution is to compile against
OpenSSL headers but not link to it. Instead of calling its functions,
applications and libraries instead load the library at runtime and resolve the
functions they need to call.
But in the presence of multiple ABI-incompatible libraries, one needs to know
which library to load. OpenSSL helpfully provides us with that in the
SHLIB_VERSION_NUMBER macro:
$ grep -r SHLIB_VERSION_NUMBER /usr/include/openssl
/usr/include/openssl/opensslv.h:# define SHLIB_VERSION_NUMBER "1.1"
And that matches the file we need to load:
$ eu-readelf -d /usr/lib64/libssl.so | grep SONAME
SONAME Library soname: [libssl.so.1.1]
Given this need, the ask for shared_library class is to be able to specify
both pieces of information separately and let the implementation reconstruct
the actual file name according to OS details. Like in my QLibrary example, I
want to specify "ssl" plus the "1.1" string only.
I don't want to specify the ".so" part in the name, since this can be
different in different OSes. Notably, it IS different on macOS, which use
"dylib" instead of "so". Not only that, the version number is often placed as
an infix instead of a suffix:
$ ls -l /usr/lib/libssl*
-rwxr-xr-x 1 root wheel 392912 Jan 18 2018 /usr/lib/libssl.0.9.7.dylib
-rwxr-xr-x 1 root wheel 630144 Mai 29 16:36 /usr/lib/libssl.0.9.8.dylib
-rw-r--r-- 1 root wheel 947104 Mai 29 16:36 /usr/lib/libssl.35.dylib
-rw-r--r-- 1 root wheel 890800 Mai 29 16:36 /usr/lib/libssl.43.dylib
lrwxr-xr-x 1 root wheel 15 Mar 15 2018 /usr/lib/libssl.dylib -> libssl.
35.dylib
I also don't want to depend on the unversioned link. As seen in the ls output
above, it can be pointing to the wrong library. Moreover, on Linux systems,
the .so file is often not present unless the optional development headers are
too.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/11611238.EZ8KjN7Ls5%40tjmaciei-mobl1.
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/11611238.EZ8KjN7Ls5%40tjmaciei-mobl1.