1
1
mirror of https://github.com/henrydcase/pqc.git synced 2024-11-22 23:48:58 +00:00

improves makefile

This commit is contained in:
Henry Case 2021-06-22 01:10:08 +01:00
parent 6d3550454a
commit d9344d6956
3 changed files with 40 additions and 10 deletions

View File

@ -1,14 +1,40 @@
include(ExternalProject) include(ExternalProject)
find_program(MAKE_PROGRAM make)
string (REPLACE " " "$<SEMICOLON>" LLVM_PROJECT_TARGETS "libcxx libcxxabi") string (REPLACE " " "$<SEMICOLON>" LLVM_PROJECT_TARGETS "libcxx libcxxabi")
set(PREFIX ${CMAKE_CURRENT_BINARY_DIR}/3rd/llvm-project) set(PREFIX ${CMAKE_CURRENT_BINARY_DIR}/3rd/llvm-project)
set(LLVM_LIB_CXX
${PREFIX}/usr/local/lib/libc++${CMAKE_STATIC_LIBRARY_SUFFIX})
set(LLVM_LIB_CXXABI
${PREFIX}/usr/local/lib/libc++abi${CMAKE_STATIC_LIBRARY_SUFFIX})
ExternalProject_Add( ExternalProject_Add(
llvm-project llvm-project
GIT_REPOSITORY https://github.com/llvm/llvm-project.git GIT_REPOSITORY https://github.com/llvm/llvm-project.git
GIT_TAG llvmorg-12.0.0 GIT_TAG llvmorg-12.0.0
GIT_SHALLOW TRUE GIT_SHALLOW TRUE
CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS=${LLVM_PROJECT_TARGETS} -DLLVM_USE_SANITIZER=MemoryWithOrigins -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ../llvm-project/llvm CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS=${LLVM_PROJECT_TARGETS} -DLLVM_USE_SANITIZER=MemoryWithOrigins -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ../llvm-project/llvm
BUILD_COMMAND make cxx cxxabi BUILD_COMMAND ${MAKE_PROGRAM} cxx cxxabi
INSTALL_COMMAND DESTDIR=${PREFIX} make install-cxx-headers install-cxx install-cxxabi INSTALL_COMMAND DESTDIR=${PREFIX} make install-cxx-headers install-cxx install-cxxabi
COMMENT "Building memcheck instrumented libc++ and libc++abi" COMMENT "Building memcheck instrumented libc++ and libc++abi"
PREFIX ${PREFIX} PREFIX ${PREFIX}
) )
add_library(
cxx SHARED IMPORTED GLOBAL)
add_library(
cxxabi SHARED IMPORTED GLOBAL)
add_dependencies(
cxx
llvm-project)
add_dependencies(
cxxabi
llvm-project)
set_target_properties(
cxx PROPERTIES IMPORTED_LOCATION ${LLVM_LIB_CXX})
set_target_properties(
cxxabi PROPERTIES IMPORTED_LOCATION ${LLVM_LIB_CXXABI})
set_property(GLOBAL PROPERTY llvmproject_build_install_dir_property ${PREFIX}/usr/local)

View File

