[PATCH] D52386: [Lexer] Add udefined_behavior_sanitizer feature

Leonard Chan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 4 18:07:32 PDT 2018


leonardchan added a comment.

> This sounds like something that would be better handled in the build system rather than in source code. In particular, I think you don't actually want to detect "is this translation unit being compiled with ubsan enabled?", you instead want to detect "is the rest of musl libc being compiled with ubsan enabled?" -- you should not compile the stubs themselves with ubsan enabled, because ubsan might insert calls to its runtime at arbitrary places within that translation unit, which means you'll get infinite recursion when one of the ubsan callbacks ends up calling itself.

UBSan doesn't actually instrument these stubs though. We have them initially defined to be weakly linked and just call __builtin_trap(), which is be replaced when the UBSan runtime eventually gets linked when compiling something that uses this libc.

I also imagine it would be convenient for there to be some `__has_feature` to detect if any of the UBSan checks are being used.


Repository:
  rL LLVM

https://reviews.llvm.org/D52386





More information about the llvm-commits mailing list