Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSC: port #7

Open
1 task done
walkero-gr opened this issue Oct 30, 2022 · 13 comments
Open
1 task done

JSC: port #7

walkero-gr opened this issue Oct 30, 2022 · 13 comments
Assignees

Comments

@walkero-gr
Copy link
Collaborator

walkero-gr commented Oct 30, 2022

  • JavaScriptCore (JSC) changes should be minimal

  • most features may be disabled (recommended). keep anything OFF in OptionsMorphOS as OFF. curl, cairo, hyphen, webp, harfbuzz should be OK to disable at this stage, drag support, content extensions off, whatever is disabled for MORPHOS_MINIMAL should be off

  • Log the process at repo wiki pages

@walkero-gr walkero-gr self-assigned this Oct 30, 2022
@walkero-gr
Copy link
Collaborator Author

Did the first changes to have the MorphOS changes being applied to AmigaOS port as well
Commit 9ad3e57

@walkero-gr
Copy link
Collaborator Author

Right now we are in a position where the JSC compiles but we get a lot of "undefined references" from the linker.

Some of them are:

/opt/code/webkitty/Source/WTF/wtf/MemoryPressureHandler.cpp:335: undefined reference to '__gthread_once'
/opt/code/webkitty/Source/WTF/wtf/MemoryPressureHandler.cpp:335: undefined reference to '__gthread_mutex_unlock'
/opt/code/webkitty/Source/WTF/wtf/MemoryPressureHandler.cpp:335: undefined reference to 'dprintf'

/opt/code/webkitty/Source/WTF/wtf/text/AtomString.h:311: undefined reference to 'ubrk_open_72'
/opt/code/webkitty/Source/WTF/wtf/text/AtomString.h:311: undefined reference to 'ubrk_setText_72'
/opt/code/webkitty/Source/WTF/wtf/text/AtomString.h:311: undefined reference to 'ubrk_close_72'
/opt/code/webkitty/Source/WTF/wtf/text/AtomString.h:311: undefined reference to 'ubrk_getRuleStatus_72'
/opt/code/webkitty/Source/WTF/wtf/text/AtomString.h:311: undefined reference to 'ubrk_next_72'
/opt/code/webkitty/Source/WTF/wtf/text/AtomString.h:311: undefined reference to 'ubrk_current_72'
/opt/code/webkitty/Source/WTF/wtf/text/AtomString.h:311: undefined reference to 'uloc_setKeywordValue_72'

/opt/code/webkitty/Source/WTF/wtf/unicode/icu/CollatorICU.cpp:270: undefined reference to 'ucol_setAttribute_72'
/opt/code/webkitty/Source/WTF/wtf/unicode/icu/CollatorICU.cpp:270: undefined reference to 'ucol_close_72'
/opt/code/webkitty/Source/WTF/wtf/unicode/icu/CollatorICU.cpp:270: undefined reference to 'uiter_setString_72'
/opt/code/webkitty/Source/WTF/wtf/unicode/icu/CollatorICU.cpp:270: undefined reference to 'ucol_strcollIter_72'
/opt/code/webkitty/Source/WTF/wtf/unicode/icu/CollatorICU.cpp:270: undefined reference to 'uiter_setUTF8_72'

A full list of all the errors can be found at
https://os4coding.net/node/2535

@3246251196
Copy link
Member

3246251196 commented Nov 22, 2022

@walkero-gr
At the very least, the __gthread*() methods should be available by linking with "-athread=native", right?

For the ICU I see that:
ppc-amigaos-nm -g libicui18n.a | ppc-amigaos-c++filt | grep 'ucol_close_72'
shows that 'ucol_close_72' is available there, at least with the version of the lib i have built.

@afxgroup
Copy link

ubrk* functions should be from ICU lib too. So most probably you have an old (or too new) version of icu

@walkero-gr
Copy link
Collaborator Author

@3246251196 @afxgroup Thank you for your replies. I have an idea of what I possibly did wrong. I will work on it to be fixed.

@walkero-gr
Copy link
Collaborator Author

walkero-gr commented Nov 28, 2022

@3246251196 @afxgroup I did a few changes with my last commit at f301583
and now when it builds I get only this error, that I am trying to figure out what is it and how to fix it

