Browse Source

Set EVM JIT version in cmake script.

cl-refactor
Paweł Bylica 10 years ago
parent
commit
d3831c8b1d
  1. 5
      CMakeLists.txt
  2. 2
      libevmjit/BuildInfo.h.in
  3. 33
      libevmjit/CMakeLists.txt
  4. 17
      libevmjit/Cache.cpp
  5. 6
      libevmjit/JIT.cpp

5
CMakeLists.txt

@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 2.8.12) cmake_minimum_required(VERSION 3.0)
cmake_policy(SET CMP0048 NEW) # allow VERSION argument in project()
project(evmjit) project(EVMJIT VERSION 0.9.0 LANGUAGES CXX)
set_property(GLOBAL PROPERTY USE_FOLDERS ON) set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_AUTOMOC OFF) set(CMAKE_AUTOMOC OFF)

2
libevmjit/BuildInfo.h.in

@ -3,8 +3,6 @@
#define EVMJIT_VERSION_MAJOR ${EVMJIT_VERSION_MAJOR} #define EVMJIT_VERSION_MAJOR ${EVMJIT_VERSION_MAJOR}
#define EVMJIT_VERSION_MINOR ${EVMJIT_VERSION_MINOR} #define EVMJIT_VERSION_MINOR ${EVMJIT_VERSION_MINOR}
#define EVMJIT_VERSION_PATCH ${EVMJIT_VERSION_PATCH} #define EVMJIT_VERSION_PATCH ${EVMJIT_VERSION_PATCH}
#define EVMJIT_VERSION_PRERELEASE "${EVMJIT_VERSION_PRERELEASE}"
#define EVMJIT_VERSION_FULL "${EVMJIT_VERSION_FULL}"
#define LLVM_VERSION "${LLVM_PACKAGE_VERSION}" #define LLVM_VERSION "${LLVM_PACKAGE_VERSION}"
#define LLVM_ASSERTIONS "${LLVM_ENABLE_ASSERTIONS}" #define LLVM_ASSERTIONS "${LLVM_ENABLE_ASSERTIONS}"

33
libevmjit/CMakeLists.txt

