'--with-gmp-lib=' configure option works on build machine, and this patch
doesn't break it.

When binary is installed on user machine, you can't assume gmp is available
in that path.

So the only way is to bundle gmp as fallback.

- Qian

On Wed, Nov 8, 2023, 10:01 PM Waldek Hebisch <de...@fricas.org> wrote:

> On Wed, Nov 08, 2023 at 08:28:22AM +0800, Qian Yun wrote:
> > Recently I found that CI built macOS binaries do not work out-of-box:
> > it complains libzstd missing because SBCL from Homebrew is built with
> > core-compression support.
> >
> > So I have changed to use upstream sbcl binary instead.
> >
> > The situation for gmp support is similar to windows: we can not assume
> > libgmp.dylib is present on system.
> >
> > So I changed CI to bundle gmp library, and changed code to load bundled
> > gmp library if there's no system gmp library.
>
> We alreay have '--with-gmp-lib=' configure option.  This option was
> added exactly to solve problem that you mention: we can not assume
> that Mac OSX has GMP library in a fixed location.  I am affraid that
> your patch below would break '--with-gmp-lib=' for people who
> need it.  It would be better just to use '--with-gmp-lib=', so that
> it works for everybody.
>
> BTW: Probably it would be better to use '--with-gmp-lib=' also on
> Windows, but I am not sure if anybody used '--with-gmp-lib=' on
> Windows, while AFAIK it is used on Mac OSX.
>
> >
> > - Qian
> >
> >
> https://github.com/oldk1331/fricas/commit/dbc3a563caf892374782e808f790f5442620816f.patch
> >
> > diff --git a/.github/workflows/macOS.yml b/.github/workflows/macOS.yml
> > index 8439f76e..d4737664 100644
> > --- a/.github/workflows/macOS.yml
> > +++ b/.github/workflows/macOS.yml
> > @@ -19,14 +19,17 @@ jobs:
> >      - name: configure
> >        run: |
> >          mkdir ../build && cd ../build
> > -        ../fricas/configure
> >
> --with-lisp=${GITHUB_WORKSPACE}/sbcl-${SBCL_VER}-x86-64-darwin/run-sbcl.sh
> > || cat config.log
> > +        ../fricas/configure
> >
> --with-lisp=${GITHUB_WORKSPACE}/sbcl-${SBCL_VER}-x86-64-darwin/run-sbcl.sh
> > --enable-gmp || cat config.log
> >      - name: make
> >        run: cd ../build && make -j3
> >      - name: make check
> >        run: cd ../build && make check -j3
> >      - name: Create artifact archives
> >        run: |
> > -        cd ../build && make dist-osx-dmg
> > +        cd ../build
> > +        make dist-macos
> > +        cp -v `brew list gmp | grep libgmp.10.dylib`
> > FriCAS.app/Contents/Resources/usr/local/lib/fricas/target/*/lib/
> > +        make dist-macos-dmg
> >          mv FriCAS.dmg ../fricas/FriCAS-macOS-x86_64-${{ github.sha
> }}.dmg
> >      - name: Upload macOS binary
> >        uses: actions/upload-artifact@v3
> > diff --git a/Makefile.in b/Makefile.in
> > index 2961de19..c370d32b 100644
> > --- a/Makefile.in
> > +++ b/Makefile.in
> > @@ -247,7 +247,7 @@ ${DIST_TARBALL}: out-of-source-check lastBuildDate
> > dist-help dist-lisp dist-doc
> >
> >  dist: ${DIST_TARBALL}
> >
> > -dist-osx-dmg: out-of-source-check
> > +dist-macos: out-of-source-check
> >         -rm -rf FriCAS.app FriCAS.dmg
> >         ${MKDIR_P} FriCAS.app/Contents/{MacOS,Resources}
> >         ${MAKE} DESTDIR=./FriCAS.app/Contents/Resources install-src
> > @@ -255,6 +255,8 @@ dist-osx-dmg: out-of-source-check
> >         cp $(fricas_top_srcdir)/contrib/macos/Info.plist
> > ./FriCAS.app/Contents/
> >         cp $(fricas_top_srcdir)/contrib/macos/appIcon.icns
> > ./FriCAS.app/Contents/Resources/
> >         cc -framework CoreFoundation
> > $(fricas_top_srcdir)/contrib/macos/FriCAS.c -o
> > ./FriCAS.app/Contents/MacOS/FriCAS
> > +
> > +dist-macos-dmg:
> >         hdiutil create -srcfolder FriCAS.app FriCAS.dmg
> >
> >  clean-distdir:
> > diff --git a/src/lisp/num_gmp.lisp b/src/lisp/num_gmp.lisp
> > index f4a022ad..212e9d40 100644
> > --- a/src/lisp/num_gmp.lisp
> > +++ b/src/lisp/num_gmp.lisp
> > @@ -838,11 +838,16 @@
> >      (sb-ext:lock-package "COMMON-LISP")))
> >
> >  (defun load-gmp-lib ()
> > -    #-:WIN32 (ignore-errors (|quiet_load_alien| "libgmp.so") t)
> > -    #+:WIN32 (if (ignore-errors (|quiet_load_alien| "libgmp-10.dll") t)
> > -                 t
> > -                 (ignore-errors (|quiet_load_alien|
> > -                     (BOOT::make-absolute-filename
> "/lib/libgmp-10.dll"))
> > t)))
> > +    (setq system-gmp-name #+:WIN32 "libgmp-10.dll"
> > +                          #-:WIN32 "libgmp.so")
> > +    (setq bundled-gmp-name #+:WIN32 "/lib/libgmp-10.dll"
> > +                           #+:DARWIN "/lib/libgmp.10.dylib"
> > +                           #-(or :WIN32 :DARWIN) nil)
> > +    (if (ignore-errors (|quiet_load_alien| system-gmp-name) t)
> > +        t
> > +        (and bundled-gmp-name
> > +             (ignore-errors (|quiet_load_alien|
> > +                 (BOOT::make-absolute-filename bundled-gmp-name)) t))))
> >
> >  (defun init-gmp(wrapper-lib)
> >      (if (not *gmp-multiplication-initialized*)
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "FriCAS - computer algebra system" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to fricas-devel+unsubscr...@googlegroups.com.
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/fricas-devel/012796c4-3cc8-4480-b9df-5bc8579b3569%40gmail.com
> .
>
> --
>                               Waldek Hebisch
>
> --
> You received this message because you are subscribed to the Google Groups
> "FriCAS - computer algebra system" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to fricas-devel+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/fricas-devel/ZUuUqLAl1DhXZS%2BF%40fricas.org
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to fricas-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/CAGBJN93B6MW5n%3DjMRcUw%2BrA_7UmzmAA6p0MKh-gjEpC2_H4sTQ%40mail.gmail.com.

Reply via email to