Skip to content

Commit

Permalink
modified CMaKe to create library paths
Browse files Browse the repository at this point in the history
  • Loading branch information
ilagunap committed Jun 8, 2021
1 parent f23e142 commit e255c7f
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 23 deletions.
47 changes: 26 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.11)
set(CMAKE_CXX_COMPILER "clang++")
set(CMAKE_C_COMPILER "clang")

project(fpchecker VERSION 0.2.0 DESCRIPTION "FPChecker" LANGUAGES CXX)
project(fpchecker VERSION 0.2.0 DESCRIPTION "FPChecker" LANGUAGES CXX C)

execute_process(COMMAND llvm-config --ldflags
OUTPUT_VARIABLE CMAKE_SHARED_LINKER_FLAGS
Expand All @@ -21,6 +21,9 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3 -g -std=c++14 -DFPC_DEBUG")

include(GNUInstallDirs)

set(NVCC_WRAPPER "${CMAKE_INSTALL_PREFIX}/bin/nvcc-fpc")
configure_file(interception_tool/intercept.h.in intercept.h)

add_library(fpchecker SHARED
src/CodeMatching.cpp
src/Instrumentation.cpp
Expand All @@ -33,6 +36,13 @@ add_library(fpchecker_plugin SHARED
plugin/instrumentation_plugin.cpp
)

add_library(fpchecker_intercept_lib SHARED
interception_tool/intercept.c
)

#set_target_properties(fpchecker_intercept_lib PROPERTIES LINKER_LANGUAGE C)
target_include_directories(fpchecker_intercept_lib PUBLIC ${CMAKE_CURRENT_BINARY_DIR})

if(APPLE)
TARGET_LINK_LIBRARIES(fpchecker "-undefined dynamic_lookup")
TARGET_LINK_LIBRARIES(fpchecker_plugin "-Wl,-flat_namespace -Wl,-undefined -Wl,suppress")
Expand All @@ -48,7 +58,7 @@ set(CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)

install(TARGETS fpchecker fpchecker_plugin
install(TARGETS fpchecker fpchecker_plugin fpchecker_intercept_lib
LIBRARY DESTINATION "lib64"
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
Expand All @@ -65,18 +75,12 @@ install(FILES "src/Runtime.h" "src/Runtime_plugin.h" "src/Runtime_parser.h"
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ
)

#install(FILES
# "tracing_tool/colors.py"
# "tracing_tool/expressions_parser.py"
# "tracing_tool/fpchecker.py"
# "tracing_tool/nvcc_options_table.py"
# "tracing_tool/nvcc_parser.py"
# "tracing_tool/strace_module.py"
# "tracing_tool/mpi_environment.py"
# "tracing_tool/debug_traces.py"
# DESTINATION bin
# PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
#)
install(FILES
"interception_tool/fpchecker.py"
"interception_tool/colors.py"
DESTINATION interception
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)

install(FILES
"parser/colors.py"
Expand All @@ -94,13 +98,6 @@ install(FILES
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)

# Install link for fpchecker tracing tool
#install(CODE "execute_process( \
# COMMAND ${CMAKE_COMMAND} -E create_symlink \
# ${CMAKE_INSTALL_PREFIX}/front-end/fpchecker.py ${CMAKE_INSTALL_PREFIX}/bin/fpchecker )"
# COMMENT "Creating link: fpchecker -> fpchecker.py"
#)

install(DIRECTORY
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
PATTERN "*"
Expand All @@ -121,6 +118,13 @@ install(CODE "execute_process( \
COMMENT "Creating link: fpc-report -> fpc-debug.py"
)

# Install link for fpchecker reports tool
install(CODE "execute_process( \
COMMAND ${CMAKE_COMMAND} -E create_symlink \
${CMAKE_INSTALL_PREFIX}/interception/fpchecker.py ${CMAKE_INSTALL_PREFIX}/bin/fpchecker )"
COMMENT "Creating link: fpchecker -> fpchecker.py"
)

# Tests
file(COPY tests DESTINATION ${CMAKE_BINARY_DIR})
file(COPY src/Runtime.h DESTINATION ${CMAKE_BINARY_DIR}/src)
Expand All @@ -137,3 +141,4 @@ message(STATUS "CMAKE_CXX_COMPILER: " ${CMAKE_CXX_COMPILER})
message(STATUS "CMAKE_CXX_FLAGS: " ${CMAKE_CXX_FLAGS})
message(STATUS "CMAKE_CPP_FLAGS: " ${CMAKE_CPP_FLAGS})
message(STATUS "CMAKE_SHARED_LINKER_FLAGS: " ${CMAKE_SHARED_LINKER_FLAGS})
message(STATUS "CMAKE_INSTALL_PREFIX: " ${CMAKE_INSTALL_PREFIX})
4 changes: 3 additions & 1 deletion interception_tool/fpchecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import subprocess
import sys
import os
from colors import *

INTERCEPT_LIB = '/usr/workspace/wsa/laguna/fpchecker/FPChecker/interception_tool/intercept.so'
#INTERCEPT_LIB = '/usr/workspace/wsa/laguna/fpchecker/FPChecker/interception_tool/intercept.so'
INTERCEPT_LIB = os.path.dirname(os.path.abspath(__file__))+"/../lib/libfpchecker_intercept_lib.so"

def runBuildCommand(params):
prGreen('*** FPChecker ***')
Expand Down
5 changes: 4 additions & 1 deletion interception_tool/intercept.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
#include <string.h>
#include <stdlib.h>

#include "intercept.h"

typedef ssize_t (*execve_func_t)(const char* filename, char* const argv[], char* const envp[]);

static execve_func_t old_execve = NULL;
static const char *nvcc_fpc = "/usr/workspace/wsa/laguna/fpchecker/FPChecker/bin/nvcc-fpc";
//static const char *nvcc_fpc = "/usr/workspace/wsa/laguna/fpchecker/FPChecker/bin/nvcc-fpc";
static const char *nvcc_fpc = NVCC_WRAPPER;

/** Return: one if the string t occurs at the end of the string s, and zero otherwise **/
int str_end(const char *s, const char *t)
Expand Down
9 changes: 9 additions & 0 deletions interception_tool/intercept.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@


#ifndef INTERCEPT_H
#define INTERCEPT_H

#cmakedefine NVCC_WRAPPER "@NVCC_WRAPPER@"

#endif /* INTERCEPT_H */

0 comments on commit e255c7f

Please sign in to comment.