aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Sujak <jakub.sujak@arm.com>2024-01-28 18:30:50 +0000
committerJakub Sujak <jakub.sujak@arm.com>2024-01-31 13:32:46 +0000
commitb5d608263b8d1f4e2f53b2e82574e67237cc9e77 (patch)
tree42fe557494525077058c3dca772d6b3a1e2ac9bf
parentec89b914f399d35a57e213e7a3af56231d480540 (diff)
downloadComputeLibrary-b5d608263b8d1f4e2f53b2e82574e67237cc9e77.tar.gz
Add build options for Address and UndefinedBehavior sanitizers
Towards: COMPMID-6625, COMPMID-6627 Change-Id: I360dfdc48b429647e4e19d6216de310130d563d0 Signed-off-by: Jakub Sujak <jakub.sujak@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/11041 Benchmark: Arm Jenkins <bsgcomp@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Adnan AlSinan <adnan.alsinan@arm.com>
-rw-r--r--SConscript3
-rw-r--r--SConstruct16
2 files changed, 17 insertions, 2 deletions
diff --git a/SConscript b/SConscript
index e8f8b87f40..0f9d167742 100644
--- a/SConscript
+++ b/SConscript
@@ -532,8 +532,9 @@ arm_compute_env.Append(CPPDEFINES = [('ARM_COMPUTE_VERSION_MAJOR', LIBRARY_VERSI
# Don't allow undefined references in the libraries:
undefined_flag = '-Wl,-undefined,error' if 'macos' in arm_compute_env["os"] else '-Wl,--no-undefined'
-if not env['thread_sanitizer']:
+if not env['thread_sanitizer'] or not env['address_sanitizer'] or not env['undefined_sanitizer']:
arm_compute_env.Append(LINKFLAGS=[undefined_flag])
+
arm_compute_env.Append(CPPPATH =[Dir("./src/core/").path] )
if env['os'] != 'openbsd':
diff --git a/SConstruct b/SConstruct
index cf8fb52bd6..e415b3469f 100644
--- a/SConstruct
+++ b/SConstruct
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright (c) 2016-2023 Arm Limited.
+# Copyright (c) 2016-2024 Arm Limited.
#
# SPDX-License-Identifier: MIT
#
@@ -139,6 +139,8 @@ vars.AddVariables(
ListVariable("data_layout_support", "Enable a list of data layout to support", "all", ["nhwc", "nchw"]),
("toolchain_prefix", "Override the toolchain prefix; used by all toolchain components: compilers, linker, assembler etc. If unspecified, use default(auto) prefixes; if passed an empty string '' prefixes would be disabled", "auto"),
("compiler_prefix", "Override the compiler prefix; used by just compilers (CC,CXX); further overrides toolchain_prefix for compilers; this is for when the compiler prefixes are different from that of the linkers, archivers etc. If unspecified, this is the same as toolchain_prefix; if passed an empty string '' prefixes would be disabled", "auto"),
+ BoolVariable("address_sanitizer", "Enable AddressSanitizer", False),
+ BoolVariable("undefined_sanitizer", "Enable UndefinedBehaviorSanitizer", False),
BoolVariable("thread_sanitizer", "Enable ThreadSanitizer", False),
("extra_cxx_flags", "Extra CXX flags to be appended to the build command", ""),
("extra_link_flags", "Extra LD flags to be appended to the build command", ""),
@@ -618,6 +620,18 @@ if env['asserts']:
if env['logging']:
env.Append(CPPDEFINES = ['ARM_COMPUTE_LOGGING_ENABLED'])
+if env['address_sanitizer']:
+ if 'android' in env['os']:
+ env.Append(CXXFLAGS = ['-fsanitize=hwaddress'])
+ env.Append(LINKFLAGS = ['-fsanitize=hwaddress'])
+ else:
+ env.Append(CXXFLAGS = ['-fsanitize=address'])
+ env.Append(LINKFLAGS = ['-fsanitize=address'])
+
+if env['undefined_sanitizer']:
+ env.Append(CXXFLAGS = ['-fsanitize=undefined'])
+ env.Append(LINKFLAGS = ['-fsanitize=undefined'])
+
if env['thread_sanitizer']:
env.Append(CXXFLAGS = ['-fsanitize=thread'])
env.Append(LINKFLAGS = ['-fsanitize=thread'])