This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] Allow sanitizers to be compiled for windows with clang
ClosedPublic

Authored by fjricci on Aug 31 2016, 10:49 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

fjricci updated this revision to Diff 69882.Aug 31 2016, 10:49 AM
fjricci retitled this revision from to [compiler-rt] Allow sanitizers to be compiled for windows with clang.
fjricci updated this object.
fjricci added reviewers: compnerd, beanz, timurrrr.
fjricci added a subscriber: llvm-commits.
timurrrr edited reviewers, added: rnk; removed: timurrrr.Aug 31 2016, 11:08 AM
timurrrr added a subscriber: rnk.
timurrrr edited subscribers, added: timurrrr; removed: rnk.

I don't actively work on ASan anymore.

Did you make sure all the ASan tests pass when the RTL is complied this way? I remember there was *some* reason why this wasn't enabled before. It is possible that the last time it was evaluated was a long time ago, when Clang/Win wasn't mature enough though.

rnk edited edge metadata.Aug 31 2016, 12:52 PM

This already works if you use clang-cl. Is this about making things work in a mingw environment?

While the current form works for clang-cl, this change is necessary if you want to use the gcc-compatible driver in clang when targeting windows.

rnk added inline comments.Aug 31 2016, 1:16 PM
cmake/config-ix.cmake
418 ↗(On Diff #69882)

I think what we really want to say here is "we support the MS CRT, not the mingw CRT". The check as written will enable building asan for mingw, and that would break their builds. I don't know how to ask that CRT question in cmake though...

I could add a check for AND NOT MINGW AND NOT CYGWIN

compnerd added inline comments.Sep 1 2016, 2:16 PM
cmake/config-ix.cmake
418 ↗(On Diff #69882)

The only way that I can see how to phrase that is to use the COMPILER_RT_TARGET and rip the environment from that. The gnu and cygnus environments are the one with their own CRT and msvc and itanium use the Microsoft CRT.

fjricci updated this revision to Diff 70581.Sep 7 2016, 12:13 PM
fjricci edited edge metadata.

Make sure to exclude mingw and cygwin

rnk accepted this revision.Sep 7 2016, 1:03 PM
rnk edited edge metadata.

Minor thing, otherwise let's do it.

lib/asan/CMakeLists.txt
217 ↗(On Diff #70581)

I think clang-cl identifies as clang and MSVC is true, so you want to do if (MSVC) first.

This revision is now accepted and ready to land.Sep 7 2016, 1:03 PM
This revision was automatically updated to reflect the committed changes.

Fixed the if/elseif order and committed.