sage icon indicating copy to clipboard operation
sage copied to clipboard

try to fix build on some arm64 macOS systems

Open dimpase opened this issue 6 months ago • 10 comments

as reported on https://github.com/sagemath/sage/issues/40106

Proposed upstream as https://github.com/gap-system/gap/pull/5992

:memo: Checklist

  • [ ] The title is concise and informative.
  • [ ] The description explains in detail what this PR is about.
  • [ ] I have linked a relevant issue or discussion.
  • [ ] I have created tests covering the changes.
  • [ ] I have updated the documentation and checked the documentation preview.

:hourglass: Dependencies

dimpase avatar May 17 '25 01:05 dimpase

This doesn't work for me, same error as before. Is LINK_SHLIB_FLAGS used in the build/gap-install target? I think that's where the error arises.

jhpalmieri avatar May 18 '25 04:05 jhpalmieri

In case it helps, I am attaching two logs: one (with 40116 in its name) from trying the build with your change on this branch, and another (with LDFLAGS in its name) where I instead made this change:

diff --git a/build/pkgs/gap/spkg-install.in b/build/pkgs/gap/spkg-install.in
index 7d207a47a4..422a210888 100644
--- a/build/pkgs/gap/spkg-install.in
+++ b/build/pkgs/gap/spkg-install.in
@@ -16,6 +16,8 @@ if [ "$SAGE_DEBUG" = yes ] ; then
     export CFLAGS="-O0 -g3 -DDEBUG_MASTERPOINTERS -DDEBUG_GLOBAL_BAGS -DDEBUG_FUNCTIONS_BAGS $CFLAGS"
 fi
 
+export LDFLAGS="-Wl,-headerpad_max_install_names $LDFLAGS"
+
 sdh_configure $SAGE_CONFIGURE_GMP --prefix=$SAGE_LOCAL
 sdh_make
 sdh_make_install

The second log shows -Wl,-headerpad_max_install_names a few more times.

gap-4.14.0 40116.log gap-4.14.0 LDFLAGS.log

jhpalmieri avatar May 18 '25 04:05 jhpalmieri

it's obviously an upstream bug, the problem is to reproduce it.

dimpase avatar May 18 '25 08:05 dimpase

Can you try building GAP on Homebrew (so that gmp+readline comes from there), but outside of Sage, just by cloning https://github.com/gap-system/gap.git, then

cd gap
./autogen.sh && ./configure --prefix=/tmp && make && make install

I can't reporoduce this on William's M1, which is Darwin 24.3.0, not 24.4.0, like yours

dimpase avatar May 18 '25 09:05 dimpase

It failed on the documentation but the earlier part succeeded:

% make install
   C       build/main.c => build/obj/build/main.c.o
   LINK    build/gap-install
# install a special build of gap with SYS_DEFAULT_PATHS set suitably
/opt/homebrew/bin/ginstall -c -d -m 0755 /tmp/bin
/opt/homebrew/bin/ginstall -c -m 0755 build/gap-install /tmp/bin/gap
# install gac
sed -e "s;@SYSINFO_GAPROOT@;/tmp/lib/gap;" < ./cnf/gac.in > /tmp/bin/gac
chmod 0755 /tmp/bin/gac
/opt/homebrew/bin/ginstall -c -d -m 0755 /tmp/share/gap
/opt/homebrew/bin/ginstall -c -d -m 0755 /tmp/lib/gap
/opt/homebrew/bin/ginstall -c -d -m 0755 /tmp/share/gap/pkg
/opt/homebrew/bin/ginstall -c -d -m 0755 /tmp/share/gap/doc
/opt/homebrew/bin/ginstall -c -m 0644 ./doc/gapmacro.tex /tmp/share/gap/doc/
/opt/homebrew/bin/ginstall -c -m 0644 ./doc/manualindex /tmp/share/gap/doc/
for book in ref tut hpc ; do \
		/opt/homebrew/bin/ginstall -c -d -m 0755 /tmp/share/gap/doc/$book ; \
		for ext in css html js txt pdf six lab; do \
			/opt/homebrew/bin/ginstall -c -m 0644  ./doc/$book/*.$ext /tmp/share/gap/doc/$book/ ; \
		done \
	done
ginstall: cannot stat './doc/ref/*.css': No such file or directory
ginstall: cannot stat './doc/ref/*.html': No such file or directory
...

The executable /tmp/bin/gap fails to run because it hasn't installed the library:

% /tmp/bin/gap
dyld[67869]: Library not loaded: /tmp/lib/libgap.10.dylib
  Referenced from: <CCD67413-3CDA-38A2-8E8D-93553B9E526F> /private/tmp/bin/gap
  Reason: tried: '/tmp/lib/libgap.10.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/tmp/lib/libgap.10.dylib' (no such file), '/tmp/lib/libgap.10.dylib' (no such file), '/private/tmp/lib/libgap.10.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/private/tmp/lib/libgap.10.dylib' (no such file), '/private/tmp/lib/libgap.10.dylib' (no such file)
[1]    67869 abort      /tmp/bin/gap

jhpalmieri avatar May 18 '25 21:05 jhpalmieri

The executable /tmp/bin/gap fails to run because it hasn't installed the library:

can in be that libgap.dylib is installed somewhere in /tmp/, just not where /tmp/bin/gap is looking ?

dimpase avatar May 19 '25 15:05 dimpase

The executable /tmp/bin/gap fails to run because it hasn't installed the library:

can in be that libgap.dylib is installed somewhere in /tmp/, just not where /tmp/bin/gap is looking ?

No, it's not there at all. Aside from a .tex file and a documentation index, the only things that were installed are two executables (gap and gac) and some empty directories.

jhpalmieri avatar May 19 '25 16:05 jhpalmieri

@jhpalmieri - can you try the new version? (without your LDFLAGS add-on, just the PR itself)

details here: https://github.com/gap-system/gap/issues/5989#issuecomment-2891644592

dimpase avatar May 19 '25 17:05 dimpase

This one works for me (on one machine, I won't be able to test the other one until tomorrow).

jhpalmieri avatar May 19 '25 19:05 jhpalmieri

The executable /tmp/bin/gap fails to run because it hasn't installed the library:

can in be that libgap.dylib is installed somewhere in /tmp/, just not where /tmp/bin/gap is looking ?

No, it's not there at all. Aside from a .tex file and a documentation index, the only things that were installed are two executables (gap and gac) and some empty directories.

well, this is a bug (probably the same we see in Sage)! All what's "normally" broken in GAP's "make install" into a non-standard location is that packages are not quite at the right place, so GAP starts, but errors out with #I gapdoc package is not available. Check that the name is correct.

Does it also happen with the branch of my GAP's PR: https://github.com/gap-system/gap/pull/5992 ? (so at GAP's source dir obtained from GIT you'd git pull pull/5992/head before doing the usual ./autogen... etc)

dimpase avatar May 20 '25 02:05 dimpase

@jhpalmieri - if you're running into the more issues on GAP, it would be great to see output of make with V=1 options, for more info.

dimpase avatar May 20 '25 16:05 dimpase

This one works for me (on one machine, I won't be able to test the other one until tomorrow).

Works on two other machines: all three exhibited the same problem and the branch here fixes it for all of them.

jhpalmieri avatar May 20 '25 21:05 jhpalmieri

For the upstream bug report, on one or better two machines affected, could you please do build and make install of GAP with and without https://github.com/gap-system/gap/pull/5992 ? And report whether libgap*.dylib appeared at install targets, better directly on https://github.com/gap-system/gap/pull/5992 ?

dimpase avatar May 21 '25 03:05 dimpase

GAP upstream has merged our fix, yay! Thanks for the efforts. Now the question is how to deal with it here. Use the patch from my upstream PR?

dimpase avatar May 26 '25 17:05 dimpase

@jhpalmieri - please test this, it should fix your issue

dimpase avatar May 26 '25 19:05 dimpase

Sorry for not responding earlier to your various questions. Using your upstream patch makes sense to me, and this does fix my issue. Thanks for your work on it!

jhpalmieri avatar May 27 '25 21:05 jhpalmieri