`assert` should be made AOT friendly and runtime independent

When generating an object file, currently the function assert (from core.sc) causes it to fail. This is problematic because it is used by several of the Scopes libraries. Most of the libraries already take steps to avoid depending on the runtime when possible, and it seems that often only assert is blocking. There are two areas of improvement:

  • avoid print. It causes a serialization error because of the usage of Value (although that could perhaps be improved), and also uses strings.
  • remove API functions. One of those is sc_write, which is included with print. The others are used to raise SIGABORT.

Making the code compile is fairly easy if we're not aiming to make it freestanding friendly, it's just a matter of fixing up print. I haven't found a way to call abort() using an LLVM intrinsic for example (eliminating the need for an API function), and of course we have no way to print to the console then. So in this case I don't know what should be done. At the moment the solution is to replace assert via set-globals! before importing any module, but that's less than desirable.

Assigned to
5 months ago
5 months ago
No labels applied.