:: Re: [DNG] Something completely diff…
Inizio della pagina
Delete this message
Reply to this message
Autore: Didier Kryn
Data:  
To: dng
Oggetto: Re: [DNG] Something completely different OS
Le 30/05/2024 à 13:20, Kevin Chadwick via Dng a écrit :
> On 30/05/2024 10:11, Didier Kryn wrote:
>> But in any case the language does not solve the problem of stack protection
> Do you mean Rust? Otherwise please elaborate as I am quite sure that Ada solves
> the problem of stack protection?


    I don't know anything of Rust, except it has interesting features
like declaring that a variable can only be assigned a value once. Also
that it has been admitted in the Linux kernel.

    Concerning stack protection, AFAIU, the stack is managed in
collaboration by the kernel, the compiler and the runtime library. The
only Ada compiler I have ever used is Gnat, which is part of GCC. In
GCC, source code from all languages is first converted to a common
intermediate code, and I don't know which part of the stack management
is specific to each language and which part is common.

    Concerning the Gnat runtime, I have, a dozen years ago, spent a
pretty large amount of time to produce a native, sysrooted GCC compiler
providing C, and Ada, statically linked against and linking to Musl
libc. When doing this, I had to hack a little bit the Gnat runtime
because it bypassed the public API of glibc to pike inside its
internals, which I find disapointing.

    BTW, I addressed questions to the authors/maintainers of Gnat, on
the GCC mailing list and never got any answer.

>> Don't forget, also,  that all languages rely upon the C runtime
>> library, which is an essential layer between applications and the kernel.
> Certainly the practical situation today for Linux but it isn't a technical OS
> requirement. I have also heard it said that libc doesn't actually need to be
> written in C.


    Sure. And I have met several times a colleague who was even writing
a kernel in Ada. Certainly a runtime library written in Ada would be a
very nice object, provided it is actually written "natively" in Ada, and
not barely translated from C. In Ada, it is very easy to invoque a
function with the API of another language, like C, C++, Fortran... It is
part of the language. Therefore interfacing to the kernel API is easy,
even easier than in C because a data type may be very conveniently
declared to match a hardware register.

    What prevents writing a runtime library in Ada, which would bypass
the C library and interface directly to the kernel, is purely
sociologic/economic. Even a brilliant software engineer like the main
author of Musl libc seems rather ignorant of the qualities of this
language. Private companies, working for the industry might do it, or
maybe have done, but their products are for sale and maybe even secret.

--     Didier