This is an archive of the discontinued LLVM Phabricator instance.

[LLD][COFF] Add /inferasanlibs to lld-link as ignored flag
ClosedPublic

Authored by alvinhochun on Apr 23 2023, 9:16 AM.

Details

Summary

MSVC link.exe added this flag and MS STL started using this flag in
.drectve [1] when compiling with Clang with asan enabled, as reported
on https://github.com/llvm/llvm-project/issues/56300. This causes issues
with lld-link because it rejects any unknown flags in .drective sections.

As dc07867dc9991c982bd3441da19d6fcc16ea54d6 noted that, when using Clang
as the driver it explicitly passes the proper asan libraries. Therefore
it should be acceptable to ignore this flag in lld-link to at least
unbreak building with clang-cl and linking with lld-link.

[1]: https://github.com/microsoft/STL/blob/faaf094ee16bcbfb2c8d612fdb9334bcdef2fd0a/stl/inc/__msvc_sanitizer_annotate_container.hpp#L35

Diff Detail

Event Timeline

alvinhochun created this revision.Apr 23 2023, 9:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 23 2023, 9:16 AM
alvinhochun requested review of this revision.Apr 23 2023, 9:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 23 2023, 9:16 AM

I should note that although I did verify the new tests on Linux, I have not tested actually building things with this patch on Windows with the MSVC toolchain. It would be great if someone can test this end to end.

mstorsjo accepted this revision.Apr 23 2023, 1:37 PM

LGTM, this looks reasonable to me.

This revision is now accepted and ready to land.Apr 23 2023, 1:37 PM
hans accepted this revision.Apr 24 2023, 4:08 AM
hans added a subscriber: aeubanks.

lgtm

+aeubanks fyi