Source/WTF/wtf/CMakeFiles/WTF.dir/./MemoryPressureHandler.cpp.obj: In function `_ZN3WTF21MemoryPressureHandler9singletonEv':
/opt/ppc-amigaos/ppc-amigaos/include/c++/11.3.0/bits/unique_lock.h:133: undefined reference to `_ZN3WTF21MemoryPressureHandler28morphosMeasurementTimerFiredEv'
/opt/ppc-amigaos/lib/gcc/ppc-amigaos/11.3.0/../../../../ppc-amigaos/bin/ld: bin/LLIntSettingsExtractor: hidden symbol `main' in Source/JavaScriptCore/CMakeFiles/LLIntSettingsExtractor.dir/llint/LLIntSettingsExtractor.cpp.obj is referenced by DSO
/opt/ppc-amigaos/lib/gcc/ppc-amigaos/11.3.0/../../../../ppc-amigaos/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
Compiling jsc failed!

It seems that this refers to the following method at https://github.com/walkero-gr/webkitty/blob/amigaos_2.36.8/Source/WTF/wtf/morphos/MemoryPressureHandlerMorphOS.cpp#L43

Any thoughts on if we need it and if we have something similar for OS4?

@3246251196
Copy link
Member

@walkero-gr
, sorry, I have no idea what a Memory Pressure Handle is even meant to be. I am guessing it is some sort of widget/gadget showing memory use?

@walkero-gr
Copy link
Collaborator Author

Some more info on the problem with the /opt/ppc-amigaos/ppc-amigaos/include/c++/11.3.0/bits/unique_lock.h:133: undefined reference to _ZN3WTF21MemoryPressureHandler28morphosMeasurementTimerFiredEv'` issue, which I believe is necessary to know about and have that written.

I created the PlatformAmigaOS.cmake file like the one MorphOS has at https://github.com/walkero-gr/webkitty/blob/amigaos_2.36.8/Source/WTF/wtf/PlatformMorphOS.cmake

This file includes the morphos files since those files could be common without specific changes for the AmigaOS 4.

When I compile the JSCore with
-DPORT=JSCOnly
as it is in the https://github.com/walkero-gr/webkitty/blob/amigaos_2.36.8/Makefile, then PlatformAmigaOS.cmake is not linked and used, so the
MemoryPressureHandler::morphosMeasurementTimerFired
is not defined and the compilation fails.

By searching deeper I found that if I go to
https://github.com/walkero-gr/webkitty/blob/amigaos_2.36.8/Source/WTF/wtf/PlatformJSCOnly.cmake#L118
and add the following
morphos/MemoryPressureHandlerMorphOS.cpp
then the required function is found and the compilation continues. That part of the code is used because we compile it setting the CMAKE_SYSTEM_NAME as Generic at the https://github.com/walkero-gr/webkitty/blob/amigaos_2.36.8/amigaos.cmake.in#L1

But for me, this doesn't seem right, and if I understand correctly, the PlatformAmigaOS.cmake is not used because we compile the JSCore only and for that the PlatformJSCOnly.cmake is used. So that makes sense why the Source/WTF/wtf/morphos/MemoryPressureHandlerMorphOS.cpp is not used at all, and why we get that error.

So I went and discussed that with Jacek and he told me the following:

Building JSCoreOnly lets you build a JSC binary which you can use to verify that JSCore and WTF are working. Again, you do not have to do this, but almost all of the work you are doing now will be used later. The MorphOS target likely does not build. I did not need it ever since I’ve released the initial 1.0.

So, as much as I understand we actually need to add the necessary files in PlatformJSCOnly.cmake so to make it compile and then continue with the work, and this might be not needed in the future and remove it because we won't actually use this compilation again.

So, what I plan to do in the following days is to do these changes and move on with the project and see how far it gets. For now, I know that it looks for AvailMem() which seems to not exist, so I need to figure this out. Will let you know how it goes.

@walkero-gr
Copy link
Collaborator Author

walkero-gr commented Dec 20, 2022

After the latest changes I did at https://github.com/walkero-gr/webkitty/pull/11 to overcome the above issue, there compilation continued until it stopped with the following complain.

/opt/ppc-amigaos/ppc-amigaos/SDK/local/clib2/lib/libdl.so: undefined reference to `__getreent'
/opt/ppc-amigaos/ppc-amigaos/SDK/local/clib2/lib/libdl.so: undefined reference to `__translate_unix_to_amiga_path_name_r'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
Compiling jsc failed!
make: *** [Makefile:53: jscore-amigaos] Error 1

Talking with @afxgroup he told me that libdl should not be used with his clib2 that we use. So I tried to find a way to overcome this issue. Unfortunately, I couldn't figure out how to remove the linking to libdl, but I saw at the Makefile that Jacek has a rule named Dummy/libdummy.a (https://github.com/walkero-gr/webkitty/blob/amigaos_2.36.8/Makefile#L212). This is used in other rules as well, where the full WebKit compilation is done.

So, I did there the necessary changes and created a dummy libdl which I copied in the local/clib2/lib/ inside the SDK. That fixed the issues, until the next one which is the following:

Source/WTF/wtf/CMakeFiles/WTF.dir/./AutomaticThread.cpp.obj: In function `_ZN3WTF6Detail15CallableWrapperIZNS_15AutomaticThread5startERKNS_14AbstractLockerEEUlvE_vJEED2Ev':
/opt/code/webkitty/Source/WTF/wtf/Function.h:47: undefined reference to `dprintf'
Source/WTF/wtf/CMakeFiles/WTF.dir/./ConcurrentPtrHashSet.cpp.obj: In function `_ZN3WTF6VectorISt10unique_ptrINS_20ConcurrentPtrHashSet5TableESt14default_deleteIS3_EELj4ENS_15CrashOnOverflowELj16ENS_10FastMallocEE14expandCapacityILNS_13FailureActionE0EEEPS6_jSC_':
/opt/code/webkitty/Source/WTF/wtf/Vector.h:(.got2+0x1c): undefined reference to `dprintf'
Source/WTF/wtf/CMakeFiles/WTF.dir/./CountingLock.cpp.obj: In function `_ZN3WTF13LockAlgorithmIjLj1ELj2ENS_12CountingLock9LockHooksEE10unlockSlowERNS_6AtomicIjEENS3_8FairnessE':
/opt/code/webkitty/Source/WTF/wtf/LockAlgorithmInlines.h:106: undefined reference to `dprintf'
Source/WTF/wtf/CMakeFiles/WTF.dir/./CrossThreadTaskHandler.cpp.obj: In function `_ZN3WTF6Detail15CallableWrapperIZNS_22CrossThreadTaskHandlerC4EPKcNS2_25AutodrainedPoolForRunLoopEEUlvE_vJEED0Ev':
/opt/code/webkitty/Source/WTF/wtf/Function.h:47: undefined reference to `dprintf'
Source/WTF/wtf/CMakeFiles/WTF.dir/./FastBitVector.cpp.obj: In function `_ZN3WTF22FastBitVectorWordOwner13setEqualsSlowERKS0_':
/opt/code/webkitty/Source/WTF/wtf/FastBitVector.cpp:36: undefined reference to `dprintf'
Source/WTF/wtf/CMakeFiles/WTF.dir/./Gigacage.cpp.obj:/opt/code/webkitty/Source/WTF/wtf/Gigacage.cpp:38: more undefined references to `dprintf' follow
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
Compiling jsc failed!
make: *** [Makefile:53: jscore-amigaos] Error 1

Unfortunately, the new clib2 misses the dprintf() which is required at this point (AmigaLabs/clib4#76).
All my changes are now in the pull request https://github.com/walkero-gr/webkitty/pull/11

@walkero-gr
Copy link
Collaborator Author

Thanks to @3246251196 who added dprintf() in clib2 I was unblocked and continued the work on the topic. I managed to have JSC compiling and the library generated. All the changes are in #11

Running some of the test binaries, most complain that the JIT is not enabled, which is not going to be enabled for now. So we have t ignore them. But there is the testapi binary that checks the library, and all of them pass just fine, until there is a crash complaining something about pthread. Crash log attached below.

Crashlog_pthread_id_1_2022-12-22_22-32-49.txt

This needs to be investigated but before that I would like to see how it works with newlib.

@walkero-gr
Copy link
Collaborator Author

Started working with JSC and newlib. The compilation fails with the following methods missing
mmap(), pthread_getattr_np() and pthread_attr_getstack()

Although mmap() can be ignored, the other two can not be skipped. I already informed newlib maintainer for ideas or for adding those methods in a newer version.

@cpm1
Copy link

cpm1 commented Dec 27, 2022

Those pthread functions should probably get implemented in our own pthreads.library implementation, which is part of the SDK and can be found in the OS4 repository. If you were talking about Fredrick as the "newlib maintainer", then he would also be able to add those functions to pthreads.library.

@walkero-gr
Copy link
Collaborator Author

Added as much information for this work as possible at the wiki page
https://github.com/walkero-gr/webkitty/wiki/Compiling-JavaScriptCore-library-for-Amiga

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants