-
Notifications
You must be signed in to change notification settings - Fork 58
Depend on libsqlite3-sys for bundled builds
#190
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
Changes from 1 commit
9a6b47d
44a5038
afe9aed
37e73c9
7ef1021
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,11 @@ | |
| //! implement your own set of callbacks if you wish to make use of them (see the | ||
| //! [`proj`](https://crates.io/crates/proj) crate for an example). | ||
|
|
||
| #[cfg(bundled_build)] | ||
| extern crate libsqlite3_sys; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need these
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rustc only links crates that are explictly used somewhere, either by actually use items from that crate or by having an explicit |
||
| #[cfg(bundled_build)] | ||
| extern crate link_cplusplus; | ||
|
|
||
| #[cfg(not(feature = "nobuild"))] | ||
| include!(concat!(env!("OUT_DIR"), "/bindings.rs")); | ||
|
|
||
|
|
||
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.
Based on your description, I was expecting this to be an optional dependency. What am I misunderstanding?
Uh oh!
There was an error while loading. Please reload this page.
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.
It's unfortunately not possible to keep that as optional dependency as the build script can decide at runtime to build libproj from source. See here for more details.
(It's currently configured that way that it only links libsqlite3 if we build from source, that's why the
extern crate libsqlite3-sysline is behind acfgflag).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.
@michaelkirk Does this answer your question? Or would you like something to be changed here?
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.
Well ideally we wouldn't be compiling a thing that we don't need. I understand that it's complicated though.
Will
libsqlite3-sysbuild sqlite3 even if it's already been installed on the system (e.g. via a package manager)?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.
@michaelkirk Yes with the
bundledfeature flag enabledlibsqlite3-syswill always buildlibsqlite3from source and statically link it. They do not provide a option that performs runtime detection whether the crate is installed or not and that falls back to compiling if the crate is not found. That means with the current version we will always buildlibsqlite3from source, but we will only link that version if we also build libproj from source.That written: I had another idea how we could maybe solve that problem in a better way. We could not enable the
bundledfeature flag inproj-sysat all. We can then use theDEP_SQLITE3_*variables to check at runtime whether or not thelibsqlite3-syscrate build a libsqlite3 version from source by checking if these environment variables exist. That would allow users to control how libsqlite3 should be linked, as they then can control thebundledflag there on their own as feature flags are additive. If these variables are not set we would fall back to trying to get a system version of libsqlite3 for the build, which is the current behavior. If that sounds more acceptable I would change the PR to use that approach instead.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.
@weiznich Just so I'm clear: there's now no unneeded sqlite build unless the
bundledfeature is enabled?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.
Yes, I changed it that way that it only uses the statically build libsqlite3 version if the user specified somewhere else in their dependency tree that libsqlite3 should be bundled.
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.
So it still builds sqlite every time, but discards the static build if it's not needed?
Uh oh!
There was an error while loading. Please reload this page.
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.
No, it doesn't configure the bundled build for sqlite at all.
If we reach the stage where we build
libprojfrom source is just checks if someone else has configured thatlibsqlite3-sysshould build libsqlite3 from source and if that's the case it will use these build artifacts. That check is done by these twoDEP_*variables, which are set bylibsqlite3-sysfor the bundled build. For that to workproj-sysneeds to depend onlibsqlite3-sys(otherwise we won't see the variables), but that shouldn't be a problem as that only runs the build script of that crate, which by default will only handle that libsqlite3 is linked to the binary, not that it is build from source.So we likely do the following unnecessary steps of work now for proj-sys for the not bundled case:
build.rsfile)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.
Great, thanks for clarifying!