-
-
Notifications
You must be signed in to change notification settings - Fork 775
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
Provide opt-out feature=from_source
to use serde_derive
source
#2580
Closed
Closed
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3cb80db
Add derive_compiled feature to force full compilation of derive
sagudev b12293e
Add cfg opt-in for the precompiled binary
pinkforest 8d54439
Remove redundant features
pinkforest 2e5bba0
Use opt-out instead and provide doc
pinkforest 10a0210
Add simplified gating via build.rs
pinkforest 81e79c1
Provide the opt-out gate without build.rs
pinkforest 6bccee7
Fix the manifest gate for opt-out - thanks @sagudev
pinkforest 5854820
Provide opt-out source compilation by feature `from_source
pinkforest 23059f7
Provide another opt-out alternative w/ nightly with cross-compile
pinkforest cb23de9
Switch back to opt-out `feature=from_source` override.
pinkforest File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@oli-obk Sadly with either
CARGO_ENCODED_RUSTFLAGS
or given these .cargo/config neither work 😭build.target
build.rustflags
Both set the options but it doesn't get seen at serde_derive procmacro level still
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.
To get rustflags into build script builds you need to use
-Zhost-config
andThere 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.
Oh we have a winner! Thanks @Nemo157 ❤️
When were these -Z introduced ? 🤔 so we can document it as required version if using this opt-out ?
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.
I think using an unstable option for the opt-out is wrong. Also it still has the same issue of getting overriden by other ways to specify rustflags rather than appending to it.
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.
Thanks for trying it out
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 fragile (or rather: easy to get wrong). Is there some solution to the resolver=2 problem?
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.
Good question need to build a test-case for it and prove it works I'll do that shortly.
EDIT: Yeah so I've replicated the resolver problem. Maybe we can just document this ?
This was the repro for it: https://github.com/pinkforest/serde_optout_unification_proof
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.
Alright with me. Is there something that can be done to ensure build dependencies also have the feature 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.
It seems I didn't clear the target properly between my repro previously
and it seems I can't replicate the problem with feature unification
e.g. I don't see anything wrong with the feature approach ?
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.
That's because it's a proc-macro crate, which is its own kind of dependency similar to a build-dependency, which is built for a single target: the host; so both the build-dep and normal-dep refer to the same proc-macro-dependency and their features get unified in it. A more accurate
cargo tree
would look likeEDIT: And by switching both dependencies to
serde = { features = ["derive"] }
instead of being direct you can see that there are two versions ofserde
built (because no(*)
), one for host one for target, that both link against the sameserde_derive
(because(*)
):