Mercury-Language/mercury

[macOS] Build segfaults on 10.6.8 (but only on x86_64)

Opened this issue · 1 comments

make[2]: Leaving directory `/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_mercury/mercury/work/mercury-srcdist-22.01.8/install_grade_dir.hlc.gc/runtime'
make[2]: Entering directory `/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_mercury/mercury/work/mercury-srcdist-22.01.8/install_grade_dir.hlc.gc/library'
../Mmake.common:494: warning: undefined variable `mer_std.mhs'
../Mmake.common:497: warning: undefined variable `mer_std.mhs'
../Mmake.common:503: warning: undefined variable `mer_std.os'
/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_mercury/mercury/work/.tmp/mmake.c5GsH4:969: warning: undefined variable `mer_std.trans_opts'
/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_mercury/mercury/work/.tmp/mmake.c5GsH4:1045: warning: undefined variable `mer_std.ms'
/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_mercury/mercury/work/.tmp/mmake.c5GsH4:1225: warning: undefined variable `mer_std.os'
mmc --generate-dependencies --grade hlc.gc     --mercury-linkage shared --flags LIB_FLAGS   --flags INTER_FLAGS -R/opt/local/lib/mercury/lib/hlc.gc -R/opt/local/lib/mercury/lib  --no-warn-nothing-exported --no-warn-unused-imports   mer_std > mer_std.dep_err 2>&1
/bin/sh: line 1: 86436 Segmentation fault      mmc --generate-dependencies --grade hlc.gc --mercury-linkage shared --flags LIB_FLAGS --flags INTER_FLAGS -R/opt/local/lib/mercury/lib/hlc.gc -R/opt/local/lib/mercury/lib --no-warn-nothing-exported --no-warn-unused-imports mer_std > mer_std.dep_err 2>&1
make[2]: *** [mer_std.depend] Error 139
make[2]: Leaving directory `/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_mercury/mercury/work/mercury-srcdist-22.01.8/install_grade_dir.hlc.gc/library'
To clean up from failed install, remove /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_mercury/mercury/work/mercury-srcdist-22.01.8/install_grade_dir.hlc.gc
make[1]: *** [install_grades] Error 1
make[1]: Leaving directory `/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_mercury/mercury/work/mercury-srcdist-22.01.8'
make: *** [install] Error 2
make: Leaving directory `/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_mercury/mercury/work/mercury-srcdist-22.01.8'
Command failed:  cd "/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_mercury/mercury/work/mercury-srcdist-22.01.8" && /usr/bin/make -w install INSTALL_INFO_DIR=/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_mercury/mercury/work/destroot/opt/local/share/info INSTALL_MAN_DIR=/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_mercury/mercury/work/destroot/opt/local/share/man DESTDIR=/opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_mercury/mercury/work/destroot 
Exit code: 2

Full build log: https://build.macports.org/builders/ports-10.6_x86_64-builder/builds/190372/steps/install-port/logs/stdio

P. S. Notice, that we get this only on x86_64.
Both i386 and ppc build fine on 10.6.

The oldest version of macOS that is "officially" supported by Mercury is 10.9. That said, Mercury definitely worked with 10.6 on x86_64 when that version of macOS was originally released and we haven't done anything since then that would prevent it from working (in principle).

As a starting point for investigating this, I would try the following:

  1. Try bumping up the stack size, e.g. (using ulimit -s), and see if that resolves the issue. (IIRC, stack exhaustion when doing --generate-dependencies step has been a problem in the past.)

  2. Try disabling optimisations in the C compiler, e.g. pass -O0 to clang. You can do this by creating a file named Mmake.params at the top-level of the Mercury source tree containing the following:

    EXTRA_CFLAGS = -O0

    This should give us a clue as to whether the issue is being caused by a misbehaving C compiler optimisation.