Closed Bug 1519715 Opened 7 years ago Closed 7 years ago

"error: unexpected close delimiter: `]`" in baldrdash's binding.rs when building for x86 Android

Categories

(Core :: JavaScript: WebAssembly, defect)

defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: botond, Unassigned)

Details

I'm trying to build today's m-c for x86 Android, and getting the following error:

19:16.46 error: unexpected close delimiter: `]`
19:16.46    --> /home/botond/dev/projects/mozilla/out-of-tree-objdirs/central-android-x86/i686-linux-android/debug/build/baldrdash-ffff98d0f670c45d/out/bindings.rs:553:32
19:16.46     |
19:16.46 553 | #[derive(Copy, Clone)]; 2usize ] , }#[test]
19:16.46     |                                ^ unexpected close delimiter

The error persists after a clobber.

Benjamin, do you know what's going on here? Is this a bug in bindgen where it generates malformed Rust code?

Flags: needinfo?(bbouvier)

Hi, sorry I can't investigate as of now; will redirect to other Cranelift/build people, if they get a chance to look at this. Otherwise happy to give a look when I'm back (should be around Jan 24th).

That being said, if there's no errors on other platforms, my gut feelings would indeed lean to a bug in bindgen, but this claim bares no proofs.

Flags: needinfo?(sunfish)
Flags: needinfo?(nfroyd)

(In reply to Benjamin Bouvier [:bbouvier] (away until Jan 24th) from comment #2)

That being said, if there's no errors on other platforms, my gut feelings would indeed lean to a bug in bindgen, but this claim bares no proofs.

That seems like really bizarre Rust code to generate. I'm inclined to agree with bbouvier, though I'm curious why automation m-c builds aren't seeing this. What version of Rust/LLVM/clang are you using?

Flags: needinfo?(nfroyd) → needinfo?(botond)

This is a (very old and fixed long-ago) bug in rustfmt. See https://github.com/rust-lang/rust-bindgen/issues/1120.

I don't know which rustfmt version you have in your $PATH, but if it's not failing on the style system then the baldrslash script should probably do something like this:

https://searchfox.org/mozilla-central/rev/c43240cef5829b8a2dec118faff8a5e1fec6ae1b/servo/components/style/build_gecko.rs#146

Which allows you to disable it and such.

Can you confirm that a patch like:

diff --git a/js/src/wasm/cranelift/build.rs b/js/src/wasm/cranelift/build.rs
index c100aca39c04..d492d0711a0a 100644
--- a/js/src/wasm/cranelift/build.rs
+++ b/js/src/wasm/cranelift/build.rs
@@ -32,6 +32,7 @@ fn main() {
 
     let mut bindings = bindgen::builder()
         .disable_name_namespacing()
+        .rustfmt_bindings(false)
         // We whitelist the Baldr C functions and get the associated types for free.
         .whitelist_function("env_.*")
         .whitelist_function("global_.*")

Allows you to build?

Oh I guess the style system is not generating unions so it just works...

So my guess is that what's happening is:

  • You have a very old rustfmt in $PATH.
  • You have rustfmt installed via rustup for the default toolchain, but not for the android one, so when you build for desktop that one's picked and it works.
  • But when building for android there's no ~/.cargo/bin/rustfmt, and we use the other rustfmt, which causes the havoc.

Indeed, a while ago I had played around with rustfmt and had a locally patched version in ~/.cargo/bin.

rustup would tell me things like:

warning: tool rustfmt is already installed, remove it from /home/botond/.cargo/bin, then run rustup update to have rustup manage this tool.

but I didn't pay it much heed, not realizing that it could have side effects like breaking Firefox builds.

Emilio, thanks for the diagnosis! I'm going to close this as invalid.

Status: NEW → RESOLVED
Closed: 7 years ago
Flags: needinfo?(sunfish)
Flags: needinfo?(botond)
Flags: needinfo?(bbouvier)
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.