Connect libclang_rt to the build, for specific architectures. This

contains the libraries for Address Sanitizer (asan), Undefined Behavior
Sanitizer (ubsan) and Profile Guided Optimization.

ASan is a fast memory error detector. It can detect the following types
of bugs:

    Out-of-bounds accesses to heap, stack and globals
    Use-after-free
    Use-after-return (to some extent)
    Double-free, invalid free
    Memory leaks (experimental)

Typical slowdown introduced by AddressSanitizer is 2x.

UBSan is a fast and compatible undefined behavior checker. It enables a
number of undefined behavior checks that have small runtime cost and no
impact on address space layout or ABI.

PLEASE NOTE: the sanitizers still have some rough edges on FreeBSD,
particularly on i386.  These will hopefully be smoothed out in the
coming time.

Differential Revision: https://reviews.freebsd.org/D1505
This commit is contained in:
Dimitry Andric 2015-01-13 19:54:47 +00:00
parent 6b30e6ae6c
commit 8028b78dbf
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=277146
5 changed files with 57 additions and 6 deletions

View File

@ -24,6 +24,14 @@
games games
.. ..
lib lib
clang
3.5.0
lib
freebsd
..
..
..
..
engines engines
.. ..
i18n i18n

View File

@ -14,6 +14,14 @@
lib lib
aout aout
.. ..
clang
3.5.0
lib
freebsd
..
..
..
..
compat compat
aout aout
.. ..

View File

@ -13,6 +13,7 @@ SUBDIR_ORDERED= ${_csu} \
libc \ libc \
libc_nonshared \ libc_nonshared \
libcompiler_rt \ libcompiler_rt \
${_libclang_rt} \
${_libcplusplus} \ ${_libcplusplus} \
${_libcxxrt} \ ${_libcxxrt} \
libelf \ libelf \
@ -211,6 +212,15 @@ _libcom_err= libcom_err
_libldns= libldns _libldns= libldns
.endif .endif
# The libraries under libclang_rt can only be built by clang, and only make
# sense to build when clang is enabled at all. Furthermore, they can only be
# built for certain architectures.
.if ${MK_CLANG} != "no" && ${COMPILER_TYPE} == "clang" && \
(${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" || \
(${MACHINE_CPUARCH} == "arm" && ${MACHINE_ARCH} != "armeb"))
_libclang_rt= libclang_rt
.endif
.if ${MK_LIBCPLUSPLUS} != "no" .if ${MK_LIBCPLUSPLUS} != "no"
_libcxxrt= libcxxrt _libcxxrt= libcxxrt
_libcplusplus= libc++ _libcplusplus= libc++

View File

@ -1,10 +1,18 @@
# $FreeBSD$ # $FreeBSD$
SUBDIR= asan\ .include <src.opts.mk>
asan_cxx\
profile\ .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
san\ SUBDIR+= asan\
ubsan\ asan_cxx\
ubsan_cxx san\
ubsan\
ubsan_cxx
.endif
.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" || \
(${MACHINE_CPUARCH} == "arm" && ${MACHINE_ARCH} != "armeb")
SUBDIR+= profile
.endif
.include <bsd.subdir.mk> .include <bsd.subdir.mk>

View File

@ -527,6 +527,23 @@ OLD_FILES+=usr/include/clang/3.5.0/xmmintrin.h
OLD_FILES+=usr/include/clang/3.5.0/xopintrin.h OLD_FILES+=usr/include/clang/3.5.0/xopintrin.h
OLD_DIRS+=usr/include/clang/3.5.0 OLD_DIRS+=usr/include/clang/3.5.0
OLD_DIRS+=usr/include/clang OLD_DIRS+=usr/include/clang
OLD_FILES+=usr/lib/clang/3.5.0/lib/freebsd/libclang_rt.asan-i386.a
OLD_FILES+=usr/lib/clang/3.5.0/lib/freebsd/libclang_rt.asan-x86_64.a
OLD_FILES+=usr/lib/clang/3.5.0/lib/freebsd/libclang_rt.asan_cxx-i386.a
OLD_FILES+=usr/lib/clang/3.5.0/lib/freebsd/libclang_rt.asan_cxx-x86_64.a
OLD_FILES+=usr/lib/clang/3.5.0/lib/freebsd/libclang_rt.profile-arm.a
OLD_FILES+=usr/lib/clang/3.5.0/lib/freebsd/libclang_rt.profile-i386.a
OLD_FILES+=usr/lib/clang/3.5.0/lib/freebsd/libclang_rt.profile-x86_64.a
OLD_FILES+=usr/lib/clang/3.5.0/lib/freebsd/libclang_rt.san-i386.a
OLD_FILES+=usr/lib/clang/3.5.0/lib/freebsd/libclang_rt.san-x86_64.a
OLD_FILES+=usr/lib/clang/3.5.0/lib/freebsd/libclang_rt.ubsan-i386.a
OLD_FILES+=usr/lib/clang/3.5.0/lib/freebsd/libclang_rt.ubsan-x86_64.a
OLD_FILES+=usr/lib/clang/3.5.0/lib/freebsd/libclang_rt.ubsan_cxx-i386.a
OLD_FILES+=usr/lib/clang/3.5.0/lib/freebsd/libclang_rt.ubsan_cxx-x86_64.a
OLD_DIRS+=usr/lib/clang/3.5.0/lib/freebsd
OLD_DIRS+=usr/lib/clang/3.5.0/lib
OLD_DIRS+=usr/lib/clang/3.5.0
OLD_DIRS+=usr/lib/clang
OLD_FILES+=usr/share/doc/llvm/clang/LICENSE.TXT OLD_FILES+=usr/share/doc/llvm/clang/LICENSE.TXT
OLD_DIRS+=usr/share/doc/llvm/clang OLD_DIRS+=usr/share/doc/llvm/clang
OLD_FILES+=usr/share/doc/llvm/COPYRIGHT.regex OLD_FILES+=usr/share/doc/llvm/COPYRIGHT.regex