[cfe-dev] Windows .exe from clang + COFF w/o gcc - success with issues

per at lumai.se per at lumai.se
Mon Aug 23 00:13:22 PDT 2010


Nice work!

Yes, _STDCALL_SUPPORTED is a temporary definition to get 
MSVC-header-base code to link until clang defines _MSC_VER _and_ handles 
the (nasty) consequences of that...

Right now there are a few parallell discussions about MSVC+clang. 
Perhaps some information could be centralized in a wiki page or such? A 
few topics as I see them:

* Compilation problems in the various SDK headers
* cl.exe command line wrapper/drop-in replacement ("llvm-cl"?)
* Supporting different MSVC versions using clang options
* Correct compiler predefines (without breaking compilation completely 
for the next 6 months...)

-- 
Per Lindén

Michael Spencer skrev 2010-08-20 21:21:
> 2010/8/17 Chris Lattner<clattner at apple.com>:
>> Thanks Per, I applied your two patches.    It would be nice if someone would compare the list of macros predefined by MSVC with the list of macros predefined by clang (when targeting windows).  Instead of trusting the MS docs, it would be good to find a way to get MSVC to dump its macro table.
>>
>> -Chris
>
> Using IDA I got the compiler to print out every macro it defines, I
> haven't gotten it to spit out the expansion, but that's easy to get
> without IDA.
>
> __FILE__
> __DATE__
> __TIME__
> __TIMESTAMP__
> __VA_ARGS__
> __FUNCTION__
> __FUNCDNAME__
> __FUNCSIG__
> __FSTREXP
> __LPREFIX
> __APREFIX
> __COUNTER__
> _MSC_EXTENSIONS
> _INTEGRAL_MAX_BITS
> _MSC_VER
> _MSC_FULL_VER
> _MSC_BUILD
> _WIN32
> _M_IX86
> _M_IX86_FP
> _MT
>
> Interestingly, _STDCALL_SUPPORTED is not in this list. I expected this
> due to the string not being in any of the binaries and it not
> expanding to anything using the compiler normally.
>
> MSVC has two separate binaries for c and c++, so I'll have to
> duplicate this in the c++ case, but it should be easy now that I know
> the global variable they use to pass identifiers around. (For anyone
> that wants to take a look. They are in c1.dll and the function is
> <.text:4F057EC0 ?InstallDefine@@YIXPAEHH_N at Z proc near>  and the
> variable is<.data:4F0B5800 ?pCurId@@3PAUId_t@@A dd>).
>
> ?pCurId@@3PAUId_t@@A is a pointer to a struct where the second dword
> is a pointer to the identifier string. You can use
> GetString(Dword(Dword(LocByName("?pCurId@@3PAUId_t@@A"))+4), -1,
> ASCSTR_C) while debugging a program in IDA to get the string.
>
> I'll collect all the defines for c and c++ with the various compiler
> options and put them all up someplace.
>
> - Michael Spencer




More information about the cfe-dev mailing list