This is an archive of the discontinued LLVM Phabricator instance.

[MSVC] Workaround missing search path for sanitizer headers.
ClosedPublic

Authored by pgousseau on Jan 31 2022, 9:08 AM.

Details

Summary

This is to fix build errors “Cannot open include file: 'sanitizer/asan_interface.h'” when building LLVM with MSVC and LLVM_USE_SANITIZER=Address.

asan_interface.h is not available in MSVC's search path, instead it is located under %VCToolsInstallDir%/crt/src/sanitizer

This is an alternate solution to https://reviews.llvm.org/D118159 , to avoid adding all internal crt sources to the header search paths.

Tested with visual studio 2019 v16.9.6

Diff Detail

Event Timeline

pgousseau created this revision.Jan 31 2022, 9:08 AM
pgousseau requested review of this revision.Jan 31 2022, 9:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 31 2022, 9:08 AM
aaron.ballman added inline comments.Jan 31 2022, 10:33 AM
llvm/include/llvm/Support/Compiler.h
451–453

I think this should be hoisted up closer to line 40 after the __has_builtin definition.

pgousseau updated this revision to Diff 404846.Feb 1 2022, 2:07 AM

Hoist up __has_include ifdef guard as per comment.

pgousseau marked an inline comment as done.Feb 1 2022, 4:03 AM
pgousseau added inline comments.
llvm/include/llvm/Support/Compiler.h
451–453

Thank you! Yes makes sense. Patch updated.

rnk added inline comments.Feb 1 2022, 9:18 AM
llvm/include/llvm/Support/Compiler.h
453–465

Please add a comment in this #else block that these declarations exist to support ASan with MSVC. If MSVC eventually ships asan_interface.h in their headers, we can remove this.

pgousseau updated this revision to Diff 405002.Feb 1 2022, 10:46 AM
pgousseau marked an inline comment as done.

Add comment as suggested.

rnk accepted this revision.Feb 1 2022, 10:50 AM

lgtm

This revision is now accepted and ready to land.Feb 1 2022, 10:50 AM
This revision was landed with ongoing or failed builds.Feb 2 2022, 3:00 AM
This revision was automatically updated to reflect the committed changes.