This is an archive of the discontinued LLVM Phabricator instance.

[CMake] Disable libc++ and libc++abi new/delete definitions when built with ASan
AbandonedPublic

Authored by phosek on Apr 3 2019, 3:41 PM.

Details

Reviewers
mcgrathr
EricWF
Summary

ASan provides its own operator new/delete to intercept all allocations
and deallocations. Currently, they rely on overriding weak symbols that
are already provided by libc++abi and libc++, but that solution is
fragile and breaks in certain scenarios, e.g. when libc++abi is
statically linked into a shared libc++.

Rather we should avoid providing new/delete operators when built with
ASan altogether and rely on new/delete operators provided by the
sanitizer runtime.

Diff Detail

Repository
rC Clang

Event Timeline

phosek created this revision.Apr 3 2019, 3:41 PM
mcgrathr accepted this revision.Apr 3 2019, 3:47 PM

IMHO the library code should use #if !__has_feature(...) to avoid the definitions entirely when built with a sanitizer whose runtime provides them.
But this is a fine way to achieve that while we wait for those libraries to be fixed for sanitized builds.

This revision is now accepted and ready to land.Apr 3 2019, 3:47 PM
phosek added a subscriber: ldionne.

IMHO the library code should use #if !__has_feature(...) to avoid the definitions entirely when built with a sanitizer whose runtime provides them.
But this is a fine way to achieve that while we wait for those libraries to be fixed for sanitized builds.

I agree, D60176 implements that but @ldionne thinks that we should go with the CMake option.

phosek abandoned this revision.May 1 2019, 6:29 PM

No longer needed, this was done as part of D60926.