Skip to content

Instantly share code, notes, and snippets.

@ochafik
Created February 5, 2022 00:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ochafik/6c5781b39a29d6c2a9859e83c3c17fb0 to your computer and use it in GitHub Desktop.
Save ochafik/6c5781b39a29d6c2a9859e83c3c17fb0 to your computer and use it in GitHub Desktop.
Repro instructions for a CGAL compilation bug that started in 5.3 (PMP::triangulate_faces + Gmp)

Only happens in mingw32 64bit builds (whether building in Windows on a msys2 env, or cross-building from linux w/ the MXE environment).

docker run -it openscad/mxe-x86_64-gui:latest
apt install -y vim cmake

# Then paste the script above
In file included from /mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/Number_types/internal/Exact_type_selector.h:25,
from /mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/Exact_kernel_selector.h:26,
from /mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/Filtered_kernel.h:22,
from /mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/Exact_predicates_exact_constructions_kernel.h:21,
from bug.cc:2:
/mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/Lazy_exact_nt.h: In instantiation of 'void CGAL::Lazy_exact_Cst<ET, X>::update_exact() const [with ET = __gmp_expr<__mpq_struct [1], __mpq_struct [1]>; X = long long unsigned int]':
/mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/Lazy_exact_nt.h:152:8: required from here
/mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/Lazy_exact_nt.h:153:17: error: call of overloaded '__gmp_expr(const long long unsigned int&)' is ambiguous
153 | auto* pet = new typename Lazy_exact_nt_rep<ET>::Indirect(cste);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/is_convertible.h:23,
from /mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/Rational_traits.h:23,
from /mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/number_type_basic.h:40,
from /mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/basic.h:28,
from /mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/Cartesian/Cartesian_base.h:20,
from /mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/Simple_cartesian.h:20,
from /mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/Exact_predicates_exact_constructions_kernel.h:20,
from bug.cc:2:
/mxe/usr/x86_64-w64-mingw32.static.posix/include/gmpxx.h:1661:3: note: candidate: '__gmp_expr<__mpq_struct [1], __mpq_struct [1]>::__gmp_expr(double)'
1661 | __GMPXX_DEFINE_ARITHMETIC_CONSTRUCTORS
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mxe/usr/x86_64-w64-mingw32.static.posix/include/gmpxx.h:1661:3: note: candidate: '__gmp_expr<__mpq_struct [1], __mpq_struct [1]>::__gmp_expr(float)'
1661 | __GMPXX_DEFINE_ARITHMETIC_CONSTRUCTORS
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mxe/usr/x86_64-w64-mingw32.static.posix/include/gmpxx.h:1661:3: note: candidate: '__gmp_expr<__mpq_struct [1], __mpq_struct [1]>::__gmp_expr(long unsigned int)'
1661 | __GMPXX_DEFINE_ARITHMETIC_CONSTRUCTORS
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mxe/usr/x86_64-w64-mingw32.static.posix/include/gmpxx.h:1661:3: note: candidate: '__gmp_expr<__mpq_struct [1], __mpq_struct [1]>::__gmp_expr(long int)'
1661 | __GMPXX_DEFINE_ARITHMETIC_CONSTRUCTORS
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mxe/usr/x86_64-w64-mingw32.static.posix/include/gmpxx.h:1661:3: note: candidate: '__gmp_expr<__mpq_struct [1], __mpq_struct [1]>::__gmp_expr(short unsigned int)'
1661 | __GMPXX_DEFINE_ARITHMETIC_CONSTRUCTORS
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mxe/usr/x86_64-w64-mingw32.static.posix/include/gmpxx.h:1661:3: note: candidate: '__gmp_expr<__mpq_struct [1], __mpq_struct [1]>::__gmp_expr(short int)'
1661 | __GMPXX_DEFINE_ARITHMETIC_CONSTRUCTORS
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mxe/usr/x86_64-w64-mingw32.static.posix/include/gmpxx.h:1661:3: note: candidate: '__gmp_expr<__mpq_struct [1], __mpq_struct [1]>::__gmp_expr(unsigned int)'
1661 | __GMPXX_DEFINE_ARITHMETIC_CONSTRUCTORS
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mxe/usr/x86_64-w64-mingw32.static.posix/include/gmpxx.h:1661:3: note: candidate: '__gmp_expr<__mpq_struct [1], __mpq_struct [1]>::__gmp_expr(int)'
1661 | __GMPXX_DEFINE_ARITHMETIC_CONSTRUCTORS
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mxe/usr/x86_64-w64-mingw32.static.posix/include/gmpxx.h:1661:3: note: candidate: '__gmp_expr<__mpq_struct [1], __mpq_struct [1]>::__gmp_expr(unsigned char)'
1661 | __GMPXX_DEFINE_ARITHMETIC_CONSTRUCTORS
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mxe/usr/x86_64-w64-mingw32.static.posix/include/gmpxx.h:1661:3: note: candidate: '__gmp_expr<__mpq_struct [1], __mpq_struct [1]>::__gmp_expr(signed char)'
1661 | __GMPXX_DEFINE_ARITHMETIC_CONSTRUCTORS
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/mxe/usr/x86_64-w64-mingw32.static.posix/include/gmpxx.h:1648:3: note: candidate: '__gmp_expr<__mpq_struct [1], __mpq_struct [1]>::__gmp_expr(__gmp_expr<__mpq_struct [1], __mpq_struct [1]>&&)'
1648 | __gmp_expr(__gmp_expr &&q)
| ^~~~~~~~~~
/mxe/usr/x86_64-w64-mingw32.static.posix/include/gmpxx.h:1642:3: note: candidate: '__gmp_expr<__mpq_struct [1], __mpq_struct [1]>::__gmp_expr(const __gmp_expr<__mpq_struct [1], __mpq_struct [1]>&)'
1642 | __gmp_expr(const __gmp_expr &q)
| ^~~~~~~~~~
#!/bin/bash
set -eu
echo '
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Polygon_mesh_processing/triangulate_faces.h>
#include <CGAL/Surface_mesh.h>
int main() {
CGAL::Surface_mesh<CGAL::Point_3<CGAL::Epeck>> mesh;
CGAL::Polygon_mesh_processing::triangulate_faces(mesh);
}
'> bug.cc
export MPFR_INCLUDE_DIR=/mxe/usr/x86_64-w64-mingw32.static.posix/include
export MPFR_LIBRARIES=/mxe/usr/x86_64-w64-mingw32.static.posix/include
export BOOST_INCLUDEDIR=/mxe/usr/x86_64-w64-mingw32.static.posix/include/
export MXE_PREFIX=/mxe/usr/x86_64-w64-mingw32.static.posix
for version in 5.2.4 5.3.1 5.4 ; do
( curl -L --insecure https://github.com/CGAL/cgal/releases/download/v${version}/CGAL-${version}-library.zip --output CGAL-${version}.zip && \
unzip CGAL-${version}.zip && \
cd CGAL-${version} && \
mkdir -p build && \
cd build && \
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$MXE_PREFIX -DMPFR_INCLUDE_DIR=$MXE_PREFIX/include -DMPFR_LIBRARIES=$MXE_PREFIX/lib/libmpfr.so && \
make install ) && \
echo "# Compiling w/ CGAL ${version}" && \
/mxe/usr/x86_64-pc-linux-gnu/bin/x86_64-w64-mingw32.static.posix-g++ -std=c++14 \
-I$BOOST_INCLUDEDIR \
-DCGAL_USE_GMPXX=1 \
-o bug.cc.obj -c bug.cc && \
echo "# Press enter to continue" && \
read
done
@t-paul
Copy link

t-paul commented Feb 5, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment