-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow the user to build oqs-provider as a static library. #201
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution! Yes, having it be one DLL/SO was the intention (by default) -- I'm not sure whether this works seamlessly on all platforms, though. Let's see what CI says... Please also check out the two nits in separate comments.
I've fixed the CI (I forgot the GitHub Actions part). |
The latest discussion above on the use of the static/shared/module moniker had me review also your rationale for the PR:
Which OS are you referring-to? Wouldn't such OS feature completely disable the purpose of
for wanting to build But if this is the reason for this PR (?), the default behaviour of What about this proposal then: We'd add a specific build option, say "OQS_PROVIDER_BUILD_STATIC" that --when set-- changes "MODULE" to "STATIC" in oqs-provider/oqsprov/CMakeLists.txt Line 34 in 6b34839
|
I was referring to iOS on PAC-enabled devices (basically all the aarch64 mac and iPhones since the XS).
I totally agree with you on that point. Changing the default behavior is indeed not a good idea. So I implemented About the |
ACK. Makes sense. Pushed your PR to the OQS CI test realm to see that everything's OK (apart from the CI nit above). Thanks again for the addition. Please consider adding yourself to the Contributors section at the end of the README.md. |
Ok! I added two additional CI targets to test the (and added myself in the README.md in 9eaa075). |
Added a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a SKIP_TESTS parameter in the CircleCI configuration.
Since the two targets I added build oqs-provider statically, tests cannot be run.
Agreed, tests as-is cannot be run with a statically built oqsprovider
as they currently still rely on the dynamic-module-by-config load mechanism (OSSL_LIB_CTX_load_config
) to activate oqsprovider
. But I'd argue the above/the latest commits don't seem an ideal solution: That way the tests for the new configuration only check whether it can build but not whether oqsprovider
can run in this config.
A more complete solution (not requiring any changes to any CI logic, i.e., performing functional testing) seems to be possible by using the new config variable as a #define in the test cases to call OSSL_PROVIDER_add_builtin
and in the tests/CMakeLists.txt
to suitably link the (then static) lib in to deliver the required init symbol. The code for the legacy provider seems to utilize the define "STATIC_LEGACY" for exactly this purpose and could serve as an example how to do this...
@thb-sb When re-basing your PR, please be sure to update the new |
Thanks for the reminder! Done :)
You're totally right, that
This is a far more better idea! So I did it: in void load_oqs_provider(OSSL_LIB_CTX *libctx, const char *modulename, const char *configfile); Then, in function(targets_set_static_provider)
foreach(target ${ARGN})
target_compile_definitions(${target} PRIVATE "OQS_PROVIDER_STATIC")
target_link_libraries(${target} PRIVATE oqsprovider)
endforeach()
endfunction() This function is called if Finally, in Note that |
Thanks for these updates -- exactly as I'd hoped it should work.
With tongue-in-cheek, I'd say "Yes, let's hang them by the options" :), but more seriously, I'd rather suggest (best already in this PR) setting (and using) a fixed name "oqs_provider_init" if "OQS_PROVIDER_STATIC" is set exactly to avoid
|
Ok, and done in c2251e3! I also updated the file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What has been done to trigger all these (end-of-line) code changes? Problem is that in various places (e.g., oqsprov.c
) they clash with our code-generating logic (see e.g. this CI run: If anything gets changed between "OQS_TEMPLATE_FRAGMENT...START" and "...END" brackets, the corresponding changes (also) must be present in the corresponding generator code in oqs-template
(to survive a next code generation round, i.e., when integrating a new iteration of liboqs
). Please see the first step in https://github.com/open-quantum-safe/oqs-provider/wiki/Release-process. Thus, can I ask you to also update the template files with these end-of-line changes (eliminating spaces?), run python3 oqs-template/generate.py
and re-build/test? An update is anyway necessary to address the merge conflict introduced by your previous contribution... :) Thanks in advance.
@thb-sb Do you have time to complete the PR as per the above or shall I do this? I might have to do another PR though as I probably don't have |
Yes, I'll have time! I'm on vacation this week, but next week I'll finish this PR |
I'm back! The conflicting changes with the generated code were produced by my vim (I configured it so that it removes leading and trailing whitespaces on lines), so I used
I'll do that as soon as possible, in another PR! (edit: done in #215)
I rebased this commit on top of main. Now I'm waiting for the CI to be green ✅ |
This commit removes the trailing whitespaces from the `.fragment` files used for generating some pieces of code that end up in `oqsprov/oqsprov.c`. See #201 (review).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I now follow(ed) the logic to "load" the provider when statically linked -- but at least for oqs_test_endecode
there's something missing: We load the provider for two contexts in that test -- and the new function load_oqs_provider
does it only for one... so I'm afraid that initialization has to be done differently (or twice with different contexts).
I think I just missed the other |
Yes, that would allow |
Hum, I think
Perhaps we should add a I'm still working on it! |
ACK. Please let me know when Ready for Review. While you're at it, please consider adding a line to the RELEASE.md highlighting this new feature. |
Okay, so I tried to leave
From my understanding, I fell into the following case: oqs-provider/scripts/runtests.sh Lines 139 to 143 in 5250576
Thus I'm wondering if having this check in both CircleCI's What do you think @baentsch ? |
Well, Yes, I by now have no real trust in proper operation of OpenSSL 3.0.[0-8] (pertaining to providers :).
I'm afraid that's then necessary, indeed. But what irks me also is that the CI task (still) uses OpenSSL1.1.1 to build |
Okay, so I investigated this issue. To do so, I cloned In this CircleCI job, we see that CMake uses the OpenSSL 1.1.1 include directory to build
while OpenSSL 3.0.1 is used for
Thus, inside a sandbox, I compiled CTest output on oqs-provider
Then, I tried to compile Finally, I tested with several versions of OpenSSL 3.0:
For each version Consequently, I think that using the OpenSSL 1.1.1 headers to compile liboqs isn't an issue (yet?), however OpenSSL 3.0.1 definitely appears to be broken. I think we may fix that issue by upgrading the OpenSSL 3 version from homebrew:
I'll give it a shot.
Output of make on OpenSSL 3.0.2
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests with the external encodings library also cannot run as-is (in CI). See https://app.circleci.com/pipelines/github/open-quantum-safe/oqs-provider/710/workflows/e31c536a-beb9-4f93-ac9d-4cef35d2ec59/jobs/1589. Suggest to skip those in case of static build.
@bhess What's your take as to the need for testing of this library after IETF has rejected the encoding it implements? Should we keep it in CI? If not, the test failing in the trace above could simply be culled completely.
This commit removes the `SHARED` argument of the `add_library`. By doing so, we let the user choose the build type of library. By default, CMake will build a static library. Thus, [`BUILD_SHARED_LIBS`] must be used to switch to a shared library. `oqs-provider` as a static library allows us to use the provider without having to store its shared library somewhere. In addition, it happens that some operating systems prohibit the use of `dlopen`/`dlsym`. To load `oqs-provider` when it is embedded into a library of a binary, one can use the [`OSSL_PROVIDER_add_builtin`] API from OpenSSL 3. [`BUILD_SHARED_LIBS`]: https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html [`OSSL_PROVIDER_add_builtin`]: https://www.openssl.org/docs/man3.1/man3/OSSL_PROVIDER_add_builtin.html
It's done. Actually I did it for macOS but I forgot about linux... |
Thanks again for this contribution, @thb-sb! |
PR [#207] introduced a check for setting the right suffix to the library, depending on the target OS: https://github.com/open-quantum-safe/oqs-provider/blob/823f3178dd50eeb5febf29eb82680400c4d9e887/oqsprov/CMakeLists.txt#L61-L7://github.com/open-quantum-safe/oqs-provider/blob/823f3178dd50eeb5febf29eb82680400c4d9e887/oqsprov/CMakeLists.txt#L61-L79 However, mixed with PR [#201] and the `OQS_PROVIDER_BUILD_STATIC` option, the library may be suffixed with the wrong extension: we may end up with a static library named `oqsprovider.dylib`, even if it's an archive: ```shell $ cmake -GNinja \ -DOQS_PROVIDER_BUILD_STATIC=ON \ -B build $ cmake --build build $ file build/lib/oqsprovider.dylib build/lib/oqsprovider.dylib: current ar archive random library $ # ^ should be named `oqsprovider.a`! ``` The check mentioned above is only relevant when oqsprovider is built as a module. This commit fixes this bug and introduces a check in the CircleCI jobs to verify that `oqsprovider.a` is actually produced. [#201](#201) [#207](#207)
This commit removes the trailing whitespaces from the `.fragment` files used for generating some pieces of code that end up in `oqsprov/oqsprov.c`. See open-quantum-safe#201 (review). Signed-off-by: Felipe Ventura <[email protected]>
…um-safe#201) This commit removes the `SHARED` argument of the `add_library`. By doing so, we let the user choose the build type of library. By default, CMake will build a static library. Thus, [`BUILD_SHARED_LIBS`] must be used to switch to a shared library. `oqs-provider` as a static library allows us to use the provider without having to store its shared library somewhere. In addition, it happens that some operating systems prohibit the use of `dlopen`/`dlsym`. To load `oqs-provider` when it is embedded into a library of a binary, one can use the [`OSSL_PROVIDER_add_builtin`] API from OpenSSL 3. The `cmake` define `OQS_PROVIDER_BUILD_STATIC` is introduced to drive building this variant. [`BUILD_SHARED_LIBS`]: https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html [`OSSL_PROVIDER_add_builtin`]: https://www.openssl.org/docs/man3.1/man3/OSSL_PROVIDER_add_builtin.html Signed-off-by: Felipe Ventura <[email protected]>
…ies. (open-quantum-safe#220) open-quantum-safe#201 has been merged, but the `RELEASE.md` file has not been updated to reflect the new changes. Signed-off-by: Felipe Ventura <[email protected]>
PR [open-quantum-safe#207] introduced a check for setting the right suffix to the library, depending on the target OS: https://github.com/open-quantum-safe/oqs-provider/blob/823f3178dd50eeb5febf29eb82680400c4d9e887/oqsprov/CMakeLists.txt#L61-L7://github.com/open-quantum-safe/oqs-provider/blob/823f3178dd50eeb5febf29eb82680400c4d9e887/oqsprov/CMakeLists.txt#L61-L79 However, mixed with PR [open-quantum-safe#201] and the `OQS_PROVIDER_BUILD_STATIC` option, the library may be suffixed with the wrong extension: we may end up with a static library named `oqsprovider.dylib`, even if it's an archive: ```shell $ cmake -GNinja \ -DOQS_PROVIDER_BUILD_STATIC=ON \ -B build $ cmake --build build $ file build/lib/oqsprovider.dylib build/lib/oqsprovider.dylib: current ar archive random library $ # ^ should be named `oqsprovider.a`! ``` The check mentioned above is only relevant when oqsprovider is built as a module. This commit fixes this bug and introduces a check in the CircleCI jobs to verify that `oqsprovider.a` is actually produced. [open-quantum-safe#201](open-quantum-safe#201) [open-quantum-safe#207](open-quantum-safe#207) Signed-off-by: Felipe Ventura <[email protected]>
This commit removes the
SHARED
argument of theadd_library
. By doing so, we let the user choose the build type of library.By default, CMake will build a static library. Thus,
BUILD_SHARED_LIBS
must be used to switch to a shared library.oqs-provider
as a static library allows us to use the provider without having to store its shared library somewhere. In addition, it happens that some operating systems prohibit the use ofdlopen
/dlsym
.To load
oqs-provider
when it is embedded into a library of a binary, one can use theOSSL_PROVIDER_add_builtin
API from OpenSSL 3.