Mercury-Language / mercury

The Mercury logic programming system.
Other
904 stars 54 forks source link

(Recently) unable to compile on Arch #94

Closed xxxserxxx closed 3 years ago

xxxserxxx commented 3 years ago

Version: 20.06.01
Linux: 5.12.8-arch1-1
GCC: 11.1.0
Arch: x86_64
Issue: Mercury compiler will not build on Arch; it fails with the error:

make[2]: Entering directory '/home/ser/Downloads/mercury-srcdist-20.06.1/compiler'
../scripts/mgnuc --grade hlc.gc.pregen       --      -c libs.md4.c -o libs.md4.o
md4.m:224:66: error: argument 2 of type ‘unsigned char *’ declared as a pointer [-Werror=array-parameter=]
  224 |     }
      |

I needed to re-install Mercury on Arch after it had been removed (purged accidentally during an "unused" package cleanup); I tried first with the AUR package, which had been successfully installed (I don't remember which version, though), and it failed with the above error. I then downloaded the sources from the Mercury site, unpacked them, and tried to compile it myself with the INSTALL instructions:

$ sh configure --prefix=/usr/local/mercury --enable-minimal-install
...
$ make
# error from above

The error is identical to what the AUR package produces. I varied the grades selected with configure a bit, with a make clean between, but the error was always the same. I mucked around a bit trying to figure out how to disable -Werror but the Makefile configuration confused me.

It's probably just my system, but whatever it is I've been unable to figure it out within the past two hours. I don't use Mercury myself directly, but I do use bower which Arch doesn't provide a binary for, and so requires Mercury to build.

wangp commented 3 years ago

Looks like gcc 11 has a new warning. You can probably add this to the Mmake.params file for now:

EXTRA_CFLAGS += -Wno-error=array-parameter
xxxserxxx commented 3 years ago

Yup, that did it, thanks. I'll let the package maintainer in AUR know.

Is clang a preferrable compiler (over GCC) for Mercury?

wangp commented 3 years ago

There's not much difference for high level C grades (hlc.*) AFAIK, but clang doesn't have some gcc extensions that we can use for low-level C grades (asm_fast.*). The Mercury debugger only works in low-level C grades, for example. Obviously for end users the debugger doesn't matter.