Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Jun 2018 00:59:53 -0700
From:      Eitan Adler <lists@eitanadler.com>
To:        "freebsd-arch@freebsd.org" <arch@freebsd.org>, David Chisnall <theraven@freebsd.org>,  Justin Hibbits <jhibbits@freebsd.org>, Maxim Sobolev <sobomax@freebsd.org>
Subject:   C++ in the kernel?
Message-ID:  <CAF6rxgnBx66EhEfvw4GTetKbCsa%2B_OEPgYWXHF_6qQPcRrbWKQ@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
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 he=
aders somewhat less C++-hostile that they=E2=80=99d 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 co=
ncerns raised were uncertainty about handling of exceptions and also lack o=
f the real stable ABI for the C++. Each compiler seems to have its own conv=
entions, which might vary even between compiler revisions. https://youtu.be=
/JPQWQfDhICA?t=3D51m55s What might be possible, however, is to have particu=
lar C++ "runtime" as a module itself, which is then would be used by the ot=
her modules that are compiled with that particular C++ compiler.

>> Most kernels that use C++ require -fno-rtti -fno-exceptions, so don=E2=
=80=99t rely on a runtime.  The ABI concerns were a problem 20 years ago, b=
ut *NIX systems have kept the same C++ ABI since everyone[1] adopted the It=
anium ABI.  [1] Well, almost everyone.  AArch32 has a slightly different AB=
I, 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 ne=
ed to get the subset of libc++ that I need working.

--=20
Eitan Adler



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAF6rxgnBx66EhEfvw4GTetKbCsa%2B_OEPgYWXHF_6qQPcRrbWKQ>