Skip to content

Find-SASL cleanup #1405

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

Merged
merged 15 commits into from
Sep 18, 2023
Merged

Find-SASL cleanup #1405

merged 15 commits into from
Sep 18, 2023

Conversation

vector-of-bool
Copy link
Contributor

@vector-of-bool vector-of-bool commented Sep 14, 2023

This is the first of several smaller changes that will go together into a full refactoring of the libmongoc build. This piece targets the SASL support library, with a few aside fixes.

Changed

  • The FindSASL2.cmake module, despite having the Find name prefix, did not behave as a proper find-module. This refactoring changes the module to behave as a find-module and generates an IMPORTED library target against which libmongoc can link. This also resulted in changes to the installed mongoc targets to support the downstream users to link against a libsasl2. Whereas the prior install hard-coded the path to sasl2 within the -targets.cmake file, this change adds a level of indirection _mongoc::detail::sasl that is resolved at import-time to the SASL implementation that is available and that matches what the targets were built against.

  • The code that decided which SASL to use was tangled, but the actual decision process is not complex. This refactors that process to a more straightforward implementation.

  • Additional Earthly targets and tasks have been defined to test the SASL on/off configurations.

  • Aside: Use the FeatureSummary module from CMake to print a definitive summary of enabled/disabled features and found/missing packages at the end of the configure process.

  • Aside: A test-cxx-driver target in Earthly, which will perform a simple build of the C++ driver using the built result of the C driver. This does not have any EVG tasks, it's just for local testing (for now).

Tweak importing of libsasl2 for user requirements

Tweaks the import of libsasl2 so that at import-time we don't
*require* the pkg-config files, since the dynamic library's dep
on libsasl should be sufficient to satisfy the runtime linking.
Build +test-cxx-driver to run a default mongo-cxx-driver using the
local mongo-c-driver as the driver backend.
@vector-of-bool vector-of-bool marked this pull request as ready for review September 14, 2023 17:59
Copy link
Contributor

@kkloberdanz kkloberdanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Minor comment.

@@ -282,6 +282,10 @@ function(_generate_pkg_config_content out)
$<GENEX_EVAL:$<TARGET_PROPERTY:pkg_config_LIBS>>
$<REMOVE_DUPLICATES:$<TARGET_PROPERTY:INTERFACE_LINK_OPTIONS>>
)

# XXX: Could we define a genex that can transform the INTERFACE_LINK_LIBRARIES to a list of
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the XXX: intended to be here, or is it a placeholder?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a callout to future readers that may know better than I do, since the current way its handled is sub-optimal but not "broken" to warrant a "TODO" or "FIXME".

Copy link
Collaborator

@kevinAlbs kevinAlbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM, though one task failure may need to be investigated:

The MinGW task appears to fail to locate libsasl2:

[2023/09/15 21:08:31.592] CMake Error at C:/Users/mci-exec/AppData/Local/mongo-c-driver/tmp.pTUuQRMADo/cmake-3.25.2-windows-x86_64/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
[2023/09/15 21:08:31.593]   Could NOT find SASL2 (missing: SASL2_VERSION SASL2_INCLUDE_DIR
[2023/09/15 21:08:31.593]   SASL2_LIBRARY) (Required is at least version "2.0")

Earthfile Outdated
alpine-test-env-base:
ARG --required version
FROM +alpine-base --version=$version
RUN apk add libsasl snappy pkgconfig
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
RUN apk add libsasl snappy pkgconfig
RUN apk add libsasl snappy

Remove package config dependency? I assume this is no longer needed due to 0c76946. Comment applies to other package config dependencies in this file: pkgconf and pkg-config

@@ -47,9 +49,17 @@ def __init__(self, *, suffix: str, target: str) -> None:
"amazon2",
]

# Other optoins: SSPI (Windows only), AUTO (not reliably test-able without more environments)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Other optoins: SSPI (Windows only), AUTO (not reliably test-able without more environments)
# Other options: SSPI (Windows only), AUTO (not reliably test-able without more environments)

@vector-of-bool vector-of-bool merged commit 75734b3 into mongodb:master Sep 18, 2023
vector-of-bool added a commit to vector-of-bool/mongo-c-driver that referenced this pull request Nov 3, 2023
* Redefine the handling of SASL imports

Tweak importing of libsasl2 for user requirements

Tweaks the import of libsasl2 so that at import-time we don't
*require* the pkg-config files, since the dynamic library's dep
on libsasl should be sufficient to satisfy the runtime linking.

* Add FeatureSummary
* Bump Earthly version, allow setting sasl options
* Include dependencies for finding libsasl2
* Define more Earthly tasks
* make _mongo_pick public, tweak signature of bool01
* Add Earthly target for testing against cxx-driver

Build +test-cxx-driver to run a default mongo-cxx-driver using the
local mongo-c-driver as the driver backend.

* Better Earthly target docs
* Fix SASL path finding for Windows, and use parallel Make
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants