Skip to content

Commit

Permalink
Some fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ekpyron committed Dec 3, 2020
1 parent f68f15e commit d24302a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
15 changes: 12 additions & 3 deletions libsmtutil/z3/Z3Loader.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <Z3Loader.h>
#include <stdexcept>
#include <z3.h>
#include <z3_version.h>
#include <iostream>

Z3Loader const& Z3Loader::get()
{
Expand All @@ -26,13 +28,20 @@ bool Z3Loader::available() const
unsigned build = 0;
unsigned rev = 0;
Z3_get_version(&major, &minor, &build, &rev);
return (major > 4 || (major == 4 && minor >= 6));
if (major != Z3_MAJOR_VERSION || minor != Z3_MINOR_VERSION || build != Z3_BUILD_NUMBER || rev != Z3_REVISION_NUMBER)
// TODO: proper warning, etc. - this function should probably return a BoolResult or something similar.
std::cerr << "Warning: solidity was build against Z3 "
<< Z3_MAJOR_VERSION << "." << Z3_MINOR_VERSION << "." << Z3_BUILD_NUMBER << "." << Z3_REVISION_NUMBER
<< " but version " << major << "." << minor << "." << build << "." << rev << " was found. Use at your own risk."
<< std::endl;
return (major == 4 && minor >= 6);
}

Z3Loader::Z3Loader(): m_handle(dlmopen(LM_ID_NEWLM, "libz3.so", RTLD_NOW))
Z3Loader::Z3Loader(): m_handle(dlmopen(LM_ID_NEWLM, "libz3.so.4", RTLD_NOW))
{
}
Z3Loader::~Z3Loader()
{
dlclose(m_handle);
if (m_handle)
dlclose(m_handle);
}
4 changes: 2 additions & 2 deletions libsolidity/formal/CHC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ CHC::CHC(
m_enabledSolvers(_enabledSolvers),
m_queryTimeout(_timeout)
{
bool usesZ3 = _enabledSolvers.z3;
bool usesZ3 = _enabledSolvers.z3 && Z3Interface::available();
#ifndef HAVE_Z3
usesZ3 = false;
#endif
Expand Down Expand Up @@ -734,7 +734,7 @@ void CHC::resetSourceAnalysis()

bool usesZ3 = false;
#ifdef HAVE_Z3
usesZ3 = m_enabledSolvers.z3;
usesZ3 = m_enabledSolvers.z3 && Z3Interface::available();
if (usesZ3)
{
/// z3::fixedpoint does not have a reset mechanism, so we need to create another.
Expand Down

0 comments on commit d24302a

Please sign in to comment.