Skip to content
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

Compile error with mozjs_sys in macOS 10.12.6 #20971

Closed
CYBAI opened this issue Jun 6, 2018 · 17 comments
Closed

Compile error with mozjs_sys in macOS 10.12.6 #20971

CYBAI opened this issue Jun 6, 2018 · 17 comments
Labels

Comments

@CYBAI
Copy link
Collaborator

@CYBAI CYBAI commented Jun 6, 2018

Refer to #20958 (comment)

Let me share the first error log here

I always built failed on macOS 10.12.6 with latest master (a07c718) with ./mach build -d

error: incorrect close delimiter: `]`
     --> /Users/chengyou.bai/Documents/cybai/servo/target/debug/build/mozjs_sys-d4d4cc1e26ce451a/out/jsapi.rs:10722:43
      |
10722 |             # [ derive ( Copy ) ]; 1usize ] , _bindgen_union_align : u64 , }            # [ test ]
      |                                           ^
      |
note: unclosed delimiter
     --> /Users/chengyou.bai/Documents/cybai/servo/target/debug/build/mozjs_sys-d4d4cc1e26ce451a/out/jsapi.rs:10465:24
      |
10465 |         pub mod shadow {
      |                        ^

error: unexpected close delimiter: `}`
     --> /Users/chengyou.bai/Documents/cybai/servo/target/debug/build/mozjs_sys-d4d4cc1e26ce451a/out/jsapi.rs:11882:5
      |
11882 |     }
      |     ^

error: aborting due to 2 previous errors

The following warnings were emitted during compilation:

warning: In file included from src/jsglue.cpp:7:
warning: src/jsglue.hpp:86:16: warning: private field 'argv_' is not used [-Wunused-private-field]
warning:     JS::Value* argv_;
warning:                ^
warning: src/jsglue.hpp:87:14: warning: private field 'argc_' is not used [-Wunused-private-field]
warning:     unsigned argc_;
warning:              ^
warning: src/jsglue.hpp:88:10: warning: private field 'constructing_' is not used [-Wunused-private-field]
warning:     bool constructing_:1;
warning:          ^
warning: src/jsglue.hpp:89:10: warning: private field 'ignoresReturnValue_' is not used [-Wunused-private-field]
warning:     bool ignoresReturnValue_:1;
warning:          ^
warning: 4 warnings generated.

error: Could not compile `mozjs_sys`.
warning: build failed, waiting for other jobs to finish...
error: build failed
Build FAILED in 0:22:05

LLVM version

→ llvm-gcc -v
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

and in #20958 (comment), @asajeffrey asked me to try to build mozjs itself.

