[m-rev.] for pre-commit review: workaround Mantis bug #453

Peter Wang novalazy at gmail.com
Mon Jan 20 13:22:56 AEDT 2020


On Mon, 20 Jan 2020 03:15:08 +1100 (AEDT), Julien Fischer <jfischer at opturion.com> wrote:
> 
> On Sun, 19 Jan 2020, Peter Wang wrote:
> 
> > On Sun, 19 Jan 2020 20:22:20 +1100 (AEDT), Julien Fischer <jfischer at opturion.com> wrote:
> >>
> >> On Sun, 19 Jan 2020, Peter Wang wrote:
> >>
> >>> On Sun, 19 Jan 2020 18:12:02 +1100 (AEDT), Julien Fischer <jfischer at opturion.com> wrote:
> >>>>
> >>>> For pre-commit review by Peter.
> >>>>
> >>>> In particular:
> >>>>
> >>>> - should we instead handle this by forcing the use of gcc -O0 in asm_fast
> >>>> grades on affected systes?
> >>>
> >>> Only in PIC mode.
> >>
> >> So, force gcc -O0 in PIC mode only as opposed to this diff?
> >
> > Yes.
> 
> Unfortunately, it doesn't work.  The only way I can get an asm_fast.gc
> installation that passes the test suite is by using '--linkage static'.
> (This is with GCC 6 on Debian 9.)
> 
> I propose that we simply use 'reg' as the default LLDS base grade on the
> affected systems.  Furthermore, we make 'hlc' the default base grade
> on systems where the default LLDS base grade is 'reg'.
> 
> Given that this only affects i*86 systems, I don't think it's worth
> spending much further effort on it, at least for the purposes of the
> 20.01 release.

Ok.

I think instead of your original patch, we should be setting
    mercury_cv_asm_labels=no
    mercury_cv_gcc_labels=no

as in the attached patch.

Peter
-------------- next part --------------
diff --git a/configure.ac b/configure.ac
index 65d3e8576..7285932d9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1227,6 +1227,17 @@ AC_SUBST(CYGPATH)
 # The result of this check may be overridden below.
 AC_CHECK_LIB(m, sin, [MATH_LIB=-lm], [MATH_LIB=])
 
+#-----------------------------------------------------------------------------#
+#
+# Add option for dynamic linking.
+#
+
+AC_ARG_ENABLE(dynamic-link,
+    AC_HELP_STRING([--disable-dynamic-link],
+                   [disable the use of dynamic linking]),
+    [mercury_cv_enable_dynamic_link="$enableval"],
+    [mercury_cv_enable_dynamic_link=yes])
+
 #-----------------------------------------------------------------------------#
 #
 # Check whether to use symbolic links
@@ -2600,7 +2611,28 @@ case "$ac_cv_prog_gcc" in yes)
         mips-*)
             CFLAGS_FOR_GOTOS="$CFLAGS_FOR_GOTOS -fomit-frame-pointer"
             ;;
-        i*86-*|x86_64*)
+        i*86-*)
+            # On x86-64 and x86, GCC labels do not work correctly with
+            # -ftree-dominator-opts.
+            CFLAGS_FOR_GOTOS="$CFLAGS_FOR_GOTOS $CFLAGS_FOR_NO_TREE_DOMINATOR_OPTS"
+            CFLAGS_FOR_REGS="-fno-builtin -fno-omit-frame-pointer"
+
+            # We can no longer use non-local gotos in position independent code
+            # on x86 with GCC 5+ as the EBX register is no longer reserved for
+            # the GOT address. We cannot jump past a function's prologue then
+            # "fix up" the EBX register.
+            case $C_COMPILER_TYPE in
+                gcc_3_*|gcc_4_*) ;;
+                gcc_*)
+                    if test "$mercury_cv_enable_dynamic_link" = yes
+                    then
+                        mercury_cv_asm_labels=no
+                        mercury_cv_gcc_labels=no
+                    fi
+                    ;;
+            esac
+            ;;
+        x86_64*)
             # On x86-64 and x86, GCC labels do not work correctly with
             # -ftree-dominator-opts.
             CFLAGS_FOR_GOTOS="$CFLAGS_FOR_GOTOS $CFLAGS_FOR_NO_TREE_DOMINATOR_OPTS"
@@ -5169,14 +5201,11 @@ AC_SUBST(NSL_LIBRARY)
 
 #-----------------------------------------------------------------------------#
 #
-# Check for dynamic linking, unless the --disable-dynamic-link option
-# was specified.
+# Check libraries for dynamic linking.
+#
+# XXX This needs to occur after mercury_check_for_functions is defined,
+# but the option defining mercury_cv_enable_dynamic_link is needed earlier.
 #
-
-AC_ARG_ENABLE(dynamic-link,
-    AC_HELP_STRING([--disable-dynamic-link],
-                   [disable the use of dynamic linking]),
-mercury_cv_enable_dynamic_link="$enableval",mercury_cv_enable_dynamic_link=yes)
 
 if test "$mercury_cv_enable_dynamic_link" = "yes"; then
     MERCURY_CHECK_FOR_HEADERS(dlfcn.h)


More information about the reviews mailing list