Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incompatibility issues with manylinux1 platform #320

Merged
merged 2 commits into from
May 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmake/CompilerHelper.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# minimal check for c++11 compliant gnu compiler
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
if(NOT (GCC_VERSION VERSION_GREATER 4.9 OR GCC_VERSION VERSION_EQUAL 4.9))
message(FATAL_ERROR "${PROJECT_NAME} requires g++ >= 4.9 (for c++11 support)")
if(NOT (GCC_VERSION VERSION_GREATER 4.8.2 OR GCC_VERSION VERSION_EQUAL 4.8.2))
message(FATAL_ERROR "${PROJECT_NAME} requires g++ >= 4.8.2 (for C++11 support)")
endif()
endif()

Expand Down
2 changes: 1 addition & 1 deletion ext/json/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ SOFTWARE.
#error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers"
#endif
#elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))
#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40900
#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40802
#error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers"
#endif
#endif
Expand Down
21 changes: 13 additions & 8 deletions src/language/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,36 +245,41 @@ def get_add_methods(self):
* \\brief Erase member to {self.varname}
*/
{self.class_name}Vector::const_iterator erase_{to_snake_case(self.class_name)}({self.class_name}Vector::const_iterator first) {{
return {self.varname}.erase(first);
auto first_it = const_iter_cast({self.varname}, first);
return {self.varname}.erase(first_it);
}}
/**
* \\brief Erase members to {self.varname}
*/
{self.class_name}Vector::const_iterator erase_{to_snake_case(self.class_name)}({self.class_name}Vector::const_iterator first, {self.class_name}Vector::const_iterator last) {{
return {self.varname}.erase(first, last);
auto first_it = const_iter_cast({self.varname}, first);
auto last_it = const_iter_cast({self.varname}, last);
return {self.varname}.erase(first_it, last_it);
}}

/**
* \\brief Insert member to {self.varname}
*/
{self.class_name}Vector::const_iterator insert_{to_snake_case(self.class_name)}({self.class_name}Vector::const_iterator position, const std::shared_ptr<{self.class_name}>& n) {{
{set_parent}

return {self.varname}.insert(position, n);
auto pos_it = const_iter_cast({self.varname}, position);
return {self.varname}.insert(pos_it, n);
}}
/**
* \\brief Insert members to {self.varname}
*/
template <class InputIterator>
void insert_{to_snake_case(self.class_name)}({self.class_name}Vector::const_iterator position, InputIterator first, InputIterator last) {{
template <class NodeType, class InputIterator>
void insert_{to_snake_case(self.class_name)}({self.class_name}Vector::const_iterator position, NodeType& to, InputIterator first, InputIterator last) {{

for (auto it = first; it != last; ++it) {{
auto& n = *it;
//set parents
{set_parent}
}}

{self.varname}.insert(position, first, last);
auto pos_it = const_iter_cast({self.varname}, position);
auto first_it = const_iter_cast(to, first);
auto last_it = const_iter_cast(to, last);
{self.varname}.insert(pos_it, first_it, last_it);
}}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/language/templates/ast/ast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
{% if node.is_abstract %} virtual {% endif %}
{% endmacro %}



using nmodl::utils::const_iter_cast;

namespace nmodl {
namespace ast {
Expand Down
2 changes: 1 addition & 1 deletion src/language/templates/pybind/pyast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ static const char* eval_method = R"(
namespace py = pybind11;
using namespace nmodl::ast;
using nmodl::visitor::JSONVisitor;
using pybind11::literals::operator""_a;
using namespace pybind11::literals;


void init_ast_module(py::module& m) {
Expand Down
2 changes: 1 addition & 1 deletion src/language/templates/pybind/pysymtab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static const char* symtabvisitor_class = R"(


namespace py = pybind11;
using pybind11::literals::operator""_a;
using namespace pybind11::literals;

using namespace nmodl;
using namespace symtab;
Expand Down
2 changes: 1 addition & 1 deletion src/language/templates/pybind/pyvisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static const char* sympy_solver_visitor_class = R"(
} // namespace nmodl


using pybind11::literals::operator""_a;
using namespace pybind11::literals;
namespace py = pybind11;


Expand Down
2 changes: 1 addition & 1 deletion src/pybind/pynmodl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@


namespace py = pybind11;
using pybind11::literals::operator""_a;
using namespace pybind11::literals;


namespace nmodl {
Expand Down
26 changes: 26 additions & 0 deletions src/utils/common_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,32 @@ T remove_extension(T const& filename) {
return p > 0 && p != T::npos ? filename.substr(0, p) : filename;
}

/**
* Return non-const iterator corresponding to the const_iterator in a vector
*
* Some old compilers like GCC v4.8.2 has C++11 support but missing erase and insert
* with const_iterator implementation. This is a workaround to handle build issues with
* such compilers especially on manylnux1 platform.
*
* See bug report : https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57158
*
* \todo Remove this after move to manylinux2010 platform.
*/
#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40900
template<typename T>
typename std::vector<T>::iterator
const_iter_cast(std::vector<T>& v, typename std::vector<T>::const_iterator iter) {
return v.begin() + (iter - v.cbegin());
}
#else
pramodk marked this conversation as resolved.
Show resolved Hide resolved
template<typename T>
typename std::vector<T>::const_iterator
const_iter_cast(const std::vector<T>& /*v*/, typename std::vector<T>::const_iterator iter) {
return iter;
}
#endif


/// Given directory path, create sub-directories
bool make_path(const std::string& path);

Expand Down
2 changes: 1 addition & 1 deletion src/visitors/inline_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ void InlineVisitor::visit_statement_block(StatementBlock& node) {
for (auto& element: inlined_statements) {
auto it = std::find(statements.begin(), statements.end(), element.first);
if (it != statements.end()) {
node.insert_statement(it, element.second.begin(), element.second.end());
node.insert_statement(it, element.second, element.second.begin(), element.second.end());
element.second.clear();
}
}
Expand Down