KEMBAR78
Support KolibriOS by phcoder · Pull Request #4663 · scummvm/scummvm · GitHub
Skip to content

Conversation

@phcoder
Copy link
Contributor

@phcoder phcoder commented Jan 26, 2023

No description provided.

@phcoder phcoder changed the title Support KolibriOS NOTFORMERGE: Support KolibriOS Jan 26, 2023
@phcoder phcoder changed the title NOTFORMERGE: Support KolibriOS Support KolibriOS Jan 26, 2023
Copy link
Member

@sev- sev- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work. Have some notes/questions.

It's not critical so can be skipped
Copy link
Member

@lephilousophe lephilousophe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks quite good to me regarding what can be done.

The toolchain quality is so low that I wonder if we can name it like that...
Sadly, this forces us to add cruft to our configure script.

I would have proposed to reject this platform if you would not have spent so much time on it.

I will try to make a build and test my ideas later today.


namespace {

// opendir/readdir are buggy. And they encourage using syscalls. Whatever
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow. The libc doesn't even work...

.path = path
};

asm volatile ("int $0x40" : "=a" (error_code), "=b" (num_read) : "a" (70), "b" (&request) : "memory");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _ksys70 function seems to do this. This would avoid using asm here.
But note they don't provide a wrapper for subfunction 1...

#include <kos32sys.h>
#include <stdio.h>

/* This is just a small wrapper so that the main scummvm is loaded as dll. */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add the explanation you put in your commit message here as well?

configure Outdated
append_var DEFINES "-U__WIN32__ -U_Win32 -U_WIN32 -U__MINGW32__ -UWIN32 -DKOLIBRIOS=1 -D_POSIX_C_SOURCE=1 -D_XOPEN_SOURCE=1"
append_var CXXFLAGS "-I${KOS32_SDK_DIR}/sources/newlib/libc/include -I${KOS32_SDK_DIR}/sources/zlib -I${KOS32_SDK_DIR}/sources/libstdc++-v3/include -fno-ident -fomit-frame-pointer"
append_var LDFLAGS "-nostdlib -shared -Wl,-shared -Wl,-s -Wl,-T${KOS32_SDK_DIR}/sources/newlib/dll.lds -Wl,--entry,_DllStartup -Wl,--image-base,0 -L${KOS32_SDK_DIR}/lib -L/home/autobuild/tools/win32/mingw32/lib -L/home/autobuild/tools/win32/lib"
append_var SYSLIBS "-ldll -lstdc++ -lsupc++ -lgcc -lc.dll -Dmain=xmain"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So basically, kos32-g++ is not a proper C++ compiler...
I would try to add a -specs=file to CXXFLAGS. This is exactly the purpose of this file: specifying the system libraries needed.
Normally, GCC has the correct spec file bundled in.
More info on this here.

configure Outdated
append_var DEFINES "-DUNCACHED_PLUGINS"
_mak_plugins='
PLUGIN_EXTRA_DEPS = $(EXECUTABLE)
PLUGIN_LDFLAGS += -nostdlib -shared -Wl,--entry,_DllStartup -Wl,-q,--retain-symbols-file,$(srcdir)/backends/plugins/elf/plugin.syms -Wl,--enable-auto-import -shared ./libscummvm.a -ldll -lstdc++ -lsupc++ -lgcc -lc.dll
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we already link scummvm with libstdc++ and so on, I suspect we will end up with several stdc++ implementations running at once which may not share their internal state.

configure Outdated
fi
if test "$_jpeg" = yes ; then
append_var LIBS "$JPEG_LIBS -ljpeg"
if test "$_host_os" = kolibrios; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of doing this check everywhere and as it's only a matter of adding a suffix, maybe it's easier to create a _libext variable set to .dll in the case of KOS and append it everytime we use the -l flag?
This would not work if the library is not for a DLL.

Another way would be to add -ljpeg to JPEG_LIBS when handling --with-jpeg-prefix=, setting it in KOS case with whatever is works with the toolchain.
Just before checking presence, add:

if [ -z "$JPEG_LIBS" ]; then
JPEG_LIBS=-ljpeg
fi

and remove -ljpeg in cc_check and in append_var.

Exporting symbols from main binary is cumbersome on KolibriOS but importing
from another dll is fine. So we make scummvm core into a dll and add a thin
launcher for it.
@lephilousophe
Copy link
Member

I managed to do something somewhat cleaner.
Not perfect but the platform is far from being clean...
https://github.com/lephilousophe/scummvm/tree/kos32

@sev-
Copy link
Member

sev- commented Feb 5, 2023

Thank you!

@sev- sev- merged commit 31071d7 into scummvm:master Feb 5, 2023
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

Successfully merging this pull request may close these issues.

4 participants