_MR_atomic_sub_int symbol not found on macOS
poldy opened this issue · 4 comments
The full error message is:
dyld[47054]: symbol not found in flat namespace '_MR_atomic_sub_int'
I installed Mercury from homebrew using brew install mercury
. This is on an M1 Mac running the latest Ventura. A sequential "hello world" program compiles and runs no problem. And indeed, when I compile the Dining Philosophers sample code with either --parallel
or --grade hlc.par.gc
it compiles ok, but when I run it gives the above error message.
I assume that you are using clang as the C compiler here. The problem is simply that there is not a definition of MR_atomic_sub_int for clang on Aarch64 based systems in the runtime; we will need to add one.
(There is a generic definition for GCC which should work on M1 based systems, although I've not tested that myself,
so installing GCC via homebrew and using that may be an option.)
Yes, I'm using clang.
I added the bare minimum of <stdatomic.h> code to get the build to complete. It could be quite a lot of work, but there are some nice features that Mercury could make use of if you introduced a minimum required version of C11.
Requiring the use of C11 is not an option in the short to medium term. MSVC only just gained some initial experimental support for C11/C17 style atomics (and I gather even that is not complete). It would make sense for us to starting C11
atomics on platforms where they are supported (i.e. in preference to the inline assembly).