C++ in the kernel?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

C++ in the kernel?

Eitan Adler-4
This was the contents of a conversation on a different list. Figured
it was more appropriate here:

>> We are experimenting with a C++ library for systems programming and are interested in trying it in the FreeBSD kernel.  Has anyone managed to run C++ code in the kernel before and perhaps have patches to make the kernel headers somewhat less C++-hostile that they’d be willing to share?

>> A friend gave a WIP talk at BSDCan a few years ago doing this very thing.  You can find his work at https://github.com/adamlsd/libcpp.ko

>> I believe few times I've seen this discussion over the years the main concerns raised were uncertainty about handling of exceptions and also lack of the real stable ABI for the C++. Each compiler seems to have its own conventions, which might vary even between compiler revisions. https://youtu.be/JPQWQfDhICA?t=51m55s What might be possible, however, is to have particular C++ "runtime" as a module itself, which is then would be used by the other modules that are compiled with that particular C++ compiler.

>> Most kernels that use C++ require -fno-rtti -fno-exceptions, so don’t rely on a runtime.  The ABI concerns were a problem 20 years ago, but *NIX systems have kept the same C++ ABI since everyone[1] adopted the Itanium ABI.  [1] Well, almost everyone.  AArch32 has a slightly different ABI, but it has also been stable for a similar length of time.

>> Thanks, the include directory of that repo looks to be exactly what I need to get the subset of libc++ that I need working.

--
Eitan Adler
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: C++ in the kernel?

Eitan Adler-4
On 29 June 2018 at 00:59, Eitan Adler <[hidden email]> wrote:

> This was the contents of a conversation on a different list. Figured
> it was more appropriate here:
>
>>> We are experimenting with a C++ library for systems programming and are interested in trying it in the FreeBSD kernel.  Has anyone managed to run C++ code in the kernel before and perhaps have patches to make the kernel headers somewhat less C++-hostile that they’d be willing to share?
>
>>> A friend gave a WIP talk at BSDCan a few years ago doing this very thing.  You can find his work at https://github.com/adamlsd/libcpp.ko
>
>>> I believe few times I've seen this discussion over the years the main concerns raised were uncertainty about handling of exceptions and also lack of the real stable ABI for the C++. Each compiler seems to have its own conventions, which might vary even between compiler revisions. https://youtu.be/JPQWQfDhICA?t=51m55s What might be possible, however, is to have particular C++ "runtime" as a module itself, which is then would be used by the other modules that are compiled with that particular C++ compiler.
>
>>> Most kernels that use C++ require -fno-rtti -fno-exceptions, so don’t rely on a runtime.  The ABI concerns were a problem 20 years ago, but *NIX systems have kept the same C++ ABI since everyone[1] adopted the Itanium ABI.  [1] Well, almost everyone.  AArch32 has a slightly different ABI, but it has also been stable for a similar length of time.
>
>>> Thanks, the include directory of that repo looks to be exactly what I need to get the subset of libc++ that I need working.

Copan used C++ in the kernel to support RAIDCore, which was a software RAID
stack.  (Written by ex-Adaptec people, I believe they were acquired by
Ciprico, which was then acquired by Dot Hill, which was acquired by
Seagate.  No idea whether the software is still active/maintained.)

RAIDCore didn't use new/delete or exceptions, so it wasn't too difficult to
get it running in the kernel on FreeBSD.  (It was originally written for
Windows and then ported to Linux, and we later ported it to FreeBSD at
Copan.)  The porting effort probably happened in the 2007-2008 timeframe.

RAIDCore was proprietary and the support code was never open sourced, so
there's nothing to share unfortunately.  I don't think there was much to
it, but my memory on that is fuzzy.

I guess the point is basic C++ in the kernel can be done without a huge
effort, and it was in a shipping product for years.


--
Eitan Adler
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: C++ in the kernel?

Sebastian Huber-4
In reply to this post by Eitan Adler-4
Hello,

I know some users which wrote network interface drivers in C++ using the
FreeBSD network stack ported to the real-time operating system RTEMS
(libbsd). Some header files are not very C++ friendly, e.g.

https://lists.freebsd.org/pipermail/freebsd-hackers/2014-September/046091.html

--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : [hidden email]
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: C++ in the kernel?

Sebastian Huber-4
In reply to this post by Eitan Adler-4
On 29/06/18 09:59, Eitan Adler wrote:
> This was the contents of a conversation on a different list. Figured
> it was more appropriate here:
>
>>> We are experimenting with a C++ library for systems programming and are interested in trying it in the FreeBSD kernel.  Has anyone managed to run C++ code in the kernel before and perhaps have patches to make the kernel headers somewhat less C++-hostile that they’d be willing to share?
>>> A friend gave a WIP talk at BSDCan a few years ago doing this very thing.  You can find his work at https://github.com/adamlsd/libcpp.ko
>>> I believe few times I've seen this discussion over the years the main concerns raised were uncertainty about handling of exceptions and also lack of the real stable ABI for the C++. Each compiler seems to have its own conventions, which might vary even between compiler revisions. https://youtu.be/JPQWQfDhICA?t=51m55s What might be possible, however, is to have particular C++ "runtime" as a module itself, which is then would be used by the other modules that are compiled with that particular C++ compiler.
>>> Most kernels that use C++ require -fno-rtti -fno-exceptions, so don’t rely on a runtime.  The ABI concerns were a problem 20 years ago, but *NIX systems have kept the same C++ ABI since everyone[1] adopted the Itanium ABI.  [1] Well, almost everyone.  AArch32 has a slightly different ABI, but it has also been stable for a similar length of time.
>>> Thanks, the include directory of that repo looks to be exactly what I need to get the subset of libc++ that I need working.

FreeBSD started to use the Concurrency Kit in the kernel. Concurrency
Kit seems to be intentionally incompatible to C++:

https://github.com/concurrencykit/ck/pull/89

--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : [hidden email]
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "[hidden email]"