Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Fix builds on Rust 1.39 #80

Merged
merged 4 commits into from Dec 5, 2019
Merged

Fix builds on Rust 1.39 #80

merged 4 commits into from Dec 5, 2019

Conversation

danieldulaney
Copy link
Contributor

Closes #78 and obsoletes #79.

Daniel Dulaney added 4 commits November 30, 2019 01:14
The preivous bindgen version (0.32.0) fails on Rust 1.39 (see
rust-lang/rust-bindgen#1627), so an upgrade is
needed.

However, the new version also breaks when enum values are also defined as
macros. Previously, this could be handled with blacklist_type, but the
recommended method is by implementing will_parse_macro and returning
Ignore for problematic enum variants. This commit implements that method
and removes the old method.
- upgrade num_cpus from 1.0 to 1.11
- upgrade regex from 0.2 to 1.3
- replace 3 instances of try! with ? in build.rs
When rustfmt is missing, bindgen puts anything on one line. Any warnings then
dump so many logs that TravisCI is overwhelmed. The fix is to add rustfmt to the
environment.

See rust-lang/rust-bindgen#1600
In some cases, C comments end up looking like indented code blocks. rustdoc
thinks those are doctests and tries to run them. Bindgen is working on a
workaround, but in the meantime, the easiest solution is just disabling doctests
crate-wide.

See rust-lang/rust-bindgen#1313
@danieldulaney
Copy link
Contributor Author

danieldulaney commented Dec 1, 2019

Ok, that was an odyssey. In summary:

  • bindgen pre-0.51.1 is broken on Rust 1.39, so bindgen is upgraded to 0.51.1.
  • bindgen changed how they handle macros inside enums, so the macro blacklisting had to be changed.
  • bindgen also changed how they generate code -- they now dump everything onto one line, then run rustfmt on it. With rustfmt missing, that leaves everything on one line, which isn't a problem except that bindgen now generates u128s for C's long doubles, which cause warnings, which print out the entire file to stdout for each warning, which causes TravisCI to error out with too many logs. The easy fix: just add rustfmt to the build environment. Everything else will have to wait on bindgen.
  • bindgen also got smart(er) about sanitizing C comments, but not enough, because it still leaves indents alone, which get recognized as code blocks by rustdoc, which tries to run the comments as doctests, which obviously fail. The workaround is disabling doctests altogether until bindgen fixes this.
  • while we're here, update the other build deps to their latest versions and fix some build.rs warnings.

The only major tradeoff is disabling doctests crate-wide. Unfortunately, setting #[doc(test(ignore))] doesn't prevent rustdoc from attempting to compile them, which fails (because English isn't generally valid Rust). This is a big hammer, but it's all we have until bindgen or rustdoc get fixed. (Note: See rust-lang/rust#59867 for the issue progress)

However, it now all works. I can finally recommend merging this PR. I'm happy to bundle these up into a single commit if that's preferred.

@AndreaCatania
Copy link

Now it compile for me.

@meh meh merged commit ba724c3 into meh:master Dec 5, 2019
@meh
Copy link
Owner

meh commented Dec 5, 2019

Sounds good to me, I was fine with the git history. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't compile with Rust 1.39
3 participants