diff options
author | Tom Allsop <tom.allsop@arm.com> | 2022-11-04 10:40:10 +0000 |
---|---|---|
committer | Tom Allsop <tom.allsop@arm.com> | 2022-11-14 11:35:09 +0000 |
commit | b4240d3aa133b8eefd253498e3f2cc321e24ab84 (patch) | |
tree | 0fc478cdfc2ed902eda7d0c9afe2734987047c89 /setup.py | |
parent | 04a2328f9683b7fe97579a3310d2f473f38717dd (diff) | |
download | tosa_checker-b4240d3aa133b8eefd253498e3f2cc321e24ab84.tar.gz |
Added ASAN & UBSAN build options and Dockerfile for sanitized builds
* Added SanitizerBuild.Dockerfile for running sanitized builds.
* Added dependencies for bandit into SanitizerBuild.Dockerfile.
* Added --sanitizer option to setup.py.
* Added .bandit.yaml.
Change-Id: I4dd41bc52790a1b7f17ffca556362e37860ab572
Diffstat (limited to 'setup.py')
-rw-r--r-- | setup.py | 43 |
1 files changed, 29 insertions, 14 deletions
@@ -18,6 +18,12 @@ argparser = argparse.ArgumentParser() argparser.add_argument( "--tensorflow_src_dir", help="TensorFlow source directory path", required=False ) +argparser.add_argument( + "--sanitizer", + help="Build using a sanitizer (choose from asan or ubsan)", + choices=["asan", "ubsan"], + required=False +) args, unknown = argparser.parse_known_args() sys.argv = [sys.argv[0]] + unknown @@ -51,21 +57,30 @@ class BazelBuildExtension(setuptools.command.build_ext.build_ext): ext.tensorflow_version, ) - self.spawn( - [ - "bazel", - "build", - "-c", - "opt", - # FIXME Some of the Bazel targets dependencies we use have - # a 'friends' visibility, check if our Bazel target can be added - # to the 'friends' list. - "--check_visibility=false", - "--override_repository=org_tensorflow=" - + os.path.abspath(tensorflow_src_dir), - ext.bazel_target, + commands = [ + "bazel", + "build" + ] + + if args.sanitizer: + commands += [ + "--config={}".format(args.sanitizer) ] - ) + + commands += [ + # FIXME Some of the Bazel targets dependencies we use have + # a 'friends' visibility, check if our Bazel target can be added + # to the 'friends' list. + "-c", + "opt", + "--check_visibility=false", + "--override_repository=org_tensorflow={}".format( + os.path.abspath(tensorflow_src_dir) + ), + ext.bazel_target + ] + + self.spawn(commands) shared_lib_dest_path = self.get_ext_fullpath(ext.name) shared_lib_dest_dir = os.path.dirname(shared_lib_dest_path) |