This is an archive of the discontinued LLVM Phabricator instance.

[libunwind] Define and use portable macro for checking for presence of ASAN
ClosedPublic

Authored by daniel-levin on Jun 11 2021, 11:32 PM.

Details

Reviewers
compnerd
Group Reviewers
Restricted Project
Commits
rGe03be2efe564: unwind: allow building with GCC
Summary
  • libunwind does not build with GCC due to a change introduced in adf1561d6ce8 which uses the clang-only __has_feature macro.
  • The problem is resolved by defining an "Is asan present?" macro that works across different compilers

Diff Detail

Event Timeline

daniel-levin created this revision.Jun 11 2021, 11:32 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 11 2021, 11:32 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
daniel-levin requested review of this revision.Jun 11 2021, 11:32 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 11 2021, 11:32 PM

Hi all :)

I am new to contributing to LLVM. This change fixes a broken build when bootstrapping with gcc. Both gcc and msvc define the SANITIZE_ADDRESS macro when using asan.

Please give me any and all feedback. I am happy to make changes.

compnerd requested changes to this revision.Jun 12 2021, 9:09 AM
compnerd added a subscriber: compnerd.
compnerd added inline comments.
libunwind/src/libunwind.cpp
25

I think that I would rather see this as:

#if !defined(__has_feature)
#define __has_feature(feature) 0
#endif

Then you can use # if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__) below.

That along with a comment would be sufficient. The GCC check would still be insufficient as it doesn't cover KASAN, but I don't believe that GCC supports that currently.

This revision now requires changes to proceed.Jun 12 2021, 9:09 AM

[libunwind] Use most appropriate macro for checking for presence of ASan.

Responded to comments from Saleem. Apologies for the noise in getting the diff correct. I had not used arc before.

compnerd accepted this revision.Jun 13 2021, 11:14 AM

LGTM; do you need someone to commit this on your behalf?

This revision is now accepted and ready to land.Jun 13 2021, 11:14 AM

Yes please. I do not have commit access. Thank you Saleem :)

This revision was landed with ongoing or failed builds.Jun 13 2021, 2:46 PM
This revision was automatically updated to reflect the committed changes.