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

internal/bindings: Don't use raft directly #247

Merged
merged 1 commit into from
May 1, 2023

Conversation

cole-miller
Copy link
Contributor

Signed-off-by: Cole Miller cole.miller@canonical.com

Signed-off-by: Cole Miller <cole.miller@canonical.com>
@@ -1,6 +1,6 @@
package bindings

/*
#cgo linux LDFLAGS: -lraft -ldqlite -Wl,-z,now
#cgo linux LDFLAGS: -ldqlite -Wl,-z,now
Copy link
Contributor

Choose a reason for hiding this comment

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

Unrelated comment: why are we using the -Wl,-z,now flags?

They seem to have been introduced here #143, but I'm not sure to understand what compatibility situation they address.

Maybe @MathieuBordere can explain this better?

Copy link
Contributor

@MathieuBordere MathieuBordere May 1, 2023

Choose a reason for hiding this comment

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

It will lead to failing to load a dqlite library that contains unknown symbols.

For example, we extend dqlite's API with some new functionality, but otherwise don't break API/ABI compatibility.
Some user uses a new version of go-dqlite that uses the new dqlite functionality, but this version of go-dqlite is used on a system that runs a version of dqlite that doesn't support this API. Without -Wl, -z, now, this will lead to a runtime failure when a codepath hits an unknown symbol, while with the flags, go-dqlite will fail to load from the start.

Copy link
Contributor

Choose a reason for hiding this comment

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

Was this situation hit in real world?

I'd expect the common case is that at runtime go-dqlite will find the same dqlite version it found at build time, or alternatively a higher version. Not a lower version though.

I'm asking mainly since it's a bit unfortunate to require users to set the extra CGO_LDFLAGS_ALLOW environment variable, and to not have go get work without that.

If we could avoid that without any meaningful real-world harm, it'd be good.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, it's something I hit when testing at the time, and figured it could happen in real life too.

We could call dqlite_version_number when go-dqlite initializes to check for the minimal dqlite version instead of adding the linker flags, it would also serve a documentation purpose, because currently the minimal dqlite version is nowhere documented except in the (some) release notes.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll open a PR to get rid of -Wl, -z, now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, it's something I hit when testing at the time, and figured it could happen in real life too.

We could call dqlite_version_number when go-dqlite initializes to check for the minimal dqlite version instead of adding the linker flags, it would also serve a documentation purpose, because currently the minimal dqlite version is nowhere documented except in the (some) release notes.

That sounds like a good idea, thanks.

@cole-miller cole-miller marked this pull request as ready for review May 1, 2023 10:08
@MathieuBordere MathieuBordere self-requested a review May 1, 2023 12:20
@cole-miller cole-miller merged commit 1684459 into canonical:master May 1, 2023
33 checks passed
@cole-miller cole-miller mentioned this pull request May 2, 2023
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.

None yet

3 participants