Skip to content

Commit

Permalink
Add -shared-libasan
Browse files Browse the repository at this point in the history
  • Loading branch information
sfodagain committed Sep 18, 2023
1 parent d88b8e4 commit ac71a4d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .builder/actions/setup_asan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Builder

import os
import re
import subprocess


class SetupAsan(Builder.Action):
def run(self, env):
self.env = env

compiler = os.getenv('CC')
proc = subprocess.run([compiler, '-print-file-name=libclang_rt.asan-x86_64.so'], stdout=subprocess.PIPE)
proc.check_returncode()
path = proc.stdout.decode().strip()
self._setenv('LD_PRELOAD', path)

def _setenv(self, var, value):
"""
Set environment variable now,
and ensure the environment variable is set again when tests run
"""
self.env.shell.setenv(var, value)
self.env.project.config['test_env'][var] = value
9 changes: 9 additions & 0 deletions builder.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,14 @@
"env": {
"LSAN_OPTIONS": "suppressions={source_dir}/tests/resources/suppressions-lsan.txt:allow_addr2line=1",
"ASAN_OPTIONS": "suppressions={source_dir}/tests/resources/suppressions-asan.txt"
},
"compilers": {
"clang": {
"+post_build_steps": ["setup-asan"],
"cmake_args": [
"-DCMAKE_C_FLAGS=-shared-libasan",
"-DCMAKE_CXX_FLAGS=-shared-libasan"
]
}
}
}

0 comments on commit ac71a4d

Please sign in to comment.