Closed Bug 1494384 Opened 6 years ago Closed 6 years ago

fix bindgen for aarch64 windows

Categories

(Core :: CSS Parsing and Computation, defect)

ARM64
Windows
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla64
Tracking Status
firefox64 --- fixed

People

(Reporter: froydnj, Assigned: froydnj)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

I'm seeing incredibly peculiar errors when running bindgen; clang complains thusly:

 0:54.65 c:/mozilla-central/WinSDKDir\include\10.0.17134.0\ucrt\corecrt_wstdio.h:483:9: error: too many arguments to function call, expected 2, have 5
 0:54.66 c:/mozilla-central/WinSDKDir\include\10.0.17134.0\ucrt\corecrt_wstdio.h:501:9: error: too many arguments to function call, expected 2, have 5
 0:54.68 c:/mozilla-central/WinSDKDir\include\10.0.17134.0\ucrt\corecrt_wstdio.h:520:9: error: too many arguments to function call, expected 2, have 5
 0:54.70 c:/mozilla-central/WinSDKDir\include\10.0.17134.0\ucrt\corecrt_wstdio.h:540:13: error: too many arguments to function call, expected 2, have 5
 0:54.71 c:/mozilla-central/WinSDKDir\include\10.0.17134.0\ucrt\corecrt_wstdio.h:561:9: error: too many arguments to function call, expected 2, have 5
 0:54.74 c:/mozilla-central/WinSDKDir\include\10.0.17134.0\ucrt\corecrt_wstdio.h:579:9: error: too many arguments to function call, expected 2, have 5
 0:54.79 c:/mozilla-central/WinSDKDir\include\10.0.17134.0\ucrt\corecrt_wstdio.h:597:9: error: too many arguments to function call, expected 2, have 5
 0:54.79 c:/mozilla-central/WinSDKDir\include\10.0.17134.0\ucrt\corecrt_wstdio.h:614:9: error: too many arguments to function call, expected 2, have 5
 0:54.80 c:/mozilla-central/WinSDKDir\include\10.0.17134.0\ucrt\corecrt_wstdio.h:632:9: error: too many arguments to function call, expected 2, have 5
 0:54.83 c:/mozilla-central/WinSDKDir\include\10.0.17134.0\ucrt\corecrt_wstdio.h:651:13: error: too many arguments to function call, expected 2, have 5
 0:54.90 c:/mozilla-central/WinSDKDir\include\10.0.17134.0\ucrt\corecrt_wstdio.h:671:9: error: too many arguments to function call, expected 2, have 5
 0:54.99 c:/mozilla-central/WinSDKDir\include\10.0.17134.0\ucrt\corecrt_wstdio.h:688:9: error: too many arguments to function call, expected 2, have 5
 0:55.08 c:/mozilla-central/WinSDKDir\include\10.0.17134.0\ucrt\corecrt_wstdio.h:845:9: error: too many arguments to function call, expected 2, have 5
 0:55.13 c:/mozilla-central/WinSDKDir\include\10.0.17134.0\ucrt\corecrt_wstdio.h:863:9: error: too many arguments to function call, expected 2, have 5
 0:55.15 c:/mozilla-central/WinSDKDir\include\10.0.17134.0\ucrt\corecrt_wstdio.h:882:9: error: too many arguments to function call, expected 2, have 5
 0:55.17 c:/mozilla-central/WinSDKDir\include\10.0.17134.0\ucrt\corecrt_wstdio.h:902:13: error: too many arguments to function call, expected 2, have 5
 0:55.19 c:/mozilla-central/WinSDKDir\include\10.0.17134.0\ucrt\corecrt_wstdio.h:922:9: error: too many arguments to function call, expected 2, have 5
 0:55.22 c:/mozilla-central/WinSDKDir\include\10.0.17134.0\ucrt\corecrt_wstdio.h:939:9: error: too many arguments to function call, expected 2, have 5
 0:55.26 c:/mozilla-central/WinSDKDir\include\10.0.17134.0\ucrt\corecrt_wstdio.h:957:9: error: too many arguments to function call, expected 2, have 5

The context here looks something like:

        int _Result;
        va_list _ArgList;
        __crt_va_start(_ArgList, _Locale); // ERROR
        _Result = _vfwprintf_l(_Stream, _Format, _Locale, _ArgList);
        __crt_va_end(_ArgList);
        return _Result;

I suspect this has something to do with x86-64/AArch64 confusion.  The vadefs.h file, which defines all these bits, has:

#elif defined _M_ARM64

    void __cdecl __va_start(va_list*, ...);

    #define __crt_va_start_a(ap,v) ((void)(__va_start(&ap, _ADDRESSOF(v), _SLOTSIZEOF(v), __alignof(v), _ADDRESSOF(v))))
    #define __crt_va_arg(ap, t)                                                 \
        ((sizeof(t) > (2 * sizeof(__int64)))                                   \
            ? **(t**)((ap += sizeof(__int64)) - sizeof(__int64))               \
            : *(t*)((ap += _SLOTSIZEOF(t) + _APALIGN(t,ap)) - _SLOTSIZEOF(t)))
    #define __crt_va_end(ap)       ((void)(ap = (va_list)0))


#elif defined _M_X64

    void __cdecl __va_start(va_list* , ...);

    #define __crt_va_start_a(ap, x) ((void)(__va_start(&ap, x)))
    #define __crt_va_arg(ap, t)                                               \
        ((sizeof(t) > sizeof(__int64) || (sizeof(t) & (sizeof(t) - 1)) != 0) \
            ? **(t**)((ap += sizeof(__int64)) - sizeof(__int64))             \
            :  *(t* )((ap += sizeof(__int64)) - sizeof(__int64)))
    #define __crt_va_end(ap)        ((void)(ap = (va_list)0))

#endif

    #define __crt_va_start(ap, x) __crt_va_start_a(ap, x)

So the AArch64 version of __va_start takes more arguments than the x86-64 one, and the error message references these argument counts.  clang has a specific check for AArch64 __va_start, too:

https://github.com/llvm-mirror/clang/blob/26346fbcb9bb9fe7a6374e84eb994e8743e65327/lib/Sema/SemaChecking.cpp#L5333-L5379

I am using a clang installation for bindgen which has support for AArch64 (I believe!).  I don't see anything obvious in bindgen or elsewhere in the tree that would confuse AArch64 for x86-64 in this instance; I have confirmed that the correct --target is being passed into bindgen.

I cannot get at the preprocessed source to see what's going on.  Emilio suggested inserting a call to builder.dump_preprocessed_input(), which I did, here:

https://searchfox.org/mozilla-central/rev/ffe6eaf2f032e58ec3b0650a87df2c62ae4ca441/servo/components/style/build_gecko.rs#276-279

but I cannot find any preprocessed files in the objdir after the build script has run (and errored out).

Any ideas on what to try next?
Flags: needinfo?(xidorn+moz)
Flags: needinfo?(emilio)
Oh, duh.  I was reading the arg counts incorrectly.

Filed https://bugs.llvm.org/show_bug.cgi?id=39090
Flags: needinfo?(xidorn+moz)
Flags: needinfo?(emilio)
We need this so we can get a libclang to use for AArch64 bindgen.
Attachment #9012308 - Flags: review?(dmajor)
Comment on attachment 9012308 [details] [diff] [review]
fix aarch64 __va_start checking in clang

r+ if it works.

I've been trying to keep loosen-msvc-detection.patch as the last entry to avoid blame noise from dangling commas. (That patch is probably the least likely ever to make it out of our local patch list.)
Attachment #9012308 - Flags: review?(dmajor) → review+
Pushed by nfroyd@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/95a1ec5402c0
fix aarch64 __va_start checking in clang; r=dmajor
https://hg.mozilla.org/mozilla-central/rev/95a1ec5402c0
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
Assignee: nobody → nfroyd
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: