Skip to content

Commit

Permalink
update cubin_filter
Browse files Browse the repository at this point in the history
  • Loading branch information
FindHao committed Mar 20, 2023
1 parent fcbe315 commit 14b0c55
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 1 deletion.
17 changes: 16 additions & 1 deletion cubin_filter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,23 @@ else ()
endif ()
enable_language(CUDA)

include(FindLibElf.cmake)
include(FindMbedTLS.cmake)

set(SANITIZER_PATH ${CUDAToolkit_TARGET_DIR}/compute-sanitizer)
message(INFO "==========")
message(STATUS ${LIBELF_INCLUDE_DIRS})
message(STATUS ${LIBELF_LIBRARIES_PATH})
message(STATUS ${MBEDTLS_INCLUDE_DIRS})
message(STATUS ${MBEDCRYPTO_LIBRARY_PATH})

set(SANITIZER_PATH ${CUDAToolkit_TARGET_DIR}/compute-sanitizer)
find_library(mbedcrypto_lib NAMES libmbedcrypto.so)
include_directories(${SANITIZER_PATH}/include/
${CUDAToolkit_TARGET_DIR}/include/
${CMAKE_CURRENT_LIST_DIR}/include/
${CMAKE_CURRENT_LIST_DIR}/src/
${LIBELF_INCLUDE_DIRS}
${MBEDTLS_INCLUDE_DIRS}
)
message(INFO ${SANITIZER_PATH} ${CUDAToolkit_NVCC_EXECUTABLE})
add_link_options(-L${SANITIZER_PATH} -fPIC -shared)
Expand All @@ -49,6 +59,11 @@ aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/ cubin_filter_src)
file(GLOB cubin_filter_head CONFIGURE_DEPENDS "${CMAKE_CURRENT_LIST_DIR}/*.h" )



add_link_options(-L${LIBELF_LIBRARIES_PATH} -L${MBEDTLS_LIBRARY_PATH} -L${MBEDCRYPTO_LIBRARY_PATH})

message(INFO ${mbedcrypto_lib})

add_library(cubin_filter SHARED ${cubin_filter_src} )

target_link_libraries(cubin_filter PUBLIC
Expand Down
66 changes: 66 additions & 0 deletions cubin_filter/FindLibElf.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# - Try to find libelf
# Once done this will define
#
# LIBELF_FOUND - system has libelf
# LIBELF_INCLUDE_DIRS - the libelf include directory
# LIBELF_LIBRARIES - Link these to use libelf
# LIBELF_DEFINITIONS - Compiler switches required for using libelf
#
# Copyright (c) 2008 Bernhard Walle <[email protected]>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#


if (LIBELF_LIBRARIES AND LIBELF_INCLUDE_DIRS)
set (LibElf_FIND_QUIETLY TRUE)
endif (LIBELF_LIBRARIES AND LIBELF_INCLUDE_DIRS)

find_path (LIBELF_INCLUDE_DIRS
NAMES
libelf.h
PATHS
/usr/include
/usr/include/libelf
/usr/local/include
/usr/local/include/libelf
/opt/local/include
/opt/local/include/libelf
/sw/include
/sw/include/libelf
ENV CPATH)

find_library (LIBELF_LIBRARIES
NAMES
elf
PATHS
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
ENV LIBRARY_PATH
ENV LD_LIBRARY_PATH)

get_filename_component(LIBELF_LIBRARIES_PATH ${LIBELF_LIBRARIES} DIRECTORY)

include (FindPackageHandleStandardArgs)


# handle the QUIETLY and REQUIRED arguments and set LIBELF_FOUND to TRUE if all listed variables are TRUE
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibElf DEFAULT_MSG
LIBELF_LIBRARIES
LIBELF_INCLUDE_DIRS)

SET(CMAKE_REQUIRED_LIBRARIES elf)
INCLUDE(CheckCXXSourceCompiles)
CHECK_CXX_SOURCE_COMPILES("#include <libelf.h>
int main() {
Elf *e = (Elf*)0;
size_t sz;
elf_getshdrstrndx(e, &sz);
return 0;
}" ELF_GETSHDRSTRNDX)

mark_as_advanced(LIBELF_INCLUDE_DIRS LIBELF_LIBRARIES ELF_GETSHDRSTRNDX)
40 changes: 40 additions & 0 deletions cubin_filter/FindMbedTLS.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) 1998 - 2022, Daniel Stenberg, <[email protected]>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at https://curl.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
# SPDX-License-Identifier: curl
#
###########################################################################
find_path(MBEDTLS_INCLUDE_DIRS mbedtls/md5.h)

find_library(MBEDTLS_LIBRARY mbedtls)
# find_library(MBEDX509_LIBRARY mbedx509)
find_library(MBEDCRYPTO_LIBRARY mbedcrypto)

get_filename_component(MBEDCRYPTO_LIBRARY_PATH ${MBEDCRYPTO_LIBRARY} DIRECTORY)
get_filename_component(MBEDTLS_LIBRARY_PATH ${MBEDTLS_LIBRARY} DIRECTORY)


set(MBEDTLS_LIBRARIES "${MBEDTLS_LIBRARY}" "${MBEDX509_LIBRARY}" "${MBEDCRYPTO_LIBRARY}")

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MbedTLS DEFAULT_MSG
MBEDTLS_INCLUDE_DIRS MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY)

mark_as_advanced(MBEDTLS_INCLUDE_DIRS MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY)

0 comments on commit 14b0c55

Please sign in to comment.