[cfe-dev] [PATCH] Windows improvements

Erik Olofsson Erik.Olofsson at hansoft.se
Sun Feb 27 20:15:51 PST 2011


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.

llvm-msvc10-fix-warnings.patch:
clang-msvc10-fix-warnings.patch:
Fixes compiler warnings.

llvm-msvc-format-diagnostics.patch:
clang-msvc-format-diagnostics.patch:
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).

llvm-outputdebugstring-support.patch:
clang-visual-studio-debuggability.patch:
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.

clang-pragma-message.patch:
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.

llvm-msvc-multi-processor-compilation.patch:
Make use of multiple processors when compiling one project in msbuild/Visual Studio. This greatly decreases turnaround time when changing headers.

llvm-temp-test-file-fail-on-win32.patch:
Fix Windows python issue where open temporary files cannot be opened again. Needed for clang-c++tests.

clang-missing-builtins.patch:
llvm-interrupt-builtin.patch:
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?

clang-msvc10-fix-mm_malloc-error.patch:
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.

Thanks,
Erik

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110228/4810e0b2/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang-missing-builtins.patch
Type: application/octet-stream
Size: 1710 bytes
Desc: clang-missing-builtins.patch
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110228/4810e0b2/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang-msvc10-fix-mm_malloc-error.patch
Type: application/octet-stream
Size: 452 bytes
Desc: clang-msvc10-fix-mm_malloc-error.patch
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110228/4810e0b2/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang-msvc10-fix-warnings.patch
Type: application/octet-stream
Size: 1839 bytes
Desc: clang-msvc10-fix-warnings.patch
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110228/4810e0b2/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang-msvc-format-diagnostics.patch
Type: application/octet-stream
Size: 9453 bytes
Desc: clang-msvc-format-diagnostics.patch
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110228/4810e0b2/attachment-0003.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang-pragma-message.patch
Type: application/octet-stream
Size: 19461 bytes
Desc: clang-pragma-message.patch
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110228/4810e0b2/attachment-0004.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang-visual-studio-debuggability.patch
Type: application/octet-stream
Size: 35137 bytes
Desc: clang-visual-studio-debuggability.patch
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110228/4810e0b2/attachment-0005.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: llvm-interrupt-builtin.patch
Type: application/octet-stream
Size: 641 bytes
Desc: llvm-interrupt-builtin.patch
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110228/4810e0b2/attachment-0006.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: llvm-msvc10-fix-warnings.patch
Type: application/octet-stream
Size: 1647 bytes
Desc: llvm-msvc10-fix-warnings.patch
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110228/4810e0b2/attachment-0007.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: llvm-msvc-format-diagnostics.patch
Type: application/octet-stream
Size: 2209 bytes
Desc: llvm-msvc-format-diagnostics.patch
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110228/4810e0b2/attachment-0008.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: llvm-msvc-multi-processor-compilation.patch
Type: application/octet-stream
Size: 2515 bytes
Desc: llvm-msvc-multi-processor-compilation.patch
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110228/4810e0b2/attachment-0009.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: llvm-outputdebugstring-support.patch
Type: application/octet-stream
Size: 5390 bytes
Desc: llvm-outputdebugstring-support.patch
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110228/4810e0b2/attachment-0010.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: llvm-temp-test-file-fail-on-win32.patch
Type: application/octet-stream
Size: 861 bytes
Desc: llvm-temp-test-file-fail-on-win32.patch
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110228/4810e0b2/attachment-0011.obj>


More information about the cfe-dev mailing list