Repairing Tao3D

Wednesday, July 19, 2017

I have a presentation to give for the flight recorder. Of course, I want to do this presentation with Tao3D. And then, there is a problem that it no longer works well on my Mac, because LLVM 3.9.

LLVM has always been a severe problem with the maintenance of Tao3D, ELFE or XL. It keesp changing all the time, so I had to write a special "adapter layer" called llvm-crap.h to deal with all the gratuitous changes that LLVM brings to its API with each new release.

The skip to LLVM 3.9 is all the more painful that I have not maintained that code since something like LLVM 3.6. So I'm three iterations behind. I did some work back on ELFE to try and at least make it compile, but it still does not run. Just to give an idea, https://github.com/c3d/elfe/commit/451a51707f4861bdd4c68a26fc7ba809b7b6d45a this is the amount of change required just to compile!!!

I painfully backported these changes to XL, the version of XL used in Tao3D. But it still does not pass the tests. For a while, I thought that ELFE would help me, since it did pass its tests. Until I realized that the tests only passed in full-interpreted mode. At -O2, they all fail, just the same way as they do in XLR. Bus error and things like that.

Browsing the source code, I noticed that there was a way to get an error out of LLVM now, which is good. It is somewhat inelegant, but what do you expect:

    text errorString;
    engineBuilder.setErrorStr(&errorString);

Then, this gets me an error that the JIT is not linked. Grumble grumble. After a detour through obsolete stuff on Google talking about calling ForceJITLinking::ForceJITLinking(), I figured I needed to #include <llvm/ExecutionEngine/MCJIT.h>.

Still not good enough. The tests keep crashing. Apparently, the code dies with a SIGSEGV somewhere in that code:

        compiler->optimizer->run(*function);

Problem is that the function was verified. So why should it crash?