Spivoxity / obc-3

Oxford Oberon-2 compiler
38 stars 7 forks source link

Building on FreeBSD/ppc64 #23

Closed Spivoxity closed 3 years ago

Spivoxity commented 5 years ago

Building environment: obc: 3.1alpha OS: FreeBSD/PowerPC64 C Compiler: GCC (Version 4.21, 5.40 & 6.40) Ocaml: Ocaml Version 4.4

Instead of the anticipated successful build output, I get "Fatal error: Couldn't find primitive *".

There are several warnings during the build about "cast from pointer to integer of different size" but no build errors. I've tried different GCC versions, but always with the same results.

This may be a problem specific to 64-bit PowerPC.

GCC6 build log attached.

Spivoxity commented 5 years ago

I've marked this report as a 'task' and as of 'minor' importance because it doesn't represent a problem with an issued release on a supported platform. I'm not inclined to add ppc64 as an architecture because it is essentially obsolete, but you are welcome to try to get OBC to build for it.

The Keiko abstract machine assumes 32-bit pointers, and on amd64 there's a workaround (enabled by defining M64X32) that involves allocating memory in the bottom 2GB of the address space. You'll need to enable this for your platform by adding to the configure script appropriately.

Then in runtime/gc.c, you'll need to add code that calls mmap appropriately. LuaJIT uses a similar scheme, and the following post on the mailing list contains hints for what is needed.

http://lua-users.org/lists/lua-l/2010-10/msg00625.html

If you succeed in this, you will get a version of Keiko based on a bytecode interpreter (rather than the JIT-based runtime that exists on supported platforms). But it will still run Oberon programs at reasonable speed.

Feel free to e-mail me (mike@cs.ox.ac.uk) if you need more help.

Spivoxity commented 5 years ago

Todo: add config checks or assertions to ensure we don't get this far with attempts to build the runtime system on a machine with 64 bit pointers without enabling M64X32.

Spivoxity commented 5 years ago

My experiments show that in the current development version, the bytecode interpreter obx builds without problem under release 11.1 of FreeBSD/amd64, without needing the mmap changes contained in the mailing list post above. The JIT-based runtime builds after a minor config change to enable the use of mprotect. See revision 0d896fd.

On ppc64, the JIT isn't going to work without adding a low-level code generator, but the bytecode interpreter ought to be easy to get going.

lenoil98 commented 3 years ago

Resolved! Fixed issue by enabling M64X32 for powerpc64.

Spivoxity commented 3 years ago

Good to hear. I'll close this now.