-
Notifications
You must be signed in to change notification settings - Fork 145
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 clang 16.0.4 Compilation on Windows #678
base: master
Are you sure you want to change the base?
Changes from all commits
0abfc3b
e3a96b6
9787935
c9bda60
cd24f89
f7548e7
988c9d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,8 @@ include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/utils.cmake") | |
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/options.cmake") | ||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") | ||
|
||
set(REMILL_ENABLE_TESTING OFF) | ||
|
||
if(REMILL_ENABLE_TESTING) | ||
include(CTest) | ||
endif() | ||
|
@@ -40,22 +42,44 @@ 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 | ||
aarch64info aarch64desc aarch64codegen aarch64asmparser | ||
armcodegen armasmparser | ||
interpreter mcjit | ||
nvptxdesc | ||
x86info x86codegen x86asmparser | ||
sparccodegen sparcasmparser | ||
webassemblydesc) | ||
# https://github.com/JonathanSalwan/Triton/issues/1082#issuecomment-1030826696 | ||
if(LLVM_LINK_LLVM_DYLIB) | ||
set(llvm_libs LLVM) | ||
else() | ||
llvm_map_components_to_libnames(llvm_libs | ||
support | ||
core | ||
irreader | ||
bitreader | ||
bitwriter | ||
passes | ||
asmprinter | ||
aarch64info | ||
aarch64desc | ||
aarch64codegen | ||
aarch64asmparser | ||
armcodegen | ||
armasmparser | ||
HipStdPar | ||
CodeGenTypes | ||
interpreter | ||
mcjit | ||
FrontendOffloading | ||
nvptxdesc | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @2over12 thoughts on removing nvptx and wasm from cxx-common? |
||
x86info | ||
x86codegen | ||
x86asmparser | ||
sparccodegen | ||
sparcasmparser | ||
webassemblydesc) | ||
endif() | ||
message(STATUS "LLVM Libraries: ${llvm_libs}") | ||
|
||
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") | ||
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") | ||
|
||
include_directories(SYSTEM ${LLVM_INCLUDE_DIRS}) | ||
|
||
string(REPLACE "." ";" LLVM_VERSION_LIST ${LLVM_PACKAGE_VERSION}) | ||
list(GET LLVM_VERSION_LIST 0 LLVM_MAJOR_VERSION) | ||
list(GET LLVM_VERSION_LIST 1 LLVM_MINOR_VERSION) | ||
|
@@ -85,6 +109,7 @@ 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) | ||
|
@@ -94,6 +119,17 @@ file(GLOB sleigh_patches "${CMAKE_CURRENT_SOURCE_DIR}/patches/sleigh/*.patch") | |
|
||
set(sleigh_ADDITIONAL_PATCHES "${sleigh_patches}" CACHE STRING "" FORCE) | ||
|
||
if(WIN32) | ||
# In one of the sleigh headers they use std::byte without the std namespace prefix. | ||
# This then causes a windows compilation failure, because of a conflicting definition | ||
# of 'byte' in one of the windows SDK headers. So as a fix we must append | ||
# _HAS_STD_BYTE to the compile definitions. | ||
add_compile_definitions(_HAS_STD_BYTE=0) | ||
# In another sleigh source file, there is an implicit narrowing conversion. | ||
# This flag allows implicit narrowing. | ||
add_compile_options ( -Xclang -Wno-narrowing) | ||
endif() | ||
|
||
# GHIDRA SLEIGH | ||
FetchContent_Declare(sleigh | ||
GIT_REPOSITORY https://github.com/lifting-bits/sleigh.git | ||
|
@@ -131,7 +167,9 @@ add_library(remill_settings INTERFACE) | |
|
||
target_include_directories(remill_settings INTERFACE | ||
$<BUILD_INTERFACE:${REMILL_INCLUDE_DIR}> | ||
$<INSTALL_INTERFACE:include>) | ||
$<INSTALL_INTERFACE:include> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there should be a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
$<BUILD_INTERFACE:${LLVM_INCLUDE_DIR}> | ||
) | ||
|
||
if(WIN32) | ||
# warnings and compiler settings | ||
|
@@ -203,7 +241,7 @@ else() | |
endif() | ||
|
||
target_compile_definitions(remill_settings INTERFACE | ||
"REMILL_INSTALL_SEMANTICS_DIR=\"${REMILL_INSTALL_SEMANTICS_DIR}\"" | ||
"REMILL_INSTALL_SEMANTICS_DIR=\"semantics\"" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you explain this? |
||
"REMILL_BUILD_SEMANTICS_DIR_X86=\"${REMILL_BUILD_SEMANTICS_DIR_X86}\"" | ||
"REMILL_BUILD_SEMANTICS_DIR_AARCH32=\"${REMILL_BUILD_SEMANTICS_DIR_AARCH32}\"" | ||
"REMILL_BUILD_SEMANTICS_DIR_AARCH64=\"${REMILL_BUILD_SEMANTICS_DIR_AARCH64}\"" | ||
|
@@ -279,6 +317,10 @@ target_link_libraries(remill INTERFACE | |
${LINKER_END_GROUP} | ||
) | ||
|
||
if(WIN32) | ||
target_link_libraries(remill INTERFACE Ws2_32.lib) | ||
endif() | ||
|
||
# | ||
# Also install clang, libllvm and llvm-link | ||
# | ||
|
@@ -325,33 +367,3 @@ if(REMILL_ENABLE_INSTALL_TARGET) | |
install(EXPORT remillTargets | ||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/remill") | ||
endif() | ||
|
||
# tests | ||
if(REMILL_ENABLE_TESTING) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you explain why this is deleted? |
||
# Tests require enabling exports on binaries | ||
# https://cmake.org/cmake/help/latest/variable/CMAKE_ENABLE_EXPORTS.html#variable:CMAKE_ENABLE_EXPORTS | ||
set(CMAKE_ENABLE_EXPORTS ON) | ||
|
||
find_package(Threads REQUIRED) | ||
add_custom_target(test_dependencies) | ||
|
||
if(REMILL_ENABLE_TESTING_SLEIGH_THUMB) | ||
message(STATUS "thumb tests enabled") | ||
add_subdirectory(tests/Thumb) | ||
endif() | ||
|
||
if(REMILL_ENABLE_TESTING_SLEIGH_PPC) | ||
message(STATUS "ppc tests enabled") | ||
add_subdirectory(tests/PPC) | ||
endif() | ||
|
||
if(REMILL_ENABLE_TESTING_X86) | ||
message(STATUS "X86 tests enabled") | ||
add_subdirectory(tests/X86) | ||
endif() | ||
|
||
if(REMILL_ENABLE_TESTING_AARCH64) | ||
message(STATUS "aarch64 tests enabled") | ||
add_subdirectory(tests/AArch64) | ||
endif() | ||
endif() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -352,7 +352,7 @@ int main(int argc, char *argv[]) { | |
arg_types.push_back(llvm::PointerType::get(context, 0)); | ||
} | ||
|
||
const auto state_type = llvm::PointerType::get(context, 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. |
||
const auto state_type = arch->StateStructType(); | ||
const auto func_type = | ||
llvm::FunctionType::get(mem_ptr_type, arg_types, false); | ||
const auto func = llvm::Function::Create( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ set(DEFAULT_BC_COMPILER_FLAGS | |
-ffreestanding -fno-common -fno-builtin -fno-exceptions -fno-rtti | ||
-fno-asynchronous-unwind-tables -Wno-unneeded-internal-declaration | ||
-Wno-unused-function -Wgnu-inline-cpp-without-extern | ||
-Wno-pass-failed=transform-warning | ||
-Wno-pass-failed=transform-warning -fshort-wchar -Xclang -mlong-double-80 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TIL about |
||
${EXTRA_BC_SYSROOT} | ||
) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,10 +134,10 @@ macro(RunGitCommand) | |
# Most methods have a fall-back default value that's used in case of non-zero | ||
# exit codes. If you're feeling risky, disable this safety check and use | ||
# those default values. | ||
if(GIT_FAIL_IF_NONZERO_EXIT ) | ||
string(REPLACE ";" " " args_with_spaces "${ARGV}") | ||
message(FATAL_ERROR "${stderr} (${GIT_EXECUTABLE} ${args_with_spaces})") | ||
endif() | ||
#if(GIT_FAIL_IF_NONZERO_EXIT ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add an option to |
||
# string(REPLACE ";" " " args_with_spaces "${ARGV}") | ||
# message(FATAL_ERROR "${stderr} (${GIT_EXECUTABLE} ${args_with_spaces})") | ||
#endif() | ||
endif() | ||
endmacro() | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
|
||
include(CMakeDependentOption) | ||
|
||
set(can_enable_testing TRUE) | ||
set(can_enable_testing FALSE) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? If this should be conditional on windows then make this an option rather than a |
||
set(can_enable_testing_x86 FALSE) | ||
set(can_enable_testing_aarch64 FALSE) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,7 +161,7 @@ function(InstallExternalTarget target_name target_path install_type installed_fi | |
|
||
install(FILES "${output_file_path}" | ||
TYPE ${install_type} | ||
PERMISSIONS OWNER_READ OWNER_EXECUTE | ||
PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? |
||
GROUP_READ GROUP_EXECUTE | ||
WORLD_READ WORLD_EXECUTE | ||
) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move to
cmake/options.cmake
.