[OpenMP] Fix libarcher tests on Ubuntu 22.04 (#170671)
When llvm-symbolizer is not found on PATH TSan uses system's addr2line instead. On Ubuntu 22.04 addr2line can't handle DWARF v5, which results in failures in some libarcher tests. This PR adds the directory of the just built LLVM binaries to PATH, to make llvm-symbolizer available to TSan. The changes were tested on an AArch64 machine, on which task-taskgroup-unrelated.c was flaky. Moving the test code to a separate function, executed 10 times, solved the issue. Fixes #170138
This commit is contained in:
parent
df14096e00
commit
de776fb60a
2 changed files with 30 additions and 4 deletions
|
|
@ -11,21 +11,30 @@ if 'PYLINT_IMPORT' in os.environ:
|
|||
config = object()
|
||||
lit_config = object()
|
||||
|
||||
def get_path_separator():
|
||||
return ';' if config.operating_system == 'Windows' else ':'
|
||||
|
||||
def append_dynamic_library_path(path):
|
||||
if config.operating_system == 'Windows':
|
||||
name = 'PATH'
|
||||
sep = ';'
|
||||
elif config.operating_system == 'Darwin':
|
||||
name = 'DYLD_LIBRARY_PATH'
|
||||
sep = ':'
|
||||
else:
|
||||
name = 'LD_LIBRARY_PATH'
|
||||
sep = ':'
|
||||
sep = get_path_separator()
|
||||
if name in config.environment:
|
||||
config.environment[name] = path + sep + config.environment[name]
|
||||
else:
|
||||
config.environment[name] = path
|
||||
|
||||
def append_path(path):
|
||||
name = 'PATH'
|
||||
sep = get_path_separator()
|
||||
if name in config.environment:
|
||||
config.environment[name] = config.environment[name] + sep + path
|
||||
else:
|
||||
config.environment[name] = path
|
||||
|
||||
# name: The name of this test suite.
|
||||
config.name = 'libarcher'
|
||||
|
||||
|
|
@ -65,6 +74,11 @@ for feature in config.test_compiler_features:
|
|||
append_dynamic_library_path(config.omp_library_dir)
|
||||
append_dynamic_library_path(config.libarcher_obj_root+"/..")
|
||||
|
||||
# Add LLVM bin dir to PATH.
|
||||
# llvm-symbolizer is needed to correctly resolve addresses, without relying on
|
||||
# system's addr2line.
|
||||
append_path(os.path.dirname(config.test_c_compiler))
|
||||
|
||||
# Rpath modifications for Darwin
|
||||
if config.operating_system == 'Darwin':
|
||||
config.test_flags += " -Wl,-rpath," + config.omp_library_dir
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int test(void) {
|
||||
int var = 0, a = 0;
|
||||
|
||||
#pragma omp parallel num_threads(8) shared(var, a)
|
||||
|
|
@ -48,6 +48,18 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
int error = (var != 2);
|
||||
return error;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int i, error;
|
||||
|
||||
for (i = 0; i < 10; ++i) {
|
||||
error = test();
|
||||
if (error)
|
||||
return error;
|
||||
}
|
||||
|
||||
fprintf(stderr, "DONE\n");
|
||||
return error;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue