Skip to content

Commit

Permalink
[lit] Fix setup of sanitizer environment
Browse files Browse the repository at this point in the history
Not all options were propageted into tests.

Reviewed By: ychen

Differential Revision: https://reviews.llvm.org/D122869
  • Loading branch information
vitalybuka committed May 20, 2022
1 parent 0e02bf6 commit d33c362
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 26 deletions.
17 changes: 13 additions & 4 deletions clang/test/Unit/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,19 @@
if 'TEMP' in os.environ:
config.environment['TEMP'] = os.environ['TEMP']

# Propagate path to symbolizer for ASan/MSan.
for symbolizer in ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH']:
if symbolizer in os.environ:
config.environment[symbolizer] = os.environ[symbolizer]
# Propagate sanitizer options.
for var in [
'ASAN_SYMBOLIZER_PATH',
'MSAN_SYMBOLIZER_PATH',
'TSAN_SYMBOLIZER_PATH',
'UBSAN_SYMBOLIZER_PATH',
'ASAN_OPTIONS',
'MSAN_OPTIONS',
'TSAN_OPTIONS',
'UBSAN_OPTIONS',
]:
if var in os.environ:
config.environment[var] = os.environ[var]

def find_shlibpath_var():
if platform.system() in ['Linux', 'FreeBSD', 'NetBSD', 'SunOS']:
Expand Down
4 changes: 0 additions & 4 deletions clang/test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@
config.substitutions.append(
('%target_triple', config.target_triple))

# Propagate path to symbolizer for ASan/MSan.
llvm_config.with_system_environment(
['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH'])

config.substitutions.append(('%PATH%', config.environment['PATH']))


Expand Down
5 changes: 0 additions & 5 deletions cross-project-tests/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,6 @@ def get_required_attr(config, attr_name):
if 'compiler-rt' in config.llvm_enabled_projects:
config.available_features.add('compiler-rt')

if config.llvm_use_sanitizer:
# Propagate path to symbolizer for ASan/MSan.
llvm_config.with_system_environment(
['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH'])

# Check which debuggers are available:
lldb_path = llvm_config.use_llvm_tool('lldb', search_env='LLDB')

Expand Down
17 changes: 13 additions & 4 deletions llvm/test/Unit/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,19 @@
if 'HOME' in os.environ:
config.environment['HOME'] = os.environ['HOME']

# Propagate path to symbolizer for ASan/MSan.
for symbolizer in ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH']:
if symbolizer in os.environ:
config.environment[symbolizer] = os.environ[symbolizer]
# Propagate sanitizer options.
for var in [
'ASAN_SYMBOLIZER_PATH',
'MSAN_SYMBOLIZER_PATH',
'TSAN_SYMBOLIZER_PATH',
'UBSAN_SYMBOLIZER_PATH',
'ASAN_OPTIONS',
'MSAN_OPTIONS',
'TSAN_OPTIONS',
'UBSAN_OPTIONS',
]:
if var in os.environ:
config.environment[var] = os.environ[var]

# Win32 seeks DLLs along %PATH%.
if sys.platform in ['win32', 'cygwin'] and os.path.isdir(config.shlibdir):
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

# Propagate some variables from the host environment.
llvm_config.with_system_environment(
['HOME', 'INCLUDE', 'LIB', 'TMP', 'TEMP', 'ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH'])
['HOME', 'INCLUDE', 'LIB', 'TMP', 'TEMP'])


# Set up OCAMLPATH to include newly built OCaml libraries.
Expand Down
11 changes: 11 additions & 0 deletions llvm/utils/lit/lit/llvm/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ def __init__(self, lit_config, config):
if not self.use_lit_shell:
features.add('shell')

self.with_system_environment([
'ASAN_SYMBOLIZER_PATH',
'MSAN_SYMBOLIZER_PATH',
'TSAN_SYMBOLIZER_PATH',
'UBSAN_SYMBOLIZER_PATH'
'ASAN_OPTIONS',
'MSAN_OPTIONS',
'TSAN_OPTIONS',
'UBSAN_OPTIONS',
])

# Running on Darwin OS
if platform.system() == 'Darwin':
# FIXME: lld uses the first, other projects use the second.
Expand Down
17 changes: 13 additions & 4 deletions mlir/test/Unit/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,16 @@
if 'HOME' in os.environ:
config.environment['HOME'] = os.environ['HOME']

# Propagate path to symbolizer for ASan/MSan.
for symbolizer in ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH']:
if symbolizer in os.environ:
config.environment[symbolizer] = os.environ[symbolizer]
# Propagate sanitizer options.
for var in [
'ASAN_SYMBOLIZER_PATH',
'MSAN_SYMBOLIZER_PATH',
'TSAN_SYMBOLIZER_PATH',
'UBSAN_SYMBOLIZER_PATH',
'ASAN_OPTIONS',
'MSAN_OPTIONS',
'TSAN_OPTIONS',
'UBSAN_OPTIONS',
]:
if var in os.environ:
config.environment[var] = os.environ[var]
17 changes: 13 additions & 4 deletions polly/test/Unit/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,19 @@ if 'TMP' in os.environ:
if 'TEMP' in os.environ:
config.environment['TEMP'] = os.environ['TEMP']

# Propagate path to symbolizer for ASan/MSan.
for symbolizer in ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH']:
if symbolizer in os.environ:
config.environment[symbolizer] = os.environ[symbolizer]
# Propagate sanitizer options.
for var in [
'ASAN_SYMBOLIZER_PATH',
'MSAN_SYMBOLIZER_PATH',
'TSAN_SYMBOLIZER_PATH',
'UBSAN_SYMBOLIZER_PATH',
'ASAN_OPTIONS',
'MSAN_OPTIONS',
'TSAN_OPTIONS',
'UBSAN_OPTIONS',
]:
if var in os.environ:
config.environment[var] = os.environ[var]

if platform.system() == 'Darwin':
shlibpath_var = 'DYLD_LIBRARY_PATH'
Expand Down

0 comments on commit d33c362

Please sign in to comment.