This is an archive of the discontinued LLVM Phabricator instance.

[MinGW] Fix passing a sanitizer lib name as dependent lib
ClosedPublic

Authored by mstorsjo on Oct 8 2018, 9:43 AM.

Diff Detail

Repository
rC Clang

Event Timeline

mstorsjo created this revision.Oct 8 2018, 9:43 AM
smeenai added inline comments.Oct 8 2018, 2:29 PM
lib/Driver/ToolChains/MinGW.cpp
266 ↗(On Diff #168672)

Isn't Windows 7 our minimum supported Windows version anyway? I can't find the documentation pointing to that, but I thought that was the policy. In particular, we require VS 2015 or above, which doesn't support anything older than Server 2008 anyway (including Vista and XP), and I doubt we'd have anyone using Server 2008.

mstorsjo added inline comments.Oct 8 2018, 2:40 PM
lib/Driver/ToolChains/MinGW.cpp
266 ↗(On Diff #168672)

For llvm itself, yes, but this is for the runtimes. Or does the policy cover that as well?

Mingw upstream still(!) default to supporting xp onwards, while I'm configuring my own setups to default to vista. I guess making that 7 wouldn't be too much of an issue though.

FWIW, I included a corresponding change for ASAN here: https://reviews.llvm.org/rCRT343074, in adding a append_list_if(MINGW psapi ASAN_DYNAMIC_LIBS) in compiler-rt/trunk/lib/asan/CMakeLists.txt.

rnk added inline comments.Oct 8 2018, 2:47 PM
lib/Driver/ToolChains/MinGW.cpp
266 ↗(On Diff #168672)

I think most of our policies have to do with LLVM's own build requirements. Clang has supported targeting older OSs for a while, and we shouldn't intentionally break it, at least. We probably don't want to support running the sanitizers on old Windows OSs, since they tend to want to use modern OS APIs. For example, I used the slim reader writer lock APIs in ASan to fix a race.

In any case, do you think it would be nicer to put this directive in the ubsan object files that use psapi? It seems lame for clang to have to know about what libraries the sanitizers use.

smeenai added inline comments.Oct 8 2018, 3:04 PM
lib/Driver/ToolChains/MinGW.cpp
266 ↗(On Diff #168672)

Ah, I wasn't thinking of the LLVM/runtimes distinction. SRWLocks would require Vista and above though, and at that point just going for 7 and above would make sense.

This is a bit orthogonal to the patch though, so sorry for side-tracking things. +1 for Reid's suggestion of embedding the psapi directive in object files.

mstorsjo added inline comments.Oct 8 2018, 3:20 PM
lib/Driver/ToolChains/MinGW.cpp
266 ↗(On Diff #168672)

We probably don't want to support running the sanitizers on old Windows OSs, since they tend to want to use modern OS APIs. For example, I used the slim reader writer lock APIs in ASan to fix a race.

Yes, I've tried to keep things simple by requiring Vista in a number of other places as well, especially for SRWLocks and other threading related things. Since Vista is pretty much extinct, requiring 7 wouldn't be that big of a change though. I have no intention of trying to support sanitizers on anything older than that.

In any case, do you think it would be nicer to put this directive in the ubsan object files that use psapi? It seems lame for clang to have to know about what libraries the sanitizers use.

It would definitely be nicer - I'll have a shot at doing that.

mstorsjo updated this revision to Diff 168848.Oct 9 2018, 11:54 AM

Relying on a linker pragma in sanitizers and mingw lib name logic in lld.

mstorsjo retitled this revision from [MinGW] Allow using ubsan to [MinGW] Fix passing a sanitizer lib name as dependent lib.Oct 9 2018, 11:56 AM
mstorsjo edited the summary of this revision. (Show Details)
rnk accepted this revision.Oct 9 2018, 1:27 PM

lgtm

This revision is now accepted and ready to land.Oct 9 2018, 1:27 PM
This revision was automatically updated to reflect the committed changes.