-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trying to use remill (with cxx-commons precompiled vcpkg packages) #560
Comments
This is my process: Build and installMy directory layout, update as you see fit.
Create a virtual environment: python3 -m venv ~/Build/install-release Activate the virtual environment so that your source ~/Build/install-release/bin/activate Go into build directory for a release build of Remill. cd ~/Build/remill-release Compile Remill. Specifying cmake \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_INSTALL_PREFIX=/Users/pag/Build/install-release \
-DVCPKG_ROOT=/Users/pag/Build/vcpkg-12-release \
-DVCPKG_TARGET_TRIPLET=x64-osx-rel \
-DCMAKE_C_COMPILER=`which clang` \
-DCMAKE_CXX_COMPILER=`which clang++` \
~/Code/remill Then you build and install that, and it installs into Here's Anvill following the same process: -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_INSTALL_PREFIX=/Users/pag/Build/install-release \
-DVCPKG_ROOT=/Users/pag/Build/vcpkg-12-release \
-DVCPKG_TARGET_TRIPLET=x64-osx-rel \
-DCMAKE_C_COMPILER=`which clang` \
-DCMAKE_CXX_COMPILER=`which clang++` \
~/Code/anvill Build and install that. Then, if you have Binary Ninja, do roughly the following to install the Binary Ninja API into the virtual environment: python3 /Applications/Binary\ Ninja.app/Contents/Resources/scripts/install_api.py -v That Now you have remill and anvill installed. Next up, using it. Integrate into another projectRight now, all of our projects that integrate with our vcpkg dependencies go and use copies of vcpkg_helper.cmake. I think @ekilmer might want to change this in the future, but this works for now. Here's what a typical CMakeLists.txt should look like that uses Remill: cmake_minimum_required(VERSION 3.19)
include("cmake/options.cmake")
include("cmake/ccache.cmake")
include("cmake/vcpkg_helper.cmake")
project("project_name")
include(GNUInstallDirs)
include("cmake/system.cmake")
include("cmake/target_settings.cmake")
include("cmake/llvm.cmake")
if(ENABLE_INSTALL)
include("cmake/packaging.cmake")
endif()
set(_VCPKG_SHARE_DIR "${VCPKG_ROOT}/installed/${VCPKG_TARGET_TRIPLET}/${CMAKE_INSTALL_DATADIR}")
find_package(XED CONFIG REQUIRED HINTS "${_VCPKG_SHARE_DIR}")
find_package(gflags CONFIG REQUIRED HINTS "${_VCPKG_SHARE_DIR}")
find_package(glog CONFIG REQUIRED HINTS "${_VCPKG_SHARE_DIR}")
find_package(Z3 4.8.12.0 EXACT CONFIG REQUIRED)
find_llvm(llvm "${_VCPKG_SHARE_DIR}")
find_package(remill CONFIG REQUIRED)
find_package(anvill CONFIG REQUIRED)
if(ENABLE_INSTALL)
export(PACKAGE "${PROJECT_NAME}")
set(cmake_install_dir "lib/cmake/${PROJECT_NAME}")
include(CMakePackageConfigHelpers)
configure_package_config_file("${PROJECT_NAME}Config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION "${cmake_install_dir}"
)
install(EXPORT "${PROJECT_NAME}Targets"
DESTINATION "${cmake_install_dir}"
NAMESPACE "${PROJECT_NAME}::"
)
install(
TARGETS
"llvm"
EXPORT
"${PROJECT_NAME}Targets"
)
endif()
add_subdirectory("blah") and llvm.cmake: #
# Copyright (c) 2021-present, Trail of Bits, Inc.
# All rights reserved.
#
# This source code is licensed in accordance with the terms specified in
# the LICENSE file found in the root directory of this source tree.
#
function(find_llvm target_name hint_dir)
find_package(llvm CONFIG REQUIRED HINTS "${hint_dir}")
add_library("${target_name}" INTERFACE)
target_include_directories("${target_name}" SYSTEM INTERFACE
$<BUILD_INTERFACE:${LLVM_INCLUDE_DIRS}>
)
target_compile_definitions("${target_name}" INTERFACE
${LLVM_DEFINITIONS}
)
# Go find only the static libraries of LLVM, and link against those.
foreach(LLVM_LIB IN LISTS LLVM_AVAILABLE_LIBS)
get_target_property(LLVM_LIB_TYPE ${LLVM_LIB} TYPE)
if(LLVM_LIB_TYPE STREQUAL "STATIC_LIBRARY")
list(APPEND LLVM_LIBRARIES "${LLVM_LIB}")
endif()
endforeach()
# These are out-of-order in `LLVM_AVAILABLE_LIBS` and should always be last.
list(REMOVE_ITEM LLVM_LIBRARIES LLVMMC LLVMCore LLVMSupport)
list(APPEND LLVM_LIBRARIES LLVMMC LLVMCore LLVMSupport)
target_link_libraries("${target_name}" INTERFACE
${LLVM_LIBRARIES}
)
endfunction(find_llvm) Usage: target_link_libraries("my_target_name"
PUBLIC
llvm
remill
anvill
) |
Hello, I just switched to Ubuntu (20.04) a couple of days ago and now I'm using the CLion IDE here. I'm trying to create a project using remill and LLVM, but I ran into a problem when creating the CMakeList. I have an example to get it started, but when I tried to recreate it, I realized that I can't link the libraries from the LLVM downloaded from cxx-common (v0.1.5, vcpkg_ubuntu-20.04_llvm-12_amd64.tar.xz). What should I do, maybe there are some repositories that show how to connect it all?
I've tried a lot of options, but here's my last one
Here is my main.cpp (located in source folder)
Here's part of the output I get (besides these, there are hundreds more lines of "undefined reference to" errors)
The text was updated successfully, but these errors were encountered: