Dear Poly/ML enthusiasts and experts of the gcc toolchain on macOS,

building Poly/ML with libgmp has always been a challenge, but I have now
managed as follows for x86_64-darwin.

The approach works as follows:

  (1) Build libgmp from sources.
  (2) Build Poly/ML --with-gmp using that homemade version.
  (3) Copy libgmp.10.dylib into the Poly/ML lib directory and adjust
locations with install_name_tool

Afterwards it is possible to copy the resulting Poly/ML target directory
to a different location on a different machine, with a different (newer)
macOS version.

The details are in the included build.txt (e.g. for macOS 10.12 Sierra).
This is not a shell script! It should be run carefully line-by-line.
Towards the end there are two install_name_tool invocations with
locations determined beforehand by "otool -L". The final "otool -L" is
just a sanity check, the result is like this:

        @executable_path/../lib/libpolyml.9.dylib (compatibility version
10.0.0, current version 10.0.0)
        @executable_path/../lib/libgmp.10.dylib (compatibility version 14.0.0,
current version 14.2.0)
        /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
version 1238.0.0)

This setup is already part of "isabelle build_polyml", see
-- but that assumes that libgmp has been installed in a standard place
(e.g. /usr/local/lib).

I wonder if anybody has managed to build libgmp for x86-darwin (32bit)
platform. That platform variant still provides better performance for
big applications like Isabelle, because it requires only half the memory.

# build libgmp (see also
curl | xz -dc | tar xf -
cd gmp-6.1.2
make distclean
./configure --prefix="$PWD/target" --enable-cxx 
--build=core2-apple-darwin"$(uname -r)"
make && make check && make install

# build polyml with this libgmp
cd ../polyml
make distclean
rm -rf target
./configure --prefix="$PWD/target" CFLAGS="-arch x86_64 -O3 -I../libffi/include 
-I$PWD/../gmp-6.1.2/target/include" CXXFLAGS="-arch x86_64 -O3 
-I../libffi/include -I$PWD/../gmp-6.1.2/target/include" CCASFLAGS="-arch 
x86_64" LDFLAGS="-segprot POLY rwx rwx -L$PWD/../gmp-6.1.2/target/lib" 
make compiler && make compiler && make install

# adjust runtime library path
cp ../gmp-6.1.2/target/lib/libgmp.10.dylib target/lib
otool -L target/bin/poly
install_name_tool -change 
"@executable_path/../lib/libgmp.10.dylib" target/bin/poly
install_name_tool -change 
"@executable_path/../lib/libpolyml.9.dylib" target/bin/poly
otool -L target/bin/poly
polyml mailing list

Reply via email to