From 48d0feb983232250b42785c04fc87251d436f4d3 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Mon, 19 Dec 2016 11:49:41 +0000 Subject: [CMake] Fix linker warning about mixed linking modes when LLVM was built with `-fvisibility-inlines-hidden`. This was observed when using a bottled version of LLVM 3.4 on macOS that appears to have been built with this option. --- CMakeLists.txt | 5 +++++ cmake/find_llvm.cmake | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2dc2cc2f..e860f3e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -194,6 +194,7 @@ set(NEEDED_LLVM_VARS LLVM_INCLUDE_DIRS LLVM_LIBRARY_DIRS LLVM_TOOLS_BINARY_DIR + LLVM_ENABLE_VISIBILITY_INLINES_HIDDEN TARGET_TRIPLE ) @@ -211,6 +212,10 @@ else() unset(ENABLE_KLEE_DEBUG) # for config.h endif() +if (LLVM_ENABLE_VISIBILITY_INLINES_HIDDEN) + list(APPEND KLEE_COMPONENT_CXX_FLAGS "-fvisibility-inlines-hidden") +endif() + list(APPEND KLEE_COMPONENT_CXX_DEFINES ${LLVM_DEFINITIONS}) list(APPEND KLEE_COMPONENT_EXTRA_INCLUDE_DIRS ${LLVM_INCLUDE_DIRS}) diff --git a/cmake/find_llvm.cmake b/cmake/find_llvm.cmake index 53b2b392..0df6b4b5 100644 --- a/cmake/find_llvm.cmake +++ b/cmake/find_llvm.cmake @@ -33,6 +33,8 @@ if (USE_CMAKE_FIND_PACKAGE_LLVM) endif() set(${output_var} ${${output_var}} PARENT_SCOPE) endfunction() + # HACK: This information is not exported so just pretend its OFF for now. + set(LLVM_ENABLE_VISIBILITY_INLINES_HIDDEN OFF) else() # Use the llvm-config binary to get the information needed. # Try to detect it in the user's environment. The user can @@ -116,6 +118,7 @@ else() set(LLVM_ENABLE_ASSERTIONS ON) set(LLVM_ENABLE_EH ON) set(LLVM_ENABLE_RTTI ON) + set(LLVM_ENABLE_VISIBILITY_INLINES_HIDDEN OFF) _run_llvm_config(_llvm_cxx_flags "--cxxflags") string_to_list("${_llvm_cxx_flags}" _llvm_cxx_flags_list) foreach (flag ${_llvm_cxx_flags_list}) @@ -127,6 +130,8 @@ else() set(LLVM_ENABLE_EH OFF) elseif ("${flag}" STREQUAL "-fno-rtti") set(LLVM_ENABLE_RTTI OFF) + elseif ("${flag}" STREQUAL "-fvisibility-inlines-hidden") + set(LLVM_ENABLE_VISIBILITY_INLINES_HIDDEN ON) endif() endforeach() -- cgit 1.4.1 From 339b87f9da680e93e7e38b1522486953a3ff3a4f Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Mon, 19 Dec 2016 12:08:36 +0000 Subject: Fix -Wformat warnings emitted by Apple Clang (800.0.42.1). --- lib/Core/MemoryManager.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/Core/MemoryManager.cpp b/lib/Core/MemoryManager.cpp index f9f4b105..24e2ed97 100644 --- a/lib/Core/MemoryManager.cpp +++ b/lib/Core/MemoryManager.cpp @@ -17,7 +17,9 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/MathExtras.h" +#include #include + using namespace klee; namespace { @@ -94,7 +96,8 @@ MemoryObject *MemoryManager::allocate(uint64_t size, bool isLocal, const llvm::Value *allocSite, size_t alignment) { if (size > 10 * 1024 * 1024) - klee_warning_once(0, "Large alloc: %lu bytes. KLEE may run out of memory.", + klee_warning_once(0, "Large alloc: %" PRIu64 + " bytes. KLEE may run out of memory.", size); // Return NULL if size is zero, this is equal to error during allocation @@ -118,10 +121,9 @@ MemoryObject *MemoryManager::allocate(uint64_t size, bool isLocal, if ((char *)address + alloc_size < deterministicSpace + spaceSize) { nextFreeSlot = (char *)address + alloc_size + RedZoneSpace; } else { - klee_warning_once( - 0, - "Couldn't allocate %lu bytes. Not enough deterministic space left.", - size); + klee_warning_once(0, "Couldn't allocate %" PRIu64 + " bytes. Not enough deterministic space left.", + size); address = 0; } } else { -- cgit 1.4.1