This is an archive of the discontinued LLVM Phabricator instance.

[MinGW] Allow using ASan
ClosedPublic

Authored by mstorsjo on Sep 26 2018, 2:23 AM.

Details

Summary

Linking to ASan for MinGW is similar to MSVC, but MinGW always links the CRT dynamically, so there is only one of the MSVC cases to consider.

When linking to a shared compiler runtime library on MinGW, the suffix of the import library is .dll.a.

The existing case of .dll as suffix for windows in general doesn't seem correct (since this is used for linking). As long as callers never actually set the Shared flag, the default static suffix of .lib also worked fine for import libraries as well.

Diff Detail

Repository
rL LLVM

Event Timeline

mstorsjo created this revision.Sep 26 2018, 2:23 AM

Also, I notice that ubsan also is built for windows, but in the MSVC toolchain, only asan (and libfuzzer) can be enabled, not ubsan. Is there something else missing for ubsan, or what's the matter with that one?

Ping @rnk in case you have time to look at it despite CppCon

rnk added inline comments.Oct 1 2018, 1:22 PM
lib/Driver/ToolChain.cpp
370–373 ↗(On Diff #167085)

I think these conditionals have outgrown conditional expressions. Maybe just patch it upafterwards with a special case:

if (Shared && Triple.isWindowsGNUEnvironment())
  Suffix = ".dll.a";
lib/Driver/ToolChains/MinGW.cpp
234 ↗(On Diff #167085)

As in, shared msvcrt? Not shared mingw rt, right?

mstorsjo added inline comments.Oct 1 2018, 1:35 PM
lib/Driver/ToolChain.cpp
370–373 ↗(On Diff #167085)

Ok

lib/Driver/ToolChains/MinGW.cpp
234 ↗(On Diff #167085)

Right, yes - a shared msvcrt, but the mingw crt additions/wrappings/glue are statically linked into each module.

mstorsjo updated this revision to Diff 167817.Oct 1 2018, 1:37 PM

Clarified the comment about shared MSVCRT, moved handling of .dll.a into a separate condition afterwards.

rnk accepted this revision.Oct 1 2018, 1:47 PM

lgtm

This revision is now accepted and ready to land.Oct 1 2018, 1:47 PM
rnk added a comment.Oct 1 2018, 1:47 PM

Regarding ubsan, it probably works, I haven't tested it though.

In D52538#1251620, @rnk wrote:

Regarding ubsan, it probably works, I haven't tested it though.

Ok, thanks. I guess ubsan doesn't need quite as intricate integration with the platform as asan does anyway.

This revision was automatically updated to reflect the committed changes.