After cargo build the mozjs, I got same error logs

   Compiling mozjs_sys v0.51.1 (file:///Users/chengyou.bai/Documents/cybai/mozjs)
warning: In file included from src/jsglue.cpp:7:
warning: src/jsglue.hpp:86:16: warning: private field 'argv_' is not used [-Wunused-private-field]
warning:     JS::Value* argv_;
warning:                ^
warning: src/jsglue.hpp:87:14: warning: private field 'argc_' is not used [-Wunused-private-field]
warning:     unsigned argc_;
warning:              ^
warning: src/jsglue.hpp:88:10: warning: private field 'constructing_' is not used [-Wunused-private-field]
warning:     bool constructing_:1;
warning:          ^
warning: src/jsglue.hpp:89:10: warning: private field 'ignoresReturnValue_' is not used [-Wunused-private-field]
warning:     bool ignoresReturnValue_:1;
warning:          ^
warning: 4 warnings generated.
error: incorrect close delimiter: `]`
     --> /Users/chengyou.bai/Documents/cybai/mozjs/target/debug/build/mozjs_sys-c78b17b647610923/out/jsapi.rs:10722:43
      |
10722 |             # [ derive ( Copy ) ]; 1usize ] , _bindgen_union_align : u64 , }            # [ test ]
      |                                           ^
      |
note: unclosed delimiter
     --> /Users/chengyou.bai/Documents/cybai/mozjs/target/debug/build/mozjs_sys-c78b17b647610923/out/jsapi.rs:10465:24
      |
10465 |         pub mod shadow {
      |                        ^

error: unexpected close delimiter: `}`
     --> /Users/chengyou.bai/Documents/cybai/mozjs/target/debug/build/mozjs_sys-c78b17b647610923/out/jsapi.rs:11882:5
      |
11882 |     }
      |     ^

The following warnings were emitted during compilation:

warning: In file included from src/jsglue.cpp:7:
warning: src/jsglue.hpp:86:16: warning: private field 'argv_' is not used [-Wunused-private-field]
warning:     JS::Value* argv_;
warning:                ^
warning: src/jsglue.hpp:87:14: warning: private field 'argc_' is not used [-Wunused-private-field]
warning:     unsigned argc_;
warning:              ^
warning: src/jsglue.hpp:88:10: warning: private field 'constructing_' is not used [-Wunused-private-field]
warning:     bool constructing_:1;
warning:          ^
warning: src/jsglue.hpp:89:10: warning: private field 'ignoresReturnValue_' is not used [-Wunused-private-field]
warning:     bool ignoresReturnValue_:1;
warning:          ^
warning: 4 warnings generated.

error: Could not compile `mozjs_sys`.

To learn more, run the command again with --verbose.
@CYBAI
Copy link
Collaborator Author

@CYBAI CYBAI commented Jun 6, 2018

@asajeffrey Here's the gist which I built mozjs with cargo build -v

@asajeffrey
Copy link
Member

@asajeffrey asajeffrey commented Jun 6, 2018

@CYBAI hmm, that gist doesn't show jsapi.rs being generated. Can you remove jsapi.rs and re-run?

@CYBAI
Copy link
Collaborator Author

@CYBAI CYBAI commented Jun 6, 2018

@asajeffrey ohh, ok, let me remove it and re-run it.

@CYBAI
Copy link
Collaborator Author

@CYBAI CYBAI commented Jun 6, 2018

@asajeffrey Updated the gist but the log looks similar to previous version. 😭 Not sure if I miss anything?

@asajeffrey
Copy link
Member

@asajeffrey asajeffrey commented Jun 6, 2018

@emilio: this is odd, bindgen is producing a syntactically invalid .rs file, have you seen this before?

@asajeffrey
Copy link
Member

@asajeffrey asajeffrey commented Jun 6, 2018

@CYBAI can you give us a snippet of /Users/chengyou.bai/Documents/cybai/mozjs/target/debug/build/mozjs_sys-c78b17b647610923/out/jsapi.rs, say about 20 lines before and after line 10722?

@jdm jdm added P-mac A-build labels Jun 6, 2018
@jdm
Copy link
Member

@jdm jdm commented Jun 6, 2018

I'm building on macOS 10.12.6 without any problems, as a point of reference.

@CYBAI
Copy link
Collaborator Author

@CYBAI CYBAI commented Jun 6, 2018

@asajeffrey Here's line 10654 to line 10762 for the mozjs/target/debug/build/mozjs_sys-c78b17b647610923/out/jsapi.rs

# [ test ]
fn bindgen_test_layout_Function() {
    assert_eq!(::std::mem::size_of::<Function>(),
                64usize,
                concat!("Size of: ", stringify!(Function)));
    assert_eq!(::std::mem::align_of::<Function>(),
                8usize,
                concat!("Alignment of ", stringify!(Function)));
    assert_eq!(unsafe {
                    &(*(::std::ptr::null::<Function>())).base as *const _ as usize
                },
                0usize,
                concat!("Offset of field: ",
                        stringify!(Function),
                        "::",
                        stringify!(base)));
    assert_eq!(unsafe {
                    &(*(::std::ptr::null::<Function>())).nargs as *const _ as usize
                },
                32usize,
                concat!("Offset of field: ",
                        stringify!(Function),
                        "::",
                        stringify!(nargs)));
    assert_eq!(unsafe {
                    &(*(::std::ptr::null::<Function>())).flags as *const _ as usize
                },
                34usize,
                concat!("Offset of field: ",
                        stringify!(Function),
                        "::",
                        stringify!(flags)));
    assert_eq!(unsafe {
                    &(*(::std::ptr::null::<Function>())).native as *const _ as usize
                },
                40usize,
                concat!("Offset of field: ",
                        stringify!(Function),
                        "::",
                        stringify!(native)));
    assert_eq!(unsafe {
                    &(*(::std::ptr::null::<Function>())).jitinfo as *const _ as usize
                },
                48usize,
                concat!("Offset of field: ",
                        stringify!(Function),
                        "::",
                        stringify!(jitinfo)));
    assert_eq!(unsafe { &(*(::std::ptr::null::<Function>()))._1 as *const _ as usize },
                56usize,
                concat!("Offset of field: ",
                        stringify!(Function),
                        "::",
                        stringify!(_1)));
}
impl Clone for Function {
    fn clone(&self) -> Self {
        *self
    }
}
# [ repr ( C ) ]
# [ derive ( Copy ) ]
pub struct String {
    pub flags: u32,
    pub length: u32,
    pub __bindgen_anon_1: root::js::shadow::String__bindgen_ty_1,
}
# [ repr ( C ) ]
# [ derive ( Copy ) ]; 1usize ] , _bindgen_union_align : u64 , }            # [ test ]
fn bindgen_test_layout_String__bindgen_ty_1() {
    assert_eq!(::std::mem::size_of::<String__bindgen_ty_1>(),
                8usize,
                concat!("Size of: ", stringify!(String__bindgen_ty_1)));
    assert_eq!(::std::mem::align_of::<String__bindgen_ty_1>(),
                8usize,
                concat!("Alignment of ", stringify!(String__bindgen_ty_1)));
    assert_eq!(unsafe {
                    & ( * ( :: std :: ptr :: null :: < String__bindgen_ty_1 > ( ) ) ) . nonInlineCharsLatin1 as * const _ as usize
                },
                0usize,
                concat!("Offset of field: ",
                        stringify!(String__bindgen_ty_1),
                        "::",
                        stringify!(nonInlineCharsLatin1)));
    assert_eq!(unsafe {
                    & ( * ( :: std :: ptr :: null :: < String__bindgen_ty_1 > ( ) ) ) . nonInlineCharsTwoByte as * const _ as usize
                },
                0usize,
                concat!("Offset of field: ",
                        stringify!(String__bindgen_ty_1),
                        "::",
                        stringify!(nonInlineCharsTwoByte)));
    assert_eq!(unsafe {
                    & ( * ( :: std :: ptr :: null :: < String__bindgen_ty_1 > ( ) ) ) . inlineStorageLatin1 as * const _ as usize
                },
                0usize,
                concat!("Offset of field: ",
                        stringify!(String__bindgen_ty_1),
                        "::",
                        stringify!(inlineStorageLatin1)));
    assert_eq!(unsafe {
                    & ( * ( :: std :: ptr :: null :: < String__bindgen_ty_1 > ( ) ) ) . inlineStorageTwoByte as * const _ as usize
                },
                0usize,
                concat!("Offset of field: ",
                        stringify!(String__bindgen_ty_1),
                        "::",
                        stringify!(inlineStorageTwoByte)));
}
@asajeffrey
Copy link
Member

@asajeffrey asajeffrey commented Jun 6, 2018

The matching snippet from my jsapi,rs is:

...
# [ repr ( C ) ]
# [ derive ( Copy ) ]
pub struct String {
    pub flags : u32 ,
    pub length : u32 ,
    pub __bindgen_anon_1 : root::js::shadow::String__bindgen_ty_1 ,
}
# [ repr ( C ) ]
# [ derive ( Copy ) ]
pub union String__bindgen_ty_1 {
    pub nonInlineCharsLatin1 : * const root::JS::Latin1Char ,
    pub nonInlineCharsTwoByte : * const u16 ,
    pub inlineStorageLatin1 : [ root::JS::Latin1Char ; 1usize ] ,
    pub inlineStorageTwoByte : [ u16 ; 1usize ] ,
    _bindgen_union_align : u64 ,
}
# [ test ]
fn bindgen_test_layout_String__bindgen_ty_1 ( ) {
...

For some reason, most of String__bindgen_ty_1 isn't being emitted.

@KiChjang
Copy link
Member

@KiChjang KiChjang commented Jun 6, 2018

I'm also building servo fine on my MacOS 10.12.6.

@SughiY
Copy link

@SughiY SughiY commented Jul 15, 2018

Hello,
I fell into the same situation. And I think this should be an issue introduced by rustfmt according to rust-lang-nursery/rust-bindgen#1045 and RustAudio/coreaudio-sys#7. I have tried the solution in rust-lang-nursery/rust-bindgen#1045 by disabling the rust_fmt and it works well. I wonder why we had this error as the default compiler is already the nightly version.

@CYBAI
Copy link
Collaborator Author

@CYBAI CYBAI commented Jul 28, 2018

Yes, as @SughiY mentioned.

I can solve the issue by doing following commands

$ cargo uninstall rustfmt
$ rustup component add rustfmt-preview
@asajeffrey
Copy link
Member

@asajeffrey asajeffrey commented Jul 28, 2018

Yes, that's a rustfmt version problem. According to fitzgen, there's a line we can add to the rustfmt config file giving the minimum version. This won't fix the problem, but at least the error message will be understandable.

@gaurikholkar
Copy link

@gaurikholkar gaurikholkar commented Aug 20, 2018

Any updates on the same? I am running rustfmt 0.8.2-nightly (5e599251 2018-07-02), rustc 1.29.0-nightly (1ecf6929d 2018-07-16) and it is giving me the same error.

@jdm
Copy link
Member

@jdm jdm commented Aug 20, 2018

@gaurikholkar
Copy link

@gaurikholkar gaurikholkar commented Aug 21, 2018

Yes @jdm but it's still giving me an error

@CYBAI
Copy link
Collaborator Author

@CYBAI CYBAI commented Apr 11, 2020

I think this is no longer an issue.

@CYBAI CYBAI closed this Apr 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.