-
-
Notifications
You must be signed in to change notification settings - Fork 751
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
Static linking of OpenSSL when using sqlx
and sqlx-macros
#1337
Comments
All of the environment variables can be prefixed with the target architecture, so you can set |
Thank you! Preliminary testing suggests that I will be updating |
`sqlx` requires linking against OpenSSL twice: - `sqlx-macros` needs to link against OpenSSL as a shared libary for use at compile time. - `sqlx` needs to link against OpenSSL a static library for use at runtime. You can find the details here. launchbadge/sqlx#670 sfackler/rust-openssl#1337 We go with the fix proposed by sfackler, and add a test program that we can use to verify everything works correctly.
- `sqlx-macros` needs to link against OpenSSL as a shared libary for use at compile time. - `sqlx` needs to link against OpenSSL a static library for use at runtime. You can find the details here: launchbadge/sqlx#670 sfackler/rust-openssl#1337 We go with the fix proposed by @sfackler, and add a test program that we can use to verify everything works correctly. We remove a few `OPENSSL`-related variables that were added 4 years ago, and that no longer appear to be needed.
`sqlx` requires linking against OpenSSL twice: - `sqlx-macros` needs to link against OpenSSL as a shared libary for use at compile time. - `sqlx` needs to link against OpenSSL a static library for use at runtime. You can find the details here: launchbadge/sqlx#670 sfackler/rust-openssl#1337 We go with the fix proposed by @sfackler, and add a test program that we can use to verify everything works correctly. We remove a few `OPENSSL`-related variables that were added 4 years ago, and that no longer appear to be needed.
I have updated
This makes Thank you very much for your help figuring this out! |
@emk sorry for tagging you, but I came across this issue when trying to build static rust binary. May I ask whether you have an example of doing |
Thank you for maintaining the Rust OpenSSL crates!
I'm the maintainer of rust-musl-builder, a Docker image used for building static Rust binaries that include
openssl
anddiesel
. I'm currently working to add support for sqlx, and I've run into an interesting challenge: launchbadge/sqlx#670In a nutshell,
sqlx
includes ansqlx-macros
package that connects to the database at compile-time. It does this to validate prepared statements, supporting syntax checking of SQL, and type-checking of prepared statement arguments. But this means that it winds up linking againstopenssl-sys
twice:sqlx-macros
links againstopenssl-sys
and glibc at compile time. Rust insists that procedural macros are always shared libraries.sqlx
links againstopenssl-sys
and muslc-libc in the final binary, which is static.Unfortunately, this means that we need to keep track of two versions of OpenSSL: a shared glibc version for macros, and a static musl-libc version for the final binary. And
OPENSSL_STATIC
doesn't offer enough control overopenssl-sys
to make this work.I'm not sure what the ideal fix is here. I've proposed several solutions to the
sqlx
maintainers in launchbadge/sqlx#670, and I don't even know if a fix is possible at the level ofsqlx
. So I'm very much open to suggestions. If you do think that this problem is best fixed at theopenssl-sys
level, please let me know, and I'll try to figure out the details and prepare a PR.Once again, thank you for maintaining the
openssl
crate! It has brought a lot of value to Rust community.The text was updated successfully, but these errors were encountered: