Bug 245542 - devel/llvm10: cannot use ASan API
Summary: devel/llvm10: cannot use ASan API
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Brooks Davis
URL:
Keywords: needs-patch
Depends on:
Blocks:
 
Reported: 2020-04-11 20:52 UTC by Jan Beich
Modified: 2020-07-28 18:52 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (brooks)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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

Log:
  Upgrade to 10.0.1 release.

  Fix sanitizer runtime install location. [0]

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

Changes:
  head/devel/llvm10/Makefile
  head/devel/llvm10/distinfo
  head/devel/llvm10/files/compiler-rt/patch-.._compiler-rt-10.0.0.src_lib_sanitizer__common_sanitizer__platform__interceptors.h
  head/devel/llvm10/files/compiler-rt/patch-.._compiler-rt-10.0.1.src_lib_sanitizer__common_sanitizer__platform__interceptors.h
  head/devel/llvm10/pkg-plist