Skip to content
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

Fix build with system LLVM #638

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,13 @@ find_package(Z3 CONFIG REQUIRED)

# LLVM
find_package(LLVM CONFIG REQUIRED)
llvm_map_components_to_libnames(llvm_libs
support core irreader
bitreader bitwriter
passes asmprinter
aarch64codegen aarch64asmparser
armcodegen armasmparser
interpreter mcjit
nvptxdesc
x86codegen x86asmparser
sparccodegen sparcasmparser
webassemblydesc)
message(STATUS "LLVM Libraries: ${llvm_libs}")

# https://github.com/JonathanSalwan/Triton/issues/1082#issuecomment-1030826696
if(LLVM_LINK_LLVM_DYLIB)
set(llvm_libs LLVM)
else()
set(llvm_libs ${LLVM_AVAILABLE_LIBS})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still want llvm_map_components_to_libnames here, otherwise it starts to pull in things like LibEdit. In the past we've also faced linking issues with LLVM_AVAILABLE_LIBS having some things out-of-order.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's true, I had to disable LibEdit on the LLVM command line. I'll try to reproduce the linker error then and see if I can find the component. Generally it shouldn't be an issue to link to all LLVM libraries, unused things are ignored. I've been using this since LLVM 10 without issues related to out-of-order linking.

endif()

message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
Expand Down Expand Up @@ -85,15 +80,16 @@ find_package(XED CONFIG REQUIRED)
find_package(glog CONFIG REQUIRED)

# Google gflags
set(GFLAGS_USE_TARGET_NAMESPACE ON)
find_package(gflags CONFIG REQUIRED)

set(sleigh_ENABLE_TESTS OFF)
set(sleigh_ADDITIONAL_PATCHES "${CMAKE_CURRENT_SOURCE_DIR}/patches/sleigh/x86-ia.patch;${CMAKE_CURRENT_SOURCE_DIR}/patches/sleigh/arm-thumb.patch" CACHE STRING "" FORCE)

# GHIDRA SLEIGH
FetchContent_Declare(sleigh
GIT_REPOSITORY https://github.com/lifting-bits/sleigh.git
GIT_TAG 9966017ca00fd910f7a27e62c1024c768fad5d51
GIT_REPOSITORY https://github.com/mrexodia/sleigh.git
GIT_TAG patch-author-9966017c
)

set(sleigh_BUILD_SUPPORT ON CACHE BOOL "" FORCE)
Expand Down Expand Up @@ -122,10 +118,10 @@ option(REMILL_BUILD_SPARC32_RUNTIME "Build the Runtime for SPARC32. Turn this of

# add everything as public.
add_library(remill_settings INTERFACE)

target_include_directories(remill_settings INTERFACE
$<BUILD_INTERFACE:${REMILL_INCLUDE_DIR}>
$<INSTALL_INTERFACE:include>)
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${LLVM_INCLUDE_DIR}>)

if(WIN32)
# warnings and compiler settings
Expand Down