Bug 245542

Summary: devel/llvm10: cannot use ASan API
Product: Ports & Packages Reporter: Jan Beich <jbeich>
Component: Individual Port(s)Assignee: Brooks Davis <brooks>
Status: New ---    
Severity: Affects Only Me Keywords: needs-patch
Priority: --- Flags: bugzilla: maintainer-feedback? (brooks)
Version: Latest   
Hardware: Any   
OS: Any   

Description Jan Beich freebsd_committer 2020-04-11 20:52:02 UTC
$ echo "#include <sanitizer/asan_interface.h>" >a.c
$ cc -fsanitize=address -c a.c
$ clang10 -fsanitize=address -c a.c
a.c:1:10: fatal error: 'sanitizer/asan_interface.h' file not found
#include <sanitizer/asan_interface.h>
1 error generated.

Found via Firefox's --enable-address-sanitizer:

In file included from ipc/glue/BackgroundChildImpl.cpp:13:
In file included from objdir/dist/include/CamerasChild.h:20:
In file included from media/webrtc/trunk/webrtc/modules/video_capture/video_capture_defines.h:15:
In file included from media/webrtc/trunk/webrtc/modules/include/module_common_types.h:20:
In file included from media/webrtc/trunk/webrtc/api/optional.h:25:
In file included from media/webrtc/trunk/webrtc/rtc_base/sanitizer.h:32:
objdir/dist/system_wrappers/sanitizer/asan_interface.h:3:15: fatal error:
      'sanitizer/asan_interface.h' file not found
#include_next <sanitizer/asan_interface.h>
1 error generated.
Comment 1 Brooks Davis freebsd_committer 2020-04-13 17:14:03 UTC
We do install it so I think that means firefox isn't discovering the include directory correctly.  They should be using `llvm-config10 --includedir` rather than praying the llvm bits are in the include path.
Comment 2 Jan Beich freebsd_committer 2020-04-13 17:32:12 UTC
ASan is a Clang feature. Why llvm-config is required?

  $ CFLAGS=-fsanitize=address CC=clang10 CXX=clang++10 make clean all BATCH= -C/usr/ports/multimedia/aom
  In file included from common/ivfdec.c:19:
  aom_ports/sanitizer.h:32:10: fatal error: 'sanitizer/asan_interface.h' file not found
  #include <sanitizer/asan_interface.h>
  1 error generated.
Comment 3 Jan Beich freebsd_committer 2020-04-13 17:59:28 UTC
Passing -DCOMPILER_RT_INSTALL_PATH:STRING=lib/clang/${DISTVERSION} like PkgSrc should help. It'd be also consistent with FreeBSD base Clang.
Comment 4 commit-hook freebsd_committer 2020-07-28 18:52:35 UTC
A commit references this bug:

Author: brooks
Date: Tue Jul 28 18:52:13 UTC 2020
New revision: 543629
URL: https://svnweb.freebsd.org/changeset/ports/543629

  Upgrade to 10.0.1 release.

  Fix sanitizer runtime install location. [0]

  PR:		245542 [0]
  Reported by:	jbeich [0]
  Sponsored by:	DARPA