Use system compiler to build (#516)

* Don't use vcpkg clang to build remill in build script

* Don't manually set compiler within CMakeLists.txt & Fix ccache detection

* Simplify ccache usage

Don't use a macro since we just immediately invoke it

* Turn on CMAKE_ENABLE_EXPORTS to fix tests

Not sure exactly why the updated CMake version affected this, but it
did.

See https://cmake.org/cmake/help/latest/variable/CMAKE_ENABLE_EXPORTS.html#variable:CMAKE_ENABLE_EXPORTS

* Bump number of build jobs in Dockerfile
This commit is contained in:
Eric Kilmer
2021-05-17 15:13:17 -04:00
committed by GitHub
parent 76f3725f79
commit 1b415d616b
5 changed files with 24 additions and 93 deletions
+9 -7
View File
@@ -12,22 +12,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.14)
include(cmake/vcpkg_helper.cmake)
project(remill)
cmake_minimum_required(VERSION 3.14)
# Setup to use ccache
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/ccache.cmake")
project(remill C CXX ASM)
include(GNUInstallDirs)
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/settings.cmake")
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/utils.cmake")
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/ccache.cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
include(CTest)
configureCcache()
FindAndSelectClangCompiler()
enable_language(C CXX ASM)
set(REMILL_SOURCE_DIR "${PROJECT_SOURCE_DIR}")
@@ -322,6 +320,10 @@ install(EXPORT remillTargets
# tests
message("compiler ID ${CMAKE_C_COMPILER_ID}")
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")
# 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)
+3 -3
View File
@@ -28,7 +28,7 @@ RUN apt-get update && \
FROM deps as build
ARG LLVM_VERSION
WORKDIR /rellic
WORKDIR /remill
COPY ./ ./
RUN ./scripts/build.sh \
--llvm-version ${LLVM_VERSION} \
@@ -36,8 +36,8 @@ RUN ./scripts/build.sh \
--extra-cmake-args "-DCMAKE_BUILD_TYPE=Release"
RUN cd remill-build && \
cmake --build . --target test_dependencies && \
CTEST_OUTPUT_ON_FAILURE=1 cmake --build . --verbose --target test && \
cmake --build . --target test_dependencies -- -j $(nproc) && \
CTEST_OUTPUT_ON_FAILURE=1 cmake --build . --verbose --target test -- -j $(nproc) && \
cmake --build . --target install
# Small installation image
+12 -23
View File
@@ -12,28 +12,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.4)
find_program(ccache_path ccache)
if("${ccache_path}" STREQUAL "ccache_path-NOTFOUND")
message(STATUS "ccache: Not found")
else()
set(CMAKE_C_COMPILER_LAUNCHER "${ccache_path}")
set(CMAKE_CXX_COMPILER_LAUNCHER "${ccache_path}")
macro(configureCcache)
if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" AND
NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
message(STATUS "ccache: Not supported")
else()
find_program(ccache_path ccache)
if("${ccache_path}" STREQUAL "ccache_path-NOTFOUND")
message(STATUS "ccache: Not found")
else()
set(CMAKE_C_COMPILER_LAUNCHER "${ccache_path}")
set(CMAKE_CXX_COMPILER_LAUNCHER "${ccache_path}")
set(ccache_dir "$ENV{CCACHE_DIR}")
if("${ccache_dir}" STREQUAL "")
set(ccache_dir "$ENV{HOME}/.ccache")
endif()
message(STATUS "ccache: enabled with '${ccache_path}'. The cache folder is located here: '${ccache_dir}'")
endif()
set(ccache_dir "$ENV{CCACHE_DIR}")
if("${ccache_dir}" STREQUAL "")
set(ccache_dir "$ENV{HOME}/.ccache")
endif()
endmacro()
message(STATUS "ccache: enabled with '${ccache_path}'. The cache folder is located here: '${ccache_dir}'")
endif()
-58
View File
@@ -1,63 +1,5 @@
cmake_minimum_required(VERSION 3.2)
function(FindAndSelectClangCompiler)
if(DEFINED ENV{LLVM_INSTALL_PREFIX})
set(LLVM_INSTALL_PREFIX $ENV{LLVM_INSTALL_PREFIX} PARENT_SCOPE)
endif()
if(DEFINED LLVM_INSTALL_PREFIX)
list(APPEND FINDPACKAGE_LLVM_HINTS "${LLVM_INSTALL_PREFIX}/lib/cmake/llvm/")
list(APPEND FINDPACKAGE_LLVM_HINTS "${LLVM_INSTALL_PREFIX}/share/llvm/cmake/")
set(FINDPACKAGE_LLVM_HINTS ${FINDPACKAGE_LLVM_HINTS} PARENT_SCOPE)
message(STATUS "Using LLVM_INSTALL_PREFIX hints for find_package(LLVM): ${FINDPACKAGE_LLVM_HINTS}")
endif()
if(DEFINED WIN32)
set(executable_extension ".exe")
else()
set(executable_extension "")
endif()
# it is important to avoid re-defining these variables if they have been already
# set or you risk ending up in a configure loop!
if(NOT DEFINED CMAKE_C_COMPILER)
if(DEFINED LLVM_INSTALL_PREFIX)
set(CMAKE_C_COMPILER "${LLVM_INSTALL_PREFIX}/bin/clang${executable_extension}"
CACHE PATH "Path to clang binary." FORCE)
else()
set(CMAKE_C_COMPILER "clang" PARENT_SCOPE)
endif()
endif()
if(NOT DEFINED CMAKE_CXX_COMPILER)
if(DEFINED LLVM_INSTALL_PREFIX)
set(CMAKE_CXX_COMPILER "${LLVM_INSTALL_PREFIX}/bin/clang++${executable_extension}"
CACHE PATH "Path to clang++ binary." FORCE)
else()
set(CMAKE_CXX_COMPILER "clang++${executable_extension}" PARENT_SCOPE)
endif()
endif()
if(NOT DEFINED CMAKE_ASM_COMPILER)
if(DEFINED LLVM_INSTALL_PREFIX)
set(CMAKE_ASM_COMPILER "${LLVM_INSTALL_PREFIX}/bin/clang++${executable_extension}"
CACHE PATH "Path to assembler (aka clang) binary." FORCE)
else()
set(CMAKE_ASM_COMPILER ${CMAKE_CXX_COMPILER} PARENT_SCOPE)
endif()
endif()
if(NOT DEFINED CMAKE_LLVM_LINK)
if(DEFINED LLVM_INSTALL_PREFIX)
set(CMAKE_LLVM_LINK "${LLVM_INSTALL_PREFIX}/bin/llvm-link${executable_extension}"
CACHE PATH "Path to llvm-link binary." FORCE)
else()
set(CMAKE_LLVM_LINK "llvm-link${executable_extension}" PARENT_SCOPE)
endif()
endif()
endfunction()
function(GetTargetTree output_variable)
if(${ARGC} LESS 1)
message(FATAL_ERROR "Usage: GetTargetTree output_var target1 target2 ...")
-2
View File
@@ -233,8 +233,6 @@ function Configure
cmake \
-DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
-DCMAKE_VERBOSE_MAKEFILE=True \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DVCPKG_ROOT="${DOWNLOAD_DIR}/${LIBRARY_VERSION}" \
${BUILD_FLAGS} \
"${SRC_DIR}"