Question about rtlib

For other topics related to the FreeBASIC project or its community.
Imortis
Posts: 1422
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Question about rtlib

Postby Imortis » Sep 01, 2017 16:23

Can anyone in the know give me a reason why FB's rtlibs SHOULD NOT be re-written in FB? Same with fbgfx? Is is just a case of the amount of time that would take? Any insight is welcome.
angros47
Posts: 1304
Joined: Jun 21, 2005 19:04

Re: Question about rtlib

Postby angros47 » Sep 01, 2017 16:47

GCC provides some optimizations that FreeBasic doesn't have, making the code more efficient.

Anyway, rewriting the libraries in FreeBasic would be possible (FreeBasic has all the features of C, and many features of C++, so any C code could be ported in FreeBasic), but it would not give any advantage, since the code would be just as difficult to understand as currently is (having to mess with OS-specific APIs, pointers, and conditional compiling). So, I can ask, in return... is there any reason why FB's rtlibs SHOULD be re-written in FB? I doubt, actually.
dkl
Site Admin
Posts: 3156
Joined: Jul 28, 2005 14:45
Location: Germany

Re: Question about rtlib

Postby dkl » Sep 01, 2017 17:08

The only problem I see is that it uses lots of POSIX/libc/kernel (Linux, FreeBSD, etc.) system headers, which are not yet available as .bi and are rather hard to auto-translate and maintain in my experience. But since such bindings are missing for FB anyways (including support for multiple libc's on Linux, for example), if they were added, they could aswell also be used for the rtlib/gfxlib.

Also it's ~50k lines of code to convert, which has to be done first (probably lots of it could be automated though, just like header translation).
Imortis
Posts: 1422
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Re: Question about rtlib

Postby Imortis » Sep 01, 2017 17:42

angros47 wrote: So, I can ask, in return... is there any reason why FB's rtlibs SHOULD be re-written in FB? I doubt, actually.


It would greatly simplify the toolchain required to build FBC itself. And, if optimizations are wanted, FBC still has the GCC backend. The code could be run through that for the rtlib and fbgfxlib to get the optimizations.
angros47
Posts: 1304
Joined: Jun 21, 2005 19:04

Re: Question about rtlib

Postby angros47 » Sep 01, 2017 17:46

It could be a good reason. Although the 64 bit version requires GCC anyway
marcov
Posts: 2352
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: Question about rtlib

Postby marcov » Sep 01, 2017 18:20

dkl wrote:The only problem I see is that it uses lots of POSIX/libc/kernel (Linux, FreeBSD, etc.) system headers, which are not yet available as .bi and are rather hard to auto-translate and maintain in my experience.


You don't need all of that. A core set is like 200 lines (which is /general/ unix, not just linux), and some structs (DIR, Stat, statfs) etc.
Terminal is quite a lot more though, but still counted in hundreds of lines rather than thousands. It is true though that headers (and, more importantly separating them in general *nix and target dependent bits) is the bulk of the work.

Or the FB rts requires a whole lot more than FPC.

Anyway, if anybody wants to try, I'll assist. Just show me how to get a development system installed, and let's go.
dkl
Site Admin
Posts: 3156
Joined: Jul 28, 2005 14:45
Location: Germany

Re: Question about rtlib

Postby dkl » Sep 01, 2017 18:35

That's probably true, chances are it only really needs a few declarations from here and there, not full headers.
angros47
Posts: 1304
Joined: Jun 21, 2005 19:04

Re: Question about rtlib

Postby angros47 » Sep 01, 2017 18:44

Since we are talking about it... any chances that the patches made by Monochromator for the DOS version could be added? Adding support for threads and dynamic linking would greatly improve the DOS port, in my opinion
Imortis
Posts: 1422
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Re: Question about rtlib

Postby Imortis » Sep 01, 2017 19:33

marcov wrote:Anyway, if anybody wants to try, I'll assist. Just show me how to get a development system installed, and let's go.


I do want to try. I will let you know if I need the assist. I assume that is is mostly going to be time consuming. Thanks for the offer.
counting_pine
Site Admin
Posts: 5793
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Re: Question about rtlib

Postby counting_pine » Sep 09, 2017 15:16

It might be good to use FB to augment the runtime library, even if not completely rewrite it.

A couple of advantages I can think of:
- code would be easier for the FB community to read and change/add to.
- we could provide access to object-orientated code, or even just code in namespaces without having to worry about getting the ABI compatibility right in C.

We could start adding includes in FB that feature classes, or even just support for functions in namespaces, and use FB to provide the implementations for those functions/classes in the rtlib.
angros47
Posts: 1304
Joined: Jun 21, 2005 19:04

Re: Question about rtlib

Postby angros47 » Sep 09, 2017 15:42

A thing that I would love to add (and that is written in pure FB) is the sound driver I have written (I'd like to have it to work as the graphic library, that is linked only if the program needs it)
TeeEmCee
Posts: 191
Joined: Jul 22, 2006 0:54
Location: Auckland

Re: Question about rtlib

Postby TeeEmCee » Sep 11, 2017 13:36

That's entirely separate. If it's totally portable, works, and has an agreeable API I don't see why a sound library shouldn't be standard.

Personally I'm not interested in rewriting the rtlib for the sake of it, but I am interested in good system headers.
dkl attempted automatic translation of system headers with fbfrog, but it isn't currently used for any of them.
The question is, do we want to minimise labour and go the automatic approach, with the translated headers resembling the originals, or do we want to manually deduplicate the common parts and force them to conform to the same layout? Looks like everyone is in favour of the latter, which basically requires hand-writing/translating everything. It's largely the current approach, but half-hearted: there are still a bunch of differences between different systems, not much deduplication, and it's a bit of a mess. It would be great if we could factor out common POSIX declarations and automatically translate everything else.

Imortis: I recommend you accept marcov's offer if you're serious about this. He knows about this better than anyone here, and you probably don't know the mess you're getting into.
Imortis
Posts: 1422
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Re: Question about rtlib

Postby Imortis » Sep 11, 2017 15:23

TeeEmCee wrote:Imortis: I recommend you accept marcov's offer if you're serious about this. He knows about this better than anyone here, and you probably don't know the mess you're getting into.


I have no doubt I will need help at some point. That is why I told him I would ask when I needed it.
marcov
Posts: 2352
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: Question about rtlib

Postby marcov » Sep 11, 2017 17:32

TeeEmCee wrote:Imortis: I recommend you accept marcov's offer if you're serious about this. He knows about this better than anyone here, and you probably don't know the mess you're getting into.


Every system is different, and truely, I only know one RTS and have little FB experience. FB comes with its own sets of constraints.

Anyway the best thing would be to first try to reduce the non FB part of the RTS as much as possible. It would make dual maintenance easier and reduce the size of the FB->C interface, making dual maintenance easier.

Return to “Community Discussion”

Who is online

Users browsing this forum: No registered users and 3 guests