Skip to content
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

Linking with older versions of GPGME should use the -lgpgme-pthread library #24

Closed
mtrmac opened this issue Jan 18, 2020 · 2 comments
Closed

Comments

@mtrmac
Copy link
Contributor

mtrmac commented Jan 18, 2020

This is more or less a FYI, I can’t think of a good fix at the level of this package:

Before GPGME 1.8.0, the default library was not thread-safe; instead of locking data structures, there was basically only an assertion (sanity check) that there is no concurrent user of the data. The users had to explicitly opt in to a thread-safe library, by using the

gpgme-config --thread=pthread --libs --cflags

instead of

gpgme-config --libs --cflags

to get the right flags; in practice (at least on recent Fedora-based systems), this amounts to using -lgpgme-pthread instead of -lgpgme.

Given how Go encourages multi-threading, this should basically be done all the time, for the pre-1.8.0 versions.

Unfortunately, more recent versions of GPGME don’t provide the gpgme-pthread library, so we can’t just change the hard-coded library name, that would break everyone using recent versions.

All the discussions about possible fixes from #6 apply similarly here: a simple go build can’t do this automatically. We could, possibly, add a build tag to let the user have a choice (requiring the final top-level executable to know about that build tag), but it’s even worse than #6 in that for #6, a user that doesn’t need the new symbols can just always use the old-symbol version without any environment-dependent logic. In this case, the decision is based not on how the gpgme bindings are used, but on the surrounding environment, so every single top-level caller needs infrastructure to correctly choose the right binding.

Given that GPGME 1.8.0 is over 3 years old at this point, I’m not at all sure how much it is worth building any kind of infrastructure (build tags, detection scripts) for helping support this.

Thanks to Ulrich Obergfell uobergfe@redhat.com for diagnosing this.

@mtrmac
Copy link
Contributor Author

mtrmac commented Jan 18, 2020

Note to self: CGo does not work with build tags the usual way, one file per build tag choice (in that case the build tags are ignored and all LDFLAGS directives are concatenated, even from build-tag-deactivated .go files).

The way to do it is

// #cgo !proglottis_gpgme_pthread_library LDFLAGS: -lgpgme -lassuan -lgpg-error
// #cgo proglottis_gpgme_pthread_library LDFLAGS: -lgpgme-pthread -lassuan -lgpg-error

@mtrmac
Copy link
Contributor Author

mtrmac commented Jan 25, 2022

FWIW this is no longer a concern for us, RHEL 8 ships with GPGME 1.13 now.

@mtrmac mtrmac closed this as completed Jan 25, 2022
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

No branches or pull requests

1 participant