mozilla / cbindgen

A project for generating C bindings from Rust code
Mozilla Public License 2.0
2.43k stars 315 forks source link

Can't build Firefox with cbindgen-0.27.0 #990

Closed juippis closed 3 months ago

juippis commented 3 months ago

Hey,

I can't build any of the current Firefox versions with cbindgen-0.27.0. This includes:

When I downgrade cbindgen back to 0.26.0, all Firefox versions will compile just fine.

Unfortunately I'm not really sure how to debug the issue because the exact error isn't clear to me. But this seems most relevant

 0:20.01 thread 'main' panicked at src/bindgen/config.rs:1125:34:
 0:20.01 called `Result::unwrap()` on an `Err` value: "Couldn't parse config file: TOML parse error at line 363, column 1\n    |\n363 | \"Keyframe\" = \"Keyframe\"\n    | ^\nduplicate key `Keyframe` in table `export.rename`\n."

Full build.log for Firefox-129.0 is attached, other versions fail to the exact same issue. firefox-129.0:20240811-072056.log

emilio commented 3 months ago

Does removing this line work? https://searchfox.org/mozilla-central/rev/03258de701dbcde998cfb07f75dce2b7d8fdbe20/servo/ports/geckolib/cbindgen.toml#365

That config had a duplicate key which presumably started erroring once we updated serde or some such?

juippis commented 3 months ago

Dropping the following patch:

diff '--color=auto' -Naur a/servo/ports/geckolib/cbindgen.toml b/servo/ports/geckolib/cbindgen.toml
--- a/servo/ports/geckolib/cbindgen.toml        2024-08-11 11:53:35.056018648 +0300
+++ b/servo/ports/geckolib/cbindgen.toml        2024-08-11 11:54:39.610198332 +0300
@@ -360,7 +360,6 @@
 "Keyframe" = "Keyframe"
 "nsChangeHint" = "nsChangeHint"
 "ServoElementSnapshotTable" = "ServoElementSnapshotTable"
-"Keyframe" = "Keyframe"
 "ComputedKeyframeValues" = "ComputedKeyframeValues"
 "OriginFlags" = "OriginFlags"
 "ServoTraversalFlags" = "ServoTraversalFlags"

made the build crash in other way:

 0:21.91 ERROR: Parsing crate `style_traits`:`/var/tmp/portage/www-client/firefox-129.0/work/firefox-129.0/servo/components/style_traits/values.rs`:
 0:21.91 Error("expected identifier or integer")
 0:21.91 Try running `rustc -Z parse-only /var/tmp/portage/www-client/firefox-129.0/work/firefox-129.0/servo/components/style_traits/values.rs` to see a nicer error message
 0:21.92 ERROR: Couldn't generate bindings for /var/tmp/portage/www-client/firefox-129.0/work/firefox-129.0.

Full build.log attached. firefox-129.0:20240811-090042.log

emilio commented 3 months ago

I could repro, https://bugzilla.mozilla.org/show_bug.cgi?id=1912663 has a fix.

juippis commented 3 months ago

Thanks, can confirm it fixes build issues with cbindgen-0.27.0 on all current Ff releases! Would love to see a quick 128esr backport too if you can make it happen.