From objitsu at gmail.com Mon May 2 18:11:51 2022 From: objitsu at gmail.com (Sean Charles (emacstheviking)) Date: Mon, 2 May 2022 09:11:51 +0100 Subject: [m-users.] CompCert C as a backend for Mercury ? Message-ID: <1852B268-7416-4CE8-8EA9-7E1F21FE4D85@gmail.com> Hi, Today I learned of: https://compcert.org/ A formally verified C compiler. I wondered what exposure it has to the erudite members of this thread, and more to the point, has anybody tried to compile the output of the mercury compiler with it? It would seem like a match made in heaven. I will be downloading this compiler to see what I can do with it. Thanks, Sean. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jfischer at opturion.com Mon May 2 22:25:50 2022 From: jfischer at opturion.com (Julien Fischer) Date: Mon, 2 May 2022 22:25:50 +1000 (AEST) Subject: [m-users.] CompCert C as a backend for Mercury ? In-Reply-To: <1852B268-7416-4CE8-8EA9-7E1F21FE4D85@gmail.com> References: <1852B268-7416-4CE8-8EA9-7E1F21FE4D85@gmail.com> Message-ID: On Mon, 2 May 2022, Sean Charles (emacstheviking) wrote: > Today I learned of:   https://compcert.org/ > > A formally verified C compiler. I wondered what exposure it has to the > erudite members of this thread, and more to the point, has anybody > tried to compile the output of the mercury compiler with it? Not to my knowledge. I was aware of its existence, but since its license does not allow commercial use and one of the things I do with Mercury is develop commercial software there didn't seem any compelling reason to look into it further. > It would seem like a match made in heaven. > > I will be downloading this compiler to see what I can do with it. Just so you're aware: there's bit more to it than just doing $ ./configure --with-cc=ccomp If you search the git repository for when we added support for clang** (circa 2011), that might give you some idea of what is required to use a new C compiler. The obvious starting point is: can you successfully compile the Boehm GC with it? Julien. From objitsu at gmail.com Mon May 2 23:14:31 2022 From: objitsu at gmail.com (Sean Charles (emacstheviking)) Date: Mon, 2 May 2022 14:14:31 +0100 Subject: [m-users.] CompCert C as a backend for Mercury ? In-Reply-To: References: <1852B268-7416-4CE8-8EA9-7E1F21FE4D85@gmail.com> Message-ID: <5959083A-6BC9-43E8-89C3-851B38257973@gmail.com> IT was a long shit! :D However, the fruits of my exploration this morning are such that I have now become interested in Coq, like I need more distractions. THanks > On 2 May 2022, at 13:25, Julien Fischer wrote: > > > On Mon, 2 May 2022, Sean Charles (emacstheviking) wrote: > >> Today I learned of: https://compcert.org/ >> A formally verified C compiler. I wondered what exposure it has to the >> erudite members of this thread, and more to the point, has anybody >> tried to compile the output of the mercury compiler with it? > > Not to my knowledge. I was aware of its existence, but since its > license does not allow commercial use and one of the things I do with > Mercury is develop commercial software there didn't seem any compelling > reason to look into it further. > >> It would seem like a match made in heaven. >> I will be downloading this compiler to see what I can do with it. > > Just so you're aware: there's bit more to it than just doing > > $ ./configure --with-cc=ccomp > > If you search the git repository for when we added support for clang** > (circa 2011), that might give you some idea of what is required to use > a new C compiler. > > The obvious starting point is: can you successfully compile the Boehm > GC with it? > > Julien. From dirk at ziegemeyer.de Tue May 3 00:35:12 2022 From: dirk at ziegemeyer.de (Dirk Ziegemeyer) Date: Mon, 2 May 2022 16:35:12 +0200 Subject: [m-users.] CompCert C as a backend for Mercury ? In-Reply-To: <5959083A-6BC9-43E8-89C3-851B38257973@gmail.com> References: <1852B268-7416-4CE8-8EA9-7E1F21FE4D85@gmail.com> <5959083A-6BC9-43E8-89C3-851B38257973@gmail.com> Message-ID: <84C8A06F-D890-4BB3-99B4-E163B3AB5CBD@ziegemeyer.de> Hi Sean, just in case you need some more distractions with Coq, I can recommend the Software foundations series [1], Volume 1 and 2. There is also a volume 0 "Discrete Math in Coq (alpha)" [2] which might be a good starting point. Dirk [1] https://softwarefoundations.cis.upenn.edu/ [2] https://cs.pomona.edu/classes/cs54/book/ > Am 02.05.2022 um 15:14 schrieb Sean Charles (emacstheviking) : > > IT was a long shit! > > :D > > However, the fruits of my exploration this morning are such that I have now become interested in Coq, like I need more distractions. > > THanks > > >> On 2 May 2022, at 13:25, Julien Fischer wrote: >> >> >> On Mon, 2 May 2022, Sean Charles (emacstheviking) wrote: >> >>> Today I learned of: https://compcert.org/ >>> A formally verified C compiler. I wondered what exposure it has to the >>> erudite members of this thread, and more to the point, has anybody >>> tried to compile the output of the mercury compiler with it? >> >> Not to my knowledge. I was aware of its existence, but since its >> license does not allow commercial use and one of the things I do with >> Mercury is develop commercial software there didn't seem any compelling >> reason to look into it further. >> >>> It would seem like a match made in heaven. >>> I will be downloading this compiler to see what I can do with it. >> >> Just so you're aware: there's bit more to it than just doing >> >> $ ./configure --with-cc=ccomp >> >> If you search the git repository for when we added support for clang** >> (circa 2011), that might give you some idea of what is required to use >> a new C compiler. >> >> The obvious starting point is: can you successfully compile the Boehm >> GC with it? >> >> Julien. > > _______________________________________________ > users mailing list > users at lists.mercurylang.org > https://lists.mercurylang.org/listinfo/users From objitsu at gmail.com Tue May 3 00:35:40 2022 From: objitsu at gmail.com (Sean Charles (emacstheviking)) Date: Mon, 2 May 2022 15:35:40 +0100 Subject: [m-users.] CompCert C as a backend for Mercury ? In-Reply-To: <84C8A06F-D890-4BB3-99B4-E163B3AB5CBD@ziegemeyer.de> References: <1852B268-7416-4CE8-8EA9-7E1F21FE4D85@gmail.com> <5959083A-6BC9-43E8-89C3-851B38257973@gmail.com> <84C8A06F-D890-4BB3-99B4-E163B3AB5CBD@ziegemeyer.de> Message-ID: Thanks! > On 2 May 2022, at 15:35, Dirk Ziegemeyer wrote: > > Hi Sean, > > just in case you need some more distractions with Coq, I can recommend the Software foundations series [1], Volume 1 and 2. There is also a volume 0 "Discrete Math in Coq (alpha)" [2] which might be a good starting point. > > Dirk > > [1] https://softwarefoundations.cis.upenn.edu/ > [2] https://cs.pomona.edu/classes/cs54/book/ > > >> Am 02.05.2022 um 15:14 schrieb Sean Charles (emacstheviking) : >> >> IT was a long shit! >> >> :D >> >> However, the fruits of my exploration this morning are such that I have now become interested in Coq, like I need more distractions. >> >> THanks >> >> >>> On 2 May 2022, at 13:25, Julien Fischer wrote: >>> >>> >>> On Mon, 2 May 2022, Sean Charles (emacstheviking) wrote: >>> >>>> Today I learned of: https://compcert.org/ >>>> A formally verified C compiler. I wondered what exposure it has to the >>>> erudite members of this thread, and more to the point, has anybody >>>> tried to compile the output of the mercury compiler with it? >>> >>> Not to my knowledge. I was aware of its existence, but since its >>> license does not allow commercial use and one of the things I do with >>> Mercury is develop commercial software there didn't seem any compelling >>> reason to look into it further. >>> >>>> It would seem like a match made in heaven. >>>> I will be downloading this compiler to see what I can do with it. >>> >>> Just so you're aware: there's bit more to it than just doing >>> >>> $ ./configure --with-cc=ccomp >>> >>> If you search the git repository for when we added support for clang** >>> (circa 2011), that might give you some idea of what is required to use >>> a new C compiler. >>> >>> The obvious starting point is: can you successfully compile the Boehm >>> GC with it? >>> >>> Julien. >> >> _______________________________________________ >> users mailing list >> users at lists.mercurylang.org >> https://lists.mercurylang.org/listinfo/users > From van.ly at sdf.org Tue May 17 22:21:14 2022 From: van.ly at sdf.org (Van Ly) Date: Tue, 17 May 2022 12:21:14 +0000 (UTC) Subject: [m-users.] aarch64 runtime reports "caught segmentation violation" Message-ID: Hello, The aarch64 Mercury runtime on Rpi 4B 8GB is unable to run a "hello world" example. Any ideas on how to proceed? Details follow. ``` $ uname -a Linux charlie 5.15.32-v8+ #1538 SMP PREEMPT Thu Mar 31 19:40:39 BST 2022 aarch64 GNU/Linux $ cc --version cc (Debian 10.2.1-6) 10.2.1 20210110 Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ ./configure --prefix=/usr/X/Applications/mercury --with-cc=gcc --disable-csharp-grade --disable-java-grade --enable-minimal-install --enable-nogc-grades $ make $ make install $ mmc --version Mercury Compiler, version 22.01.1, on aarch64-unknown-linux-gnu Copyright (C) 1993-2012 The University of Melbourne Copyright (C) 2013-2022 The Mercury team $ nl hello.m 1 :- module hello. 2 :- interface. 3 :- import_module io. 4 :- pred main(io, io). 5 :- mode main(di, uo) is det. 6 :- implementation. 7 main(IO0, IO1) :- 8 io.write_string("Hello World!\n", IO0, IO1). $ mmc --make hello Making Mercury/int3s/hello.int3 Making Mercury/ints/hello.int Making Mercury/cs/hello.c Making Mercury/os/hello.o Making hello $ ./hello *** Mercury runtime: caught segmentation violation *** cause: address not mapped to object address involved: (nil) This may have been caused by a stack overflow, due to unbounded recursion. exiting from signal handler Segmentation fault ``` -- vl From objitsu at gmail.com Tue May 17 22:44:56 2022 From: objitsu at gmail.com (Sean Charles (emacstheviking)) Date: Tue, 17 May 2022 13:44:56 +0100 Subject: [m-users.] aarch64 runtime reports "caught segmentation violation" In-Reply-To: References: Message-ID: <36B6B64C-77E9-478D-B800-AE7621016B9B@gmail.com> Possibly *nix specific then, I ran the code fine on my M1 Mac mini with no issues; ➜ tmp cat hello.m :- module hello. :- interface. :- import_module io. :- pred main(io, io). :- mode main(di, uo) is det. :- implementation. main(IO0, IO1) :- io.write_string("Hello World!\n", IO0, IO1). ➜ tmp ./hello Hello World! ➜ tmp uname -a Darwin Seans-Mac-mini.local 21.4.0 Darwin Kernel Version 21.4.0: Fri Mar 18 00:47:26 PDT 2022; root:xnu-8020.101.4~15/RELEASE_ARM64_T8101 arm64 So, could be something in the specific set of libraries used on your platform I guess. Sorry can’t be more help. > On 17 May 2022, at 13:21, Van Ly wrote: > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jfischer at opturion.com Tue May 17 23:06:57 2022 From: jfischer at opturion.com (Julien Fischer) Date: Tue, 17 May 2022 23:06:57 +1000 (AEST) Subject: [m-users.] aarch64 runtime reports "caught segmentation violation" In-Reply-To: References: Message-ID: <95c5cd29-884e-1fe4-e240-242df3ad5622@opturion.com> Hi, On Tue, 17 May 2022, Van Ly wrote: > The aarch64 Mercury runtime on Rpi 4B 8GB is unable to run a > "hello world" example. Any ideas on how to proceed? Details follow. ... > $ mmc --make hello > Making Mercury/int3s/hello.int3 > Making Mercury/ints/hello.int > Making Mercury/cs/hello.c > Making Mercury/os/hello.o > Making hello > > $ ./hello > > *** Mercury runtime: caught segmentation violation *** > cause: address not mapped to object > address involved: (nil) > This may have been caused by a stack overflow, due to unbounded recursion. > exiting from signal handler > Segmentation fault The first question would be: what compilation grade is being used to compile hello.m? (Based on the above runtime error message and the platform, I guess it would be asm_fast.gc.) Some things to try: 1. Is this is an issue related to the use of shared Mercury libraries on that system? You can check by compiling with: $ mmc --mercury-linkage static hello and see if that then works. 2. Is it some issue with the C compiler on that system? Forcing -O0 in the C compiler when building and installing Mercury and also compiling your program would be the way to check that. The former can be done by placing a file named Mmake.params at the top-level of the Mercury source tree containing the following: EXTRA_CFLAGS = -O0 The latter can be done by: $ mmc --cflags "-O0" hello 3. If the compilation grade you are using (see above) is asm_fast.gc, then you may want to install and use a high-level C grade (e.g. hlc.gc) instead. They are generally a bit more forgiving of portability issues. Julien. From van.ly at sdf.org Wed May 25 22:30:55 2022 From: van.ly at sdf.org (Van Ly) Date: Wed, 25 May 2022 12:30:55 +0000 (UTC) Subject: [m-users.] aarch64 runtime reports "caught segmentation violation" In-Reply-To: <36B6B64C-77E9-478D-B800-AE7621016B9B@gmail.com> References: <36B6B64C-77E9-478D-B800-AE7621016B9B@gmail.com> Message-ID: <20895ba3-6c66-907b-8e7b-e63932bb9a66@SDF.ORG> I had no trouble with the Mercury runtime on amd64/netbsd9.2/gcc12.1. Possibly a Broadcom/Rpi4/aarch64/Linux/GCC specific combination. On Tue, 17 May 2022, Sean Charles (emacstheviking) wrote: > Possibly *nix specific then, I ran the code fine on my M1 Mac mini with no issues; -- vl From van.ly at sdf.org Thu May 26 17:39:23 2022 From: van.ly at sdf.org (Van Ly) Date: Thu, 26 May 2022 07:39:23 +0000 (UTC) Subject: [m-users.] aarch64 runtime reports "caught segmentation violation" In-Reply-To: <95c5cd29-884e-1fe4-e240-242df3ad5622@opturion.com> References: <95c5cd29-884e-1fe4-e240-242df3ad5622@opturion.com> Message-ID: <14b975ad-7c48-8f92-c188-97df9ba1b33f@SDF.ORG> Thankyou Julien for those suggestions. Rebuilding Mercury with Mmake.params "EXTRA_CFLAGS = -O0" after $ ./configure --prefix=path/to/mercury --disable-csharp-grade --disable-java-grade --enable-nogc-grades --enable-hlc-prof-grades --enable-hlc-low-level-debug-grades --with-cc="path/to/gcc" I was seeing progress lines like mmc --compile-to-c --grade asm_fast --mercury-linkage shared ... but I was able to get through the "Hello, World" example using $ mmc --mercury-linkage static hello which was failing before the "-O0" rebuild. I should have exhausted my options in the FAQ before bugging the list. https://mercurylang.org/information/doc-release/mercury_faq/index.html Will the configure option '--with-default-grade=reg' install and use a high-level C grade? On Tue, 17 May 2022, Julien Fischer wrote: > > Hi, > > On Tue, 17 May 2022, Van Ly wrote: ... >> $ ./hello >> >> *** Mercury runtime: caught segmentation violation *** >> cause: address not mapped to object ... > The first question would be: what compilation grade is being used to > compile hello.m? (Based on the above runtime error message and the > platform, I guess it would be asm_fast.gc.) > > Some things to try: > > 1. Is this is an issue related to the use of shared Mercury libraries > on that system? You can check by compiling with: > > $ mmc --mercury-linkage static hello > > and see if that then works. > > 2. Is it some issue with the C compiler on that system? Forcing -O0 in > the C compiler when building and installing Mercury and also compiling > your program would be the way to check that. > > The former can be done by placing a file named Mmake.params at the > top-level of the Mercury source tree containing the following: > > EXTRA_CFLAGS = -O0 > > The latter can be done by: > > $ mmc --cflags "-O0" hello > > 3. If the compilation grade you are using (see above) is asm_fast.gc, > then you may want to install and use a high-level C grade (e.g. hlc.gc) > instead. They are generally a bit more forgiving of portability issues. > > Julien. -- vl From novalazy at gmail.com Fri May 27 12:23:20 2022 From: novalazy at gmail.com (Peter Wang) Date: Fri, 27 May 2022 12:23:20 +1000 Subject: [m-users.] aarch64 runtime reports "caught segmentation violation" In-Reply-To: <14b975ad-7c48-8f92-c188-97df9ba1b33f@SDF.ORG> References: <95c5cd29-884e-1fe4-e240-242df3ad5622@opturion.com> <14b975ad-7c48-8f92-c188-97df9ba1b33f@SDF.ORG> Message-ID: <20220527122320.GD1569@gmail.com> On Thu, 26 May 2022 07:39:23 +0000 Van Ly wrote: > > Thankyou Julien for those suggestions. > > Rebuilding Mercury with Mmake.params "EXTRA_CFLAGS = -O0" after > > $ ./configure --prefix=path/to/mercury --disable-csharp-grade > --disable-java-grade --enable-nogc-grades --enable-hlc-prof-grades > --enable-hlc-low-level-debug-grades --with-cc="path/to/gcc" > > I was seeing progress lines like > > mmc --compile-to-c --grade asm_fast --mercury-linkage shared ... > > but I was able to get through the "Hello, World" example using > > $ mmc --mercury-linkage static hello > > which was failing before the "-O0" rebuild. > > I should have exhausted my options in the FAQ before bugging the > list. > > https://mercurylang.org/information/doc-release/mercury_faq/index.html > > Will the configure option '--with-default-grade=reg' install and use a > high-level C grade? Hi, I can confirm that asm_fast.gc crashes on Aarch64 with gcc 10.2. asm_fast.gc does work on Aarch64 with gcc 8.3.0, so something changed between those versions. For now, please run configure with the --with-llds-base-grade=reg option, and avoid asm_fast grades when specifying grades directly. Peter (Note that I'm testing under emulation but that should not matter.)