-
Notifications
You must be signed in to change notification settings - Fork 48
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
ProxQP on old Clang/GCC #253
Comments
I've tried, but there are many places where the code needs to be changed and at some point, I think those compilers are not fully compatible with C++14 or C++17. |
Looking closely at the issue, it seems to be a bug of clang-5 with respect to null pointer deferencing: note: read of dereferenced null pointer is not allowed in a constant expression |
Thanks a lot for the investigation so far. So I managed to update to Clang 7.1.0 and gcc 7.3.1 (that's the most that I can go). More specifically:
I am still getting errors like the following: In file included from proxsuite/examples/cpp/first_example_dense.cpp:7:
In file included from /workdir/proxsuite/build/install/lib/pkgconfig/../../include/proxsuite/proxqp/dense/dense.hpp:8:
In file included from /workdir/proxsuite/build/install/lib/pkgconfig/../../include/proxsuite/proxqp/dense/wrapper.hpp:10:
In file included from /workdir/proxsuite/build/install/lib/pkgconfig/../../include/proxsuite/proxqp/dense/solver.hpp:13:
In file included from /workdir/proxsuite/build/install/lib/pkgconfig/../../include/proxsuite/proxqp/dense/linesearch.hpp:9:
In file included from /workdir/proxsuite/build/install/lib/pkgconfig/../../include/proxsuite/proxqp/dense/model.hpp:11:
In file included from /workdir/proxsuite/build/install/lib/pkgconfig/../../include/proxsuite/proxqp/sparse/model.hpp:9:
In file included from /workdir/proxsuite/build/install/lib/pkgconfig/../../include/proxsuite/linalg/sparse/core.hpp:9:
In file included from /workdir/proxsuite/build/install/lib/pkgconfig/../../include/proxsuite/linalg/veg/memory/dynamic_stack.hpp:6:
In file included from /workdir/proxsuite/build/install/lib/pkgconfig/../../include/proxsuite/linalg/veg/internal/collection_algo.hpp:4:
In file included from /workdir/proxsuite/build/install/lib/pkgconfig/../../include/proxsuite/linalg/veg/memory/alloc.hpp:10:
/workdir/proxsuite/build/install/lib/pkgconfig/../../include/proxsuite/linalg/veg/memory/placement.hpp:63:35: error: no member named 'launder' in namespace 'std'
const VEG_NOEXCEPT->T* { return VEG_LAUNDER(mem); }
^~~~~~~~~~~~~~~~
/workdir/proxsuite/build/install/lib/pkgconfig/../../include/proxsuite/linalg/veg/memory/placement.hpp:46:32: note: expanded from macro 'VEG_LAUNDER'
#define VEG_LAUNDER(p) (::std::launder(p))
~~~~~~~^ I am using this command to compile the example: I have built A Dockerfile to reproduce is: FROM mottosso/mayabase-centos7
# Expose ninja, cmake3
RUN yum install -y http://repo.okay.com.mx/centos/7/x86_64/release/okay-release-1-1.noarch.rpm
# Build dependencies
RUN yum install -y centos-release-scl centos-release-scl-rh scl-utils
RUN yum install -y \
ninja-build \
cmake3 \
libXt-devel \
freeglut-devel \
devtoolset-7
RUN ln -s /usr/bin/cmake3 /usr/bin/cmake
ENV CC=/opt/rh/devtoolset-7/root/usr/bin/gcc
ENV CXX=/opt/rh/devtoolset-7/root/usr/bin/g++ Update: (@jcarpent @Bambade) There is a difference between compilers: clang gives the above error, while g++ gives the following: /workdir/proxsuite/build/install/lib64/pkgconfig/../../include/proxsuite/linalg/veg/memory/alloc.hpp:175:15: error: 'aligned_alloc' is not a member of 'std'
return std::aligned_alloc(align, (size + mask) & ~mask); By the way (although it cannot solve my issue), if I use |
Making the following patch: diff --git a/include/proxsuite/linalg/veg/memory/alloc.hpp b/include/proxsuite/linalg/veg/memory/alloc.hpp
index 4c9056847..3ed961ad9 100644
--- a/include/proxsuite/linalg/veg/memory/alloc.hpp
+++ b/include/proxsuite/linalg/veg/memory/alloc.hpp
@@ -171,7 +171,7 @@ aligned_alloc(usize align, usize size) noexcept -> void*
return alignment::detail::aligned_alloc(align, (size + mask) & ~mask);
#endif
#else
-#ifdef PROXSUITE_WITH_CPP_17
+#if defined(PROXSUITE_WITH_CPP_17) && defined(_LIBCPP_HAS_ALIGNED_ALLOC)
return std::aligned_alloc(align, (size + mask) & ~mask);
#else
return alignment::detail::aligned_alloc(align, (size + mask) & ~mask);
diff --git a/include/proxsuite/linalg/veg/memory/placement.hpp b/include/proxsuite/linalg/veg/memory/placement.hpp
index 0ec1708cf..cb1afbc8a 100644
--- a/include/proxsuite/linalg/veg/memory/placement.hpp
+++ b/include/proxsuite/linalg/veg/memory/placement.hpp
@@ -41,7 +41,7 @@
#if VEG_HAS_BUILTIN(__builtin_launder) || __GNUC__ >= 7
#define VEG_LAUNDER(p) (__builtin_launder(p))
-#elif defined(VEG_WITH_CXX17_SUPPORT)
+#elif defined(VEG_WITH_CXX17_SUPPORT) && __GNUC__ >= 6
#include <new>
#define VEG_LAUNDER(p) (::std::launder(p))
#else I was able to make ProxSuite compile and run using both g++ and clang. I am not sure if the patch is good but checking just for c++17 seems to not be enough. |
@costashatz Could you open a PR? Your fix looks good to me. |
Sure. Here it is: #255 |
Partly solved by #255.. clang5/gcc 4.8 are too old for ProxQP. |
Thanks a lot @jcarpent! |
Hello guys,
Thanks for the great work! I have been very satisfied by this solver so far.
I am having trouble getting it compiled in old compilers. Long story but I need to compile it with clang5. I am getting many errors related to
std::launder
,std::aligned_alloc
, etc..I am attaching a Dockerfile with the system that I need ProxQP to compile with. I hope this will help you to fix the compilation errors.
Any help will be appreciated.
Thanks in advance!
The text was updated successfully, but these errors were encountered: