With GCC being a dead end and hard to use for universal binaries on OSX and Microsoft refusing to fix bugs in their compiler I thought it would good idea to get clang compiling our code base.
Before I start fixing bugs and missing features in clang I have created these patches to make it easier to debug and develop clang on Windows. After this is done what is needed is reimplementing <intrin.h> from Visual Studio 2010 includes and fixing any bugs that I find in the compiler. Finally I need lambda expressions which we already use heavily.
Fixes compiler warnings.
Complete support for msvc style diagnostics parsable by Visual Studio. Added column support for msvc locations. I also added indentation so you can easily see the grouping of errors, include stacks and notes (msvc mode only).
Visual Studio has no good way of getting stdout and stderr output into its Output Window. Getting these into the Output Window can be really helpful for debugging as you can go to diagnostics locations directly from there. It’s also helpful to actually see the compiler output while breaking into the code. To allow this I have added support for OutputDebugString in llvm raw_ostream. I then use this from the driver where you can redirect stdout and stderr to OutputDebugString with -output-diagnostics-as-debug-string option.
I have also added a shortcut when invoking cc1 so it doesn’t actually start a new process. This is because Visual Studio does not support automatically attaching to child processes, and doing -### every time you change a command line option and copying the results is cumbersome. It should also have the added benefit of speeding up compilation. I don’t know enough about clang to know if this is safe in all instances, and the way it’s implemented might not be optimal. Let me know if this could be done in a better way.
Make pragma message just output the message ignoring location (in msvc mode) and include stack information (always). This makes #pragma message usable in the same way when using clang as when using msvc and gcc.
Make use of multiple processors when compiling one project in msbuild/Visual Studio. This greatly decreases turnaround time when changing headers.
Fix Windows python issue where open temporary files cannot be opened again. Needed for clang-c++tests.
Add builtins needed to implement __debugbreak and _byteswap_ushort from intrin.h. Before implementing everything else needed for intrin.h I need to know if this is the correct way?
mm_malloc is implemented in Visual Studio 2010, this fixes the compile error resulting from it being a macro.
I have ran check-all on OSX and Visual Studio 2010 and made sure that there aren’t any regressions on these platforms. I would add tests for the OutputDebugString functionality, but capturing this probably needs extra support in the testing framework. Let me know what you think of these patches and I will start fixing more things if they are accepted.
clang-missing-builtins.patch (1.67 KB)
clang-msvc10-fix-mm_malloc-error.patch (452 Bytes)
clang-msvc10-fix-warnings.patch (1.8 KB)
clang-msvc-format-diagnostics.patch (9.23 KB)
clang-pragma-message.patch (19 KB)
clang-visual-studio-debuggability.patch (34.3 KB)
llvm-interrupt-builtin.patch (641 Bytes)
llvm-msvc10-fix-warnings.patch (1.61 KB)
llvm-msvc-format-diagnostics.patch (2.16 KB)
llvm-outputdebugstring-support.patch (5.26 KB)
llvm-temp-test-file-fail-on-win32.patch (861 Bytes)