-
Notifications
You must be signed in to change notification settings - Fork 3
Compiling JavaScriptCore library for Amiga
This is one of the first and more crucial parts of the work we are doing with the port.
When we started with this work we didn't have a finalised and stable development environment, so one of the first things we did was to create a branch out of the morphos_2.36.8 branch which we called amigaos_2.36.8 and searched for every change that was applied for MorphOS and add there the AmigaOS precompiler checks as well (https://github.com/walkero-gr/webkitty/commit/495541e290cbbcd787f76725c66bbf32bc12fcab).
When the development environment was working well, we started compiling the project using the Makefile rule jscore-amigaos. A lot of changes needed to be done, some of them worth mentioning below. What we tried to do is to make as small changes as possible, so as to retain the code being able to be updated in the future, without a lot of work needed.
One of the trickiest things we needed to make sure is that we compiled with the right C library. You see we mainly compile the project with afxgroup's clib2, and the reasons are:
- it is complete enough for the work
- it is AmigaOS 4 focused
- it is open sourced and we can make changes where needed
The problem is that the AmigaOS 4 development environment and compilers by default are using newlib. So, we had to make sure that -mcrt=clib2 was applied everywhere needed. Some of the early errors we had was about that. Now the Makefile is set in a way that we can use both clib2 or newlib by setting the USE_CLIB2=YES|NO at the make call. By default clib2 is used.
Then we changed the code as needed in many places as we were compiling the JSC (#8, #10, #11). During this work, we created missing SDK methods like GetLength() and ConvertTagList() to be as similar to the MorphOS ones, based on their description in MorphOS SDK documentation.
One of the problems that troubled us a lot until we find the solution and how to overcome it was the MemoryPressureHandler comment 1329703864. This problem was not easy to fix as we had all the necessary fixes in place, but still, some files were not used during the compilation. The solution was to force the usage of Source/WTF/wtf/PlatformMorphOS.cmake in the file PlatformJSCOnly.cmake.
This as a solution didn't seem right and after a deeper search we realised that this is the only way to make it work since we do not build the whole WebKit but just the JSC one. The goal for this is to build the JSC binary, along with some test binaries, so as to test and be sure JSC and WTF work before continuing with the port. So this change was applied and the compilation continued. More information can be found at comment 1351388355
After that, the linker complained about libdl library. With clib2 this is not needed since everything is included. In the makefile there is a rule that builds a dummy library for replacing libdl, which can be run with make Dummy/libdummy.a which then needs o be copied to the SDK local/clib2/lib folder.
The next problem we faced was the missing dprintf() method from the clib2 (https://github.com/afxgroup/clib2/issues/76). To overcome that blockage we added the necessary methods (https://github.com/afxgroup/clib2/pull/77) and since then it was merged into clib2 beta8 branch.
After all this work the JSC compiles fine with clib2 and the binaries are working quite well, but some crashes are happening. Please find information about that at https://github.com/walkero-gr/webkitty/wiki/JavaScriptCore-Tests.