[m-rev.] for review: Disable non-local gotos on AArch64 with GCC 9+.

Peter Wang novalazy at gmail.com
Wed Jun 1 14:02:42 AEST 2022


Programs using non-local gotos on AArch64 crash when compiled with
newer versions of GCC:

    gcc 6.3.0 (Debian 9) - ok
    gcc 8.3.0 (Debian 10) - ok
    gcc 9.3.0 (Debian 11) - crash
    gcc 10.2 (Debian 11) - crash

Specifically, the programs only crash when compiled with PIC,
but PIC is commonly the default now.

This is Mantis bug #560.

configure.ac:
    Disable non-local gotos on AArch64 when using GCC 9+.

README.Linux-aarch64:
    Mention the problem.

diff --git a/README.Linux-aarch64 b/README.Linux-aarch64
index 90bf86a06..fd91fc2fe 100644
--- a/README.Linux-aarch64
+++ b/README.Linux-aarch64
@@ -2,3 +2,8 @@ This file documents the port of Mercury to Linux on AArch64 (ARM64),
 i.e. the `aarch64*-linux*` configuration.
 
 Mercury should build and install "out-of-the-box" on Linux for AArch64.
+
+Low-level C grades using non-local gotos, i.e. asm_fast.*, do not work
+with GCC 9 or later. Non-PIC (position-independent code) actually does
+still work, but PIC is commonly the default.
+If you require a low-level C grade, please use a reg.* grade.
diff --git a/configure.ac b/configure.ac
index c21e3c4b6..d6fee831b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2406,6 +2406,17 @@ case "$ac_cv_c_compiler_gnu" in yes)
             # -ftree-dominator-opts.
             CFLAGS_FOR_GOTOS="$CFLAGS_FOR_GOTOS $CFLAGS_FOR_NO_TREE_DOMINATOR_OPTS"
             CFLAGS_FOR_REGS="-fomit-frame-pointer"
+            # GCC labels do not work correctly on aarch64 when generating PIC
+            # with GCC 9+.
+            case $C_COMPILER_TYPE in
+                gcc_3_*|gcc_4_*|gcc_5_*|gcc_6_*|gcc_7_*|gcc_8_*)
+                    ;;
+                gcc_*)
+                    MERCURY_MSG("gcc labels do not work with PIC on aarch64")
+                    mercury_cv_asm_labels=no
+                    mercury_cv_gcc_labels=no
+                    ;;
+            esac
             ;;
     esac
     ;;
-- 
2.35.1



More information about the reviews mailing list