[Dlang-internal] druntime: proposed changes in code organization

Johan j at j.nl
Sun Dec 17 09:37:33 UTC 2023


On Saturday, 16 December 2023 at 19:42:43 UTC, Denis Feklushkin 
wrote:
> On Saturday, 16 December 2023 at 18:59:50 UTC, Johan wrote:
>
>>> Make sure what you read benefits list:
>>> https://github.com/dlang/dmd/pull/15822#issue-1996484133
>>
>> Much of your list are not benefits, just removing things from 
>> the source code that you find "ugly" I guess. For example, 
>> removing `version (Linux):` is not a benefit; it's just 
>> developer taste, with no benefit for the user.
>
> This is actually one (little) benefit, because currently you 
> cannot write a program for Windows that will use some druntime 
> Linux structures for parsing something like net traffic, core 
> dumps, etc. You will need to duplicate Linux (or Posix) 
> structures for that.
>
> This is a meaningless block that has formed historically 
> because it was easier and faster to implement by this way

If it's meaningless, it can be removed today without your big 
file change. Can it?

>> I understand that for you currently the situation is not nice. 
>> But it is not a good solution to make life good for you, and 
>> make it worse for the status quo. A custom druntime or 
>> non-standard OS is not a very common case.
>
> (At first, I don't see what currently druntime is distributed 
> as ready for cross-compilation bundle. I.e., ldc2 archieve 
> isn't contains druntime binary for Windows, Linux and *BSDs 
> simultaneously, right? In this case we should not change 
> anything particularly much in the config)

For cross-compilation, you don't need druntime _binaries_. The 
binaries are only needed for linking. But if linking with 
druntime/phobos is needed, then LDC has a specific tool to make 
it easier for users to build druntime+phobos for a different 
target platform. And then you just specify the location of those 
binaries on the cmdline. Yes, this can be simplified for 
continued use by editing ldc2.conf, but it is not required to do 
so; nor is it needed to have a separate druntime source tree 
stored somewhere else.

> As for me, we don't know common this case or not. "Non-standard 
> OS" includes thousands variations of hardware+software from 
> realtime embedded software to modern gaming consoles support or 
> so on.
>
> But it will be simpler to be always at second place (after 
> invincible C and C++) on D support implementation timeline in 
> the event of the appearance of some new (revolutionary, of 
> course) devices or OS inventions. So I think I guess that the 
> impact of such a changes will be great.

You make it sound as if it is currently impossible to implement 
druntime for linux, Apple, Windows, Solaris, OpenBSD, NetBSD, 
FreeBSD, DragonFly, Android, ... x86, x86_64, arm32, aarch64, 
riscv, ... Yet, the implementation for all these exists.

> ldc2.conf will obtain 3-6 sections (i.e. about ~50 lines total) 
> for common platforms like Linux, Windows and *BSD. Is that too 
> expensive?

Please show us the PR where you fix LDC, Dub, and GDC for the 
problems you are introducing.

Thanks,
   Johan



More information about the Dlang-internal mailing list