@ -19,7 +19,7 @@ if(MEMSAN)
if(ADDRSAN) if(ADDRSAN)
message(FATAL_ERROR "Can't use MSAN and ASAN") message(FATAL_ERROR "Can't use MSAN and ASAN")
endif() endif()
include(.cmake/libstd-memcheck.mk) include(.cmake/libstd-memory_sanitizer.mk)
# LLVM project location # LLVM project location
set(LLVM_PRJ ${CMAKE_CURRENT_BINARY_DIR}/3rd/llvm-project) set(LLVM_PRJ ${CMAKE_CURRENT_BINARY_DIR}/3rd/llvm-project)
@ -27,7 +27,7 @@ if(MEMSAN)
set(LLVM_PRJ_INC ${LLVM_PRJ}/usr/local/include) set(LLVM_PRJ_INC ${LLVM_PRJ}/usr/local/include)
# Add memory sanitizer instrumented libraries # Add memory sanitizer instrumented libraries
set(CMAKE_ARGS_MEMCHECK_LIB "-stdlib=libc++ -L${LLVM_PRJ_LIB} -lc++abi -Wl,-rpath,${LLVM_PRJ_LIB}") set(CMAKE_ARGS_MEMCHECK_LIB "-stdlib=libc++")
set(CMAKE_ARGS_MEMCHECK_INC "-isystem -I${LLVM_PRJ_INC} -I${LLVM_PRJ_INC}/c++/v1") set(CMAKE_ARGS_MEMCHECK_INC "-isystem -I${LLVM_PRJ_INC} -I${LLVM_PRJ_INC}/c++/v1")
set(CMAKE_ARGS_MEMCHECK_FLAGS "-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer -Wno-unused-command-line-argument") set(CMAKE_ARGS_MEMCHECK_FLAGS "-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer -Wno-unused-command-line-argument")
set(EXTRA_CXX_FLAGS "${CMAKE_ARGS_MEMCHECK_FLAGS} ${CMAKE_ARGS_MEMCHECK_LIB} ${CMAKE_ARGS_MEMCHECK_INC} -DPQC_MEMSAN_BUILD") set(EXTRA_CXX_FLAGS "${CMAKE_ARGS_MEMCHECK_FLAGS} ${CMAKE_ARGS_MEMCHECK_LIB} ${CMAKE_ARGS_MEMCHECK_INC} -DPQC_MEMSAN_BUILD")
@ -43,6 +43,7 @@ ExternalProject_Add(
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/3rd/gtest INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/3rd/gtest
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/3rd/gtest -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_CXX_FLAGS=${EXTRA_CXX_FLAGS} -DCMAKE_C_FLAGS=${EXTRA_CXX_FLAGS} -Dgtest_disable_pthreads=ON CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/3rd/gtest -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_CXX_FLAGS=${EXTRA_CXX_FLAGS} -DCMAKE_C_FLAGS=${EXTRA_CXX_FLAGS} -Dgtest_disable_pthreads=ON
) )
add_dependencies(gtest_project cxx cxxabi)
FetchContent_Declare( FetchContent_Declare(
gbench gbench
@ -270,7 +271,6 @@ add_subdirectory(src/sign/sphincs/sphincs-sha256-256s-simple/avx2)
add_subdirectory(src/sign/sphincs/sphincs-sha256-256f-robust/avx2) add_subdirectory(src/sign/sphincs/sphincs-sha256-256f-robust/avx2)
add_subdirectory(src/sign/sphincs/sphincs-sha256-256f-simple/avx2) add_subdirectory(src/sign/sphincs/sphincs-sha256-256f-simple/avx2)
add_subdirectory(src/sign/sphincs/sphincs-sha256-256s-robust/avx2) add_subdirectory(src/sign/sphincs/sphincs-sha256-256s-robust/avx2)
# KEMs # KEMs
add_subdirectory(src/kem/kyber/kyber512/avx2) add_subdirectory(src/kem/kyber/kyber512/avx2)
add_subdirectory(src/kem/kyber/kyber768/avx2) add_subdirectory(src/kem/kyber/kyber768/avx2)
@ -348,6 +348,8 @@ add_executable(
target_link_libraries( target_link_libraries(
ut ut
cxx
cxxabi
gtest gtest
gtest_main gtest_main
pqc_s) pqc_s)

View File

@ -4,15 +4,17 @@ include_directories(${PROJECT_SOURCE_DIR}/3rd/gbench/include)
link_directories(${CMAKE_CURRENT_BINARY_DIR}/../../3rd/gbench/lib) link_directories(${CMAKE_CURRENT_BINARY_DIR}/../../3rd/gbench/lib)
add_executable( add_executable(
bench bench
kyber.cc kyber.cc
) )
target_link_libraries( target_link_libraries(
bench bench
pqc pqc
benchmark benchmark
benchmark_main benchmark_main
cxx
cxxabi
) )