Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions rtl/ompt-tsan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,36 +142,42 @@ extern "C" {
fptr = (void (*)(const char *, int, const volatile void *))dlsym(RTLD_DEFAULT, "AnnotateHappensAfter");
(*fptr)(file,line,cv);
}

static void AnnotateHappensBefore(const char *file, int line, const volatile void *cv){
void (*fptr)(const char *, int, const volatile void *);

fptr = (void (*)(const char *, int, const volatile void *))dlsym(RTLD_DEFAULT, "AnnotateHappensBefore");
(*fptr)(file,line,cv);
}

static void AnnotateIgnoreWritesBegin(const char *file, int line){
void (*fptr)(const char *, int);

fptr = (void (*)(const char *, int))dlsym(RTLD_DEFAULT, "AnnotateIgnoreWritesBegin");
(*fptr)(file,line);
}

static void AnnotateIgnoreWritesEnd(const char *file, int line){
void (*fptr)(const char *, int);

fptr = (void (*)(const char *, int))dlsym(RTLD_DEFAULT, "AnnotateIgnoreWritesEnd");
(*fptr)(file,line);
}

static void AnnotateNewMemory(const char *file, int line, const volatile void *cv, size_t size){
void (*fptr)(const char *, int, const volatile void *,size_t);

fptr = (void (*)(const char *, int, const volatile void *,size_t))dlsym(RTLD_DEFAULT, "AnnotateNewMemory");
(*fptr)(file,line,cv,size);
}

static int RunningOnValgrind(){
int (*fptr)();

fptr = (int (*)())dlsym(RTLD_DEFAULT, "RunningOnValgrind");
if (fptr==NULL || fptr != RunningOnValgrind)
if (fptr == NULL)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jprotze fptr pointer is NULL when -fsanitize=thread is not used, not NULL otherwise. So the only way to activate Archer is to keep only this check. Let me know what you think.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reasoning behind the extra check fptr != RunningOnValgrind is, that the dynamic loader might find the function RunningOnValgrind in ompt-tsan. In that case, we can also assume that there is no tsan in the application.

runOnTsan = 0;

return 0;
}
#else
Expand Down Expand Up @@ -994,8 +1000,9 @@ ompt_start_tool_result_t* ompt_start_tool(
static ompt_start_tool_result_t ompt_start_tool_result = {&ompt_tsan_initialize,&ompt_tsan_finalize, {0}};
runOnTsan=1;
RunningOnValgrind();
if (!runOnTsan) // if we are not running on TSAN, give a different tool the chance to be loaded
if (!runOnTsan) { // if we are not running on TSAN, give a different tool the chance to be loaded
return NULL;
}

return &ompt_start_tool_result;
}
6 changes: 3 additions & 3 deletions tools/clang-archer++.in
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ done

if [ $linking == yes ] ; then
if [ @LIBOMP_TSAN_SUPPORT@ == FALSE ] ; then
link_flags="-L@OMP_PREFIX@/lib -Wl,-rpath=@OMP_PREFIX@/lib -L@CMAKE_INSTALL_PREFIX@/lib -Wl,-rpath=@CMAKE_INSTALL_PREFIX@/lib -larcher"
link_flags="-L@OMP_PREFIX@/lib -Wl,-rpath,@OMP_PREFIX@/lib -L@CMAKE_INSTALL_PREFIX@/lib -Wl,-rpath,@CMAKE_INSTALL_PREFIX@/lib -larcher"
else
link_flags="-L@OMP_PREFIX@/lib -Wl,-rpath=@OMP_PREFIX@/lib"
link_flags="-L@OMP_PREFIX@/lib -Wl,-rpath,@OMP_PREFIX@/lib"
fi
else
link_flags=""
fi

if [ "$static_analysis" == "true" ]; then
@LLVM_ROOT@/bin/clang++ -I@OMP_PREFIX@/include -Xclang -load -Xclang @CMAKE_INSTALL_PREFIX@/lib/LLVMArcher.so -fopenmp -fsanitize=thread $link_flags -g "$@"
@LLVM_ROOT@/bin/clang++ -I@OMP_PREFIX@/include -Xclang -load -Xclang @CMAKE_INSTALL_PREFIX@/lib/LLVMArcher@CMAKE_SHARED_LIBRARY_SUFFIX@ -fopenmp -fsanitize=thread $link_flags -g "$@"
else
@LLVM_ROOT@/bin/clang++ -I@OMP_PREFIX@/include -fopenmp -fsanitize=thread $link_flags -g "$@"
fi
6 changes: 3 additions & 3 deletions tools/clang-archer.in
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ done

if [ $linking == yes ] ; then
if [ @LIBOMP_TSAN_SUPPORT@ == FALSE ] ; then
link_flags="-L@OMP_PREFIX@/lib -Wl,-rpath=@OMP_PREFIX@/lib -L@CMAKE_INSTALL_PREFIX@/lib -Wl,-rpath=@CMAKE_INSTALL_PREFIX@/lib -larcher"
link_flags="-L@OMP_PREFIX@/lib -Wl,-rpath,@OMP_PREFIX@/lib -L@CMAKE_INSTALL_PREFIX@/lib -Wl,-rpath,@CMAKE_INSTALL_PREFIX@/lib -larcher"
else
link_flags="-L@OMP_PREFIX@/lib -Wl,-rpath=@OMP_PREFIX@/lib"
link_flags="-L@OMP_PREFIX@/lib -Wl,-rpath,@OMP_PREFIX@/lib"
fi
else
link_flags=""
fi

if [ "$static_analysis" == "true" ]; then
@LLVM_ROOT@/bin/clang -I@OMP_PREFIX@/include -Xclang -load -Xclang @CMAKE_INSTALL_PREFIX@/lib/LLVMArcher.so -fopenmp -fsanitize=thread $link_flags -g "$@"
@LLVM_ROOT@/bin/clang -I@OMP_PREFIX@/include -Xclang -load -Xclang @CMAKE_INSTALL_PREFIX@/lib/LLVMArcher@CMAKE_SHARED_LIBRARY_SUFFIX@ -fopenmp -fsanitize=thread $link_flags -g "$@"
else
@LLVM_ROOT@/bin/clang -I@OMP_PREFIX@/include -fopenmp -fsanitize=thread $link_flags -g "$@"
fi