From f5aa915f3f1a9e38d38b2714756997e0dc82375c Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 1 Feb 2018 17:05:58 +0000 Subject: [PATCH] Require explicit opt-in for interceptor-lib use, in case of local llvm * CMake can find the local LLVM even without specifying LLVM_DIR, but we don't want to build it for interceptor-lib unless it's exactly the one we want, so we ask for explicit opt-in. --- renderdoc/3rdparty/interceptor-lib/README.md | 4 ++-- renderdoc/CMakeLists.txt | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/renderdoc/3rdparty/interceptor-lib/README.md b/renderdoc/3rdparty/interceptor-lib/README.md index 7f0bea47d..8a8aa5ea4 100644 --- a/renderdoc/3rdparty/interceptor-lib/README.md +++ b/renderdoc/3rdparty/interceptor-lib/README.md @@ -10,7 +10,7 @@ See [LICENSE](LICENSE) file in this directory. # LLVM Build instructions -To use this in RenderDoc you must set `-DLLVM_DIR=/path/to/llvm` pointing to a compatible build of LLVM 4.0 for the target you are building. Below are instructions on how to build that compatible LLVM. +To use this in RenderDoc you must set `-DUSE_INTERCEPTOR_LIB=On -DLLVM_DIR=/path/to/llvm` pointing to a compatible build of LLVM 4.0 for the target you are building. Below are instructions on how to build that compatible LLVM. You'll need the Android NDK r16b, and you'll need python available in your path. @@ -70,4 +70,4 @@ cp ./lib/Target/ARM/ARM*.inc $TARGET_PATH/include/MCTargetDesc/ cp ./lib/Target/AArch64/AArch64*.inc $TARGET_PATH/include/MCTargetDesc/ ``` -Then you can set `-DLLVM_DIR=/path/to/llvm/install_armXX/lib/cmake/llvm` when building renderdoc and you should see a line saying that LLVM is being used to compile interceptor-lib! +Then you can set `-DUSE_INTERCEPTOR_LIB=On -DLLVM_DIR=/path/to/llvm/install_armXX/lib/cmake/llvm` when building renderdoc and you should see a line saying that LLVM is being used to compile interceptor-lib! diff --git a/renderdoc/CMakeLists.txt b/renderdoc/CMakeLists.txt index 203ffd4ad..4ca4a85c0 100644 --- a/renderdoc/CMakeLists.txt +++ b/renderdoc/CMakeLists.txt @@ -355,17 +355,18 @@ if(ENABLE_GL OR ENABLE_GLES OR ENABLE_VULKAN) list(APPEND renderdoc_objects $) endif() -find_package(LLVM CONFIG) - -set(HAVE_INTERCEPTOR_LIB OFF) +option(USE_INTERCEPTOR_LIB OFF) # on Android, pull in interceptor-lib only if we have LLVM available -if(ANDROID AND LLVM_FOUND) - if(${LLVM_PACKAGE_VERSION} VERSION_LESS "4.0.0" OR ${LLVM_PACKAGE_VERSION} VERSION_GREATER "4.0.1") - message(STATUS "LLVM ${LLVM_PACKAGE_VERSION} found - we require precisely 4.0.") +if(ANDROID AND USE_INTERCEPTOR_LIB ) + find_package(LLVM CONFIG) + + if(NOT LLVM_FOUND) + message(FATAL_ERROR "LLVM not found - interceptor-lib requires LLVM 4.0 available.") + elseif(${LLVM_PACKAGE_VERSION} VERSION_LESS "4.0.0" OR ${LLVM_PACKAGE_VERSION} VERSION_GREATER "4.0.1") + message(FATAL_ERROR "LLVM ${LLVM_PACKAGE_VERSION} found - we require precisely 4.0.") else() message(STATUS "LLVM ${LLVM_PACKAGE_VERSION} found - enabling android hooking using interceptor-lib.") - set(HAVE_INTERCEPTOR_LIB ON) add_subdirectory(3rdparty/interceptor-lib) list(APPEND renderdoc_objects $) link_directories(${LLVM_DIR}/../..) @@ -377,8 +378,8 @@ if(ANDROID AND LLVM_FOUND) endif() endif() -if(ANDROID AND NOT HAVE_INTERCEPTOR_LIB) - message(STATUS "LLVM not found - android hooking will use sometimes less reliable PLT-interception method.") +if(ANDROID AND NOT USE_INTERCEPTOR_LIB) + message(STATUS "Interceptor-lib not enabled (USE_INTERCEPTOR_LIB) - android hooking will use sometimes less reliable PLT-interception method. ") endif() # always pull in the amd folder