diff --git a/CMakeLists.txt b/CMakeLists.txt index c2398d3..0dc7740 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 @@ -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 @@ -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") @@ -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 ) @@ -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" @@ -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 "*" @@ -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) @@ -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}) diff --git a/interception_tool/fpchecker.py b/interception_tool/fpchecker.py index 30d14a7..6ca4ddf 100755 --- a/interception_tool/fpchecker.py +++ b/interception_tool/fpchecker.py @@ -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 ***') diff --git a/interception_tool/intercept.c b/interception_tool/intercept.c index 6ce578d..507d89c 100644 --- a/interception_tool/intercept.c +++ b/interception_tool/intercept.c @@ -5,10 +5,13 @@ #include #include +#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) diff --git a/interception_tool/intercept.h.in b/interception_tool/intercept.h.in new file mode 100644 index 0000000..6512f0d --- /dev/null +++ b/interception_tool/intercept.h.in @@ -0,0 +1,9 @@ + + +#ifndef INTERCEPT_H +#define INTERCEPT_H + +#cmakedefine NVCC_WRAPPER "@NVCC_WRAPPER@" + +#endif /* INTERCEPT_H */ +