@ -29,37 +29,6 @@ else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
endif() endif()
set(EVMJIT_VERSION "0.0.0")
set(EVMJIT_VERSION_MAJOR 0)
set(EVMJIT_VERSION_MINOR 0)
set(EVMJIT_VERSION_PATCH 0)
set(EVMJIT_VERSION_FULL "v0.0.0-nogit")
find_package(Git)
if(GIT_FOUND)
execute_process(COMMAND ${GIT_EXECUTABLE} -C ${CMAKE_CURRENT_SOURCE_DIR} describe --dirty --always --match v*
OUTPUT_VARIABLE EVMJIT_VERSION_FULL OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
if(${EVMJIT_VERSION_FULL} MATCHES "^v[0-9]+\\.[0-9]+")
string(SUBSTRING ${EVMJIT_VERSION_FULL} 1 -1 EVMJIT_VERSION_FULL) # skip "v"
string(REPLACE "-" ";" VERSION_COMPONENTS ${EVMJIT_VERSION_FULL})
list(LENGTH VERSION_COMPONENTS NUM_VERSION_COMPONENTS)
list(GET VERSION_COMPONENTS 0 EVMJIT_VERSION)
string(REPLACE "." ";" VERSION_NUMBERS ${EVMJIT_VERSION})
list(LENGTH VERSION_NUMBERS NUM_VERSION_NUMBERS)
list(GET VERSION_NUMBERS 0 EVMJIT_VERSION_MAJOR)
list(GET VERSION_NUMBERS 1 EVMJIT_VERSION_MINOR)
if(${NUM_VERSION_NUMBERS} GREATER 2)
list(GET VERSION_NUMBERS 2 EVMJIT_VERSION_PATCH) # patch number is optional
endif()
if(${NUM_VERSION_COMPONENTS} GREATER 1)
list(GET VERSION_COMPONENTS 1 VERSION_PRERELEASE_CANDIDATE)
string(REGEX MATCH "^[a-zA-Z]+.*" EVMJIT_VERSION_PRERELEASE ${VERSION_PRERELEASE_CANDIDATE}) # prerelease starts with letter
endif()
endif()
if(${EVMJIT_VERSION_MAJOR} EQUAL 0) if(${EVMJIT_VERSION_MAJOR} EQUAL 0)
set(EVMJIT_SOVERSION "0.${EVMJIT_VERSION_MINOR}") set(EVMJIT_SOVERSION "0.${EVMJIT_VERSION_MINOR}")
else() else()
@ -70,7 +39,7 @@ endif()
string(COMPARE EQUAL "${LLVM_ENABLE_ASSERTIONS}" "ON" LLVM_DEBUG) string(COMPARE EQUAL "${LLVM_ENABLE_ASSERTIONS}" "ON" LLVM_DEBUG)
configure_file(BuildInfo.h.in ${CMAKE_CURRENT_BINARY_DIR}/gen/BuildInfo.gen.h) configure_file(BuildInfo.h.in ${CMAKE_CURRENT_BINARY_DIR}/gen/BuildInfo.gen.h)
message(STATUS "EVM JIT version: ${EVMJIT_VERSION_MAJOR}.${EVMJIT_VERSION_MINOR}.${EVMJIT_VERSION_PATCH} ${EVMJIT_VERSION_PRERELEASE} (${EVMJIT_VERSION_FULL})") message(STATUS "EVM JIT version: ${EVMJIT_VERSION_MAJOR}.${EVMJIT_VERSION_MINOR}.${EVMJIT_VERSION_PATCH}")
add_library(${TARGET_NAME} SHARED ${SOURCES} gen/BuildInfo.gen.h) add_library(${TARGET_NAME} SHARED ${SOURCES} gen/BuildInfo.gen.h)
set_target_properties(${TARGET_NAME} PROPERTIES set_target_properties(${TARGET_NAME} PROPERTIES

17
libevmjit/Cache.cpp

@ -28,17 +28,10 @@ namespace
CacheMode g_mode; CacheMode g_mode;
std::unique_ptr<llvm::MemoryBuffer> g_lastObject; std::unique_ptr<llvm::MemoryBuffer> g_lastObject;
JITListener* g_listener; JITListener* g_listener;
static const size_t c_versionStampLength = 32;
llvm::StringRef getLibVersionStamp() llvm::StringRef getLibVersionStamp()
{ {
static auto version = llvm::SmallString<c_versionStampLength>{}; return EVMJIT_VERSION;
if (version.empty())
{
version = EVMJIT_VERSION_FULL;
version.resize(c_versionStampLength);
}
return version;
} }
} }
@ -130,11 +123,13 @@ std::unique_ptr<llvm::Module> Cache::getObject(std::string const& id)
if (auto r = llvm::MemoryBuffer::getFile(cachePath.str(), -1, false)) if (auto r = llvm::MemoryBuffer::getFile(cachePath.str(), -1, false))
{ {
auto& buf = r.get(); auto& buf = r.get();
auto objVersionStamp = buf->getBufferSize() >= c_versionStampLength ? llvm::StringRef{buf->getBufferEnd() - c_versionStampLength, c_versionStampLength} : llvm::StringRef{}; auto expectedStamp = getLibVersionStamp();
if (objVersionStamp == getLibVersionStamp()) auto stampSize = expectedStamp.size();
auto objStamp = buf->getBufferSize() >= stampSize ? llvm::StringRef{buf->getBufferEnd() - stampSize, stampSize} : llvm::StringRef{};
if (objStamp == expectedStamp)
g_lastObject = llvm::MemoryBuffer::getMemBufferCopy(r.get()->getBuffer()); g_lastObject = llvm::MemoryBuffer::getMemBufferCopy(r.get()->getBuffer());
else else
DLOG(cache) << "Unmatched version: " << objVersionStamp.str() << ", expected " << getLibVersionStamp().str() << "\n"; DLOG(cache) << "Unmatched version: " << objStamp.str() << ", expected " << expectedStamp.str() << "\n";
} }
else if (r.getError() != std::make_error_code(std::errc::no_such_file_or_directory)) else if (r.getError() != std::make_error_code(std::errc::no_such_file_or_directory))
DLOG(cache) << r.getError().message(); // TODO: Add warning log DLOG(cache) << r.getError().message(); // TODO: Add warning log

6
libevmjit/JIT.cpp

@ -51,11 +51,11 @@ void printVersion()
std::cout << "Ethereum EVM JIT Compiler (http://github.com/ethereum/evmjit):\n" std::cout << "Ethereum EVM JIT Compiler (http://github.com/ethereum/evmjit):\n"
<< " EVMJIT version " << EVMJIT_VERSION << "\n" << " EVMJIT version " << EVMJIT_VERSION << "\n"
#ifdef NDEBUG #ifdef NDEBUG
<< " Optimized build, " EVMJIT_VERSION_FULL "\n" << " Optimized build, "
#else #else
<< " DEBUG build, " EVMJIT_VERSION_FULL "\n" << " DEBUG build, "
#endif #endif
<< " Built " << __DATE__ << " (" << __TIME__ << ")\n" << __DATE__ << " (" << __TIME__ << ")\n"
<< std::endl; << std::endl;
} }

Loading…
Cancel
Save