-
Notifications
You must be signed in to change notification settings - Fork 694
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
No more syntex #940
No more syntex #940
Conversation
d5f4753
to
d130bf6
Compare
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, looks pretty reasonable. If I understand it well, we're running rustfmt
on the bindings now, and we need to have the latest rustfmt-nightly
installed locally to run tests so that they pass on CI.
Is that right? If so, I think we should document that.
src/codegen/helpers.rs
Outdated
pub fn link_name(name: &str) -> quote::Tokens { | ||
// This is ridiculous, but rustfmt doesn't seem to be formatting | ||
// `link_name` attributes very well, so we jump through these formatting | ||
// hoops to make it work. |
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.
Can you file an issue upstream and reference it 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.
I've filed a handful of bugs upstream, and they've all been fixed now, so this comment might actually be out of date. I'll double check.
.lit() | ||
.byte_str(string), | ||
) | ||
let b = quote::ByteStr(&string); |
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.
ooh, nice
Yes, it will be automatically installed by the I'll document it in |
☔ The latest upstream changes (presumably #926) made this pull request unmergeable. Please resolve the merge conflicts. |
re-r? @emilio |
Oops, just saw I need to rebase now. |
Ok, rebased. |
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.
Looks ok, but I don't feel like updating nightly / rustfmt on behalf of the user is right... :/
|
||
``` | ||
$ rustup update nightly | ||
$ rustup run nightly cargo install -f rustfmt-nightly |
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.
What happens when rustfmt
changes the default formatting? All our CI breaks until we update them? That seems not great :(
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.
Nope, because both the generated bindings and the expectations are run through rustfmt
before being compared.
tests/tests.rs
Outdated
// Because `rustfmt` needs to match its exact nightly version, we update | ||
// both at the same time. | ||
|
||
let status = process::Command::new("rustup") |
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 definitely feels wrong to update the nightly in behalf of the user.
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.
Unfortunately, this is the only way for the latest rustfmt
to work :-/
tests/tests.rs
Outdated
assert!(status.success(), "should run `rustup update nightly` OK"); | ||
|
||
let status = process::Command::new("rustup") | ||
.args(&["run", "nightly", "cargo", "install", "-f", "rustfmt-nightly"]) |
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.
Ditto...
(Of course this is just for contributors, but still) |
Oh, also @glyn reported when building on top of this branch that he got unexpected test expectation changes, so we should probably get that sorted out. |
@glyn, do you have the latest |
☔ The latest upstream changes (presumably #953) made this pull request unmergeable. Please resolve the merge conflicts. |
Aha! You need to use |
The `syntex` crate is unmaintained. It is slow to build, and additionally it requires that we pre-process `src/codegen/mod.rs` before we build the `bindgen` crate. The `quote` crate provides similar quasi-quoting functionality, is maintained, and builds faster. It doesn't have a typed API or builders, however; it only deals with tokens. Before this commit: ``` $ cargo clean; cargo build <snip> Finished dev [unoptimized + debuginfo] target(s) in 98.75 secs ``` After this commit: ``` $ cargo clean; cargo build <snip> Finished dev [unoptimized + debuginfo] target(s) in 46.26 secs ``` Build time is cut in half! But what about run time? Before this commit: ``` Generated Stylo bindings in: Duration { secs: 3, nanos: 521105668 } ``` After this commit: ``` Generated Stylo bindings in: Duration { secs: 3, nanos: 548797242 } ``` So it appears to be about 20ms slower at generating Stylo bindings, but I suspect this is well within the noise. Finally, this also lets us remove that nasty `mem::transmute` inside `bindgen::ir::BindgenContext::gen` that was used for the old `syntex` context. Now `BindgenContext` doesn't have a lifetime parameter either. This should make it easier to revisit doing our analyses in parallel with `rayon`, since that context was one of the things that made it hard for `BindgenContext` to implement `Sync`. Fixes rust-lang#925
Was previously printing seconds, but claiming it was milliseconds.
The latest `rustfmt` has fixed the formatting bugs we were running into.
@bors-servo r=emilio |
📌 Commit 46f74c1 has been approved by |
No more syntex There are a few commits in this PR, but the big one is the commit that goes `syntex` -> `quote` for code generation. I've included a copy of its commit message below. I tried to verify that it works with the stylo build still, but there were some issues, and then I checked with master, and that wasn't working either. So now I'm C-Reducing the failures on master and figured that this is at least ready for feedback in the meantime. r? @emilio ---------------------------- The `syntex` crate is unmaintained. It is slow to build, and additionally it requires that we pre-process `src/codegen/mod.rs` before we build the `bindgen` crate. The `quote` crate provides similar quasi-quoting functionality, is maintained, and builds faster. It doesn't have a typed API or builders, however; it only deals with tokens. Before this commit: ``` $ cargo clean; cargo build <snip> Finished dev [unoptimized + debuginfo] target(s) in 98.75 secs ``` After this commit: ``` $ cargo clean; cargo build <snip> Finished dev [unoptimized + debuginfo] target(s) in 46.26 secs ``` Build time is cut in half! But what about run time? Before this commit: ``` Generated Stylo bindings in: Duration { secs: 3, nanos: 521105668 } ``` After this commit: ``` Generated Stylo bindings in: Duration { secs: 3, nanos: 548797242 } ``` So it appears to be about 20ms slower at generating Stylo bindings, but I suspect this is well within the noise. Finally, this also lets us remove that nasty `mem::transmute` inside `bindgen::ir::BindgenContext::gen` that was used for the old `syntex` context. Now `BindgenContext` doesn't have a lifetime parameter either. This should make it easier to revisit doing our analyses in parallel with `rayon`, since that context was one of the things that made it hard for `BindgenContext` to implement `Sync`. Fixes #925
☀️ Test successful - status-travis |
@fitzgen |
There are a few commits in this PR, but the big one is the commit that goes
syntex
->quote
for code generation. I've included a copy of its commit message below.I tried to verify that it works with the stylo build still, but there were some issues, and then I checked with master, and that wasn't working either. So now I'm C-Reducing the failures on master and figured that this is at least ready for feedback in the meantime.
r? @emilio
The
syntex
crate is unmaintained. It is slow to build, and additionally it requires that we pre-processsrc/codegen/mod.rs
before we build thebindgen
crate.The
quote
crate provides similar quasi-quoting functionality, is maintained, and builds faster. It doesn't have a typed API or builders, however; it only deals with tokens.Before this commit:
After this commit:
Build time is cut in half! But what about run time?
Before this commit:
After this commit:
So it appears to be about 20ms slower at generating Stylo bindings, but I suspect this is well within the noise.
Finally, this also lets us remove that nasty
mem::transmute
insidebindgen::ir::BindgenContext::gen
that was used for the oldsyntex
context. NowBindgenContext
doesn't have a lifetime parameter either. This should make it easier to revisit doing our analyses in parallel withrayon
, since that context was one of the things that made it hard forBindgenContext
to implementSync
.Fixes #925