__builtin_va_list issue with -ccc-host-triple x86_64-pc-win32-macho

I realized that va_list is not really part of the ABI and the compiler can implement it any way it wants, but it looks like in the x86_64-pc-win32-macho triple there is a mixture of the Unix 24 byte array of structure scheme and the Visual Studio 8 byte pointer to the frame scheme.

I’ve seen a failure using a va_list that looks a lot like the schemes were being mixed, but the code was so complicated it is hard to say for sure. I tried to generate a simple test case and it looked like the code gen for the va_list was following Visual Studio scheme of being a pointer to the frame, but the sizeof (__builtin_va_list) is still 24 bytes. Given this I think it is safe to assume that the x86_64-pc-win32-macho triple has a bug that is mixing va_list schemes. For our EFI usage case we don’t care which scheme is used, we just need the compiler to be self consistent. Xcode also shows the va_list as an array of a structure that is 24 bytes.

Test case:

v.c (762 Bytes)

v.x86_64-pc-win32-macho.s (4.39 KB)

v.s (6.53 KB)


It might be dubious in lib/Basic/Targets.cpp.

  case llvm::Triple::x86_64:
    switch (os) {
    case llvm::Triple::Win32: // This is what Triple.h supports now.
      if (Triple.getEnvironment() == llvm::Triple::MachO)
        return new DarwinX86_64TargetInfo(T);
        return new VisualStudioWindowsX86_64TargetInfo(T);



Thanks! That looks like the issue.

Unfortunately this fix broke some other code in the EFI emulator that was including Darwin system files and I need to work on that before I can fully test the change.