]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/mk/bsd.sanitizer.mk
Revert "ossl: Add support for AES-CBC cipher"
[FreeBSD/FreeBSD.git] / share / mk / bsd.sanitizer.mk
1 .include <bsd.opts.mk>
2
3 _use_sanitizers=        no
4 # Add the necessary sanitizer flags if requested
5 .if ${MK_ASAN} == "yes" && ${NO_SHARED:Uno:tl} == "no"
6 SANITIZER_CFLAGS+=      -fsanitize=address -fPIC
7 # TODO: remove this once all basic errors have been fixed:
8 # https://github.com/google/sanitizers/wiki/AddressSanitizer#faq
9 SANITIZER_CFLAGS+=      -fsanitize-recover=address
10 SANITIZER_LDFLAGS+=     -fsanitize=address
11 _use_sanitizers=        yes
12 .endif # ${MK_ASAN} == "yes"
13
14 .if ${MK_UBSAN} == "yes" && ${NO_SHARED:Uno:tl} == "no"
15 # Unlike the other sanitizers, UBSan could also work for static libraries.
16 # However, this currently results in linker errors (even with the
17 # -fsanitize-minimal-runtime flag), so only enable it for dynamically linked
18 # code for now.
19 SANITIZER_CFLAGS+=      -fsanitize=undefined
20 SANITIZER_CFLAGS+=      -fsanitize-recover=undefined
21 SANITIZER_LDFLAGS+=     -fsanitize=undefined
22 _use_sanitizers=        yes
23 .endif # ${MK_UBSAN} == "yes"
24
25 .if !defined(BOOTSTRAPPING) && ${_use_sanitizers} != "no" && \
26     ${COMPILER_TYPE} != "clang"
27 .error "Sanitizer instrumentation currently only supported with clang"
28 .endif
29
30 # For libraries we only instrument the shared and PIE libraries by setting
31 # SHARED_CFLAGS instead of CFLAGS. We do this since static executables are not
32 # compatible with the santizers (interceptors do not work).
33 .if ${_use_sanitizers} != "no"
34 .include "../../lib/libclang_rt/compiler-rt-vars.mk"
35 .if target(__<bsd.lib.mk>__)
36 SHARED_CFLAGS+= ${SANITIZER_CFLAGS}
37 SOLINKOPTS+=    ${SANITIZER_LDFLAGS}
38 LDFLAGS:=       ${LDFLAGS:N-Wl,-no-undefined:N-Wl,--no-undefined}
39 .else
40 CFLAGS+=        ${SANITIZER_CFLAGS}
41 LDFLAGS+=       ${SANITIZER_LDFLAGS}
42 .endif
43 .endif # ${_use_sanitizers} != "no"