New guy on the list trying to fix windows things

Hey guys, I'm new to the community and I just posted into the clang
channel on IRC, but I wanted to write to this list as well. My company
is having some issues with Clang on Windows, and instead of just bugging
you guys about it, they asked me to see what I could do. I was hoping I
could get someone to point me in the right direction though.

The issue I'm looking at has been previously reported here:
https://github.com/ishani/clang-msvc/issues/1
So far I've tracked it down to the following: The sizeof operator
doesn't like the fact that it is being asked the sizeof a static,
uninstantiated, template type. It looks like a while back sizeof was
fixed to allow this kind of operation
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2253.html),
which it looks like was implemented in clang 3.1. However the fact that
the line in atlstr.h uses a template seems to be breaking thing.

I'm going to start poking around, but I was hoping someone might have an
idea of where to point me. My intention is to fix the issue and submit
the patch back to llvm/clang

By the way, I think I have confirmed my suspicions that the problem is
what I think, because I changed atlstr.h to:
const ChTraits::XCHAR xhcarforsize = 'a';
if (memcmp(pMatch, pCharSet, nCharSetLen*sizeof(xcharforsize)) == 0)
...

and everything worked (That's not true, I just got past that issue and
to the next one)

I know that unfettered Windows support is a goal for you guys, hopefully
I can help.
Thanks,
JB

Hey guys, I'm new to the community and I just posted into the clang
channel on IRC, but I wanted to write to this list as well. My company
is having some issues with Clang on Windows, and instead of just bugging
you guys about it, they asked me to see what I could do. I was hoping I
could get someone to point me in the right direction though.

Sure! I'd just mention that Windows support in general in Clang and LLVM
is weak in some areas and strong in others. In particular, C++ ABI
compatibility with MSVC isn't there yet. We can't actually self-host Clang
with that ABI yet, but it should happen in the next month.

The issue I'm looking at has been previously reported here:
https://github.com/ishani/clang-msvc/issues/1

This looks like a git clone that hasn't been updated in almost a year.
There's been a lot of recent development in upstream Clang, so I'd try
that. We have pre-built Windows binaries here: http://llvm.org/builds/

So far I've tracked it down to the following: The sizeof operator
doesn't like the fact that it is being asked the sizeof a static,
uninstantiated, template type. It looks like a while back sizeof was
fixed to allow this kind of operation
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2253.html),
which it looks like was implemented in clang 3.1. However the fact that
the line in atlstr.h uses a template seems to be breaking thing.

This probably had something to do with our implementation of delayed
template parsing. Please report it at http://llvm.org/bugs if it still
reproduces. We haven't been testing ATL headers thoroughly enough, since
Clang and LLVM don't use them.

Thanks for your response. I understand that LLVM is working toward Windows support, which is why they want me to get more actively involved in trying to fix at least the problems that we have already. I’ll definitely file the ticket at llvm.org, but I was hoping you might be able to tell me where to look in source to figure out how to start fixing things.

Currently I’m poking around in the Sema directory, hoping to find something. That is at least where the error is being thrown, but it may not be where the bug is. The thing you mentioned about delayed template parsing sounds like it might be of particular interest. Can you point me to where that magic happens?

Thanks,
JB

Hi JB,

I unfortunately have no idea about all this. However, for other people to help you, it is normally extremely helpful if you can provide a reduced test case for which you can reproduce the problem with clang trunk (the latest version). In the optimal case you provide this test case (e.g. single C file) together with the command line options you have run clang trunk, the output you got and an explanation on how the output you got differs from what you expect.

(I know it is probably possible to guess your problem from the links you provided, but such guessing often is rather inaccurate and not everybody will even try to do so).

Cheers,
Tobias

That is a good suggestion, thank you. I should have done that yesterday, but zygoloid was actually able to help me figure some things out. As a result I have something that hopefully is even better, a bug report: http://llvm.org/bugs/show_bug.cgi?id=18443

This can be achieved with either the minimal code in the bug report, or if you are using Visual Studio, the way I originally discovered the bug was to simply include the file “#include <atltime.h>” and try to compile with no fancy options.

Zygoloid diagnosed for me that the “bug” actually stems from syntactically incorrect code, but because it is prevalent in MS headers and cl.exe supports it, I think (and he agreed) that it is something clang should consider supporting.

Thanks,
JB