Date: Wed, 7 Oct 2020 00:48:37 -0700 From: Mark Millard <marklmi@yahoo.com> To: Kamal Prasad <kamalpr@gmail.com> Cc: Warner Losh <imp@bsdimp.com>, "freebsd-arm@freebsd.org" <freebsd-arm@freebsd.org> Subject: Re: generic q on freebsd Message-ID: <A0D6771B-8DF0-4BBB-A30A-30937DFC4FB8@yahoo.com> In-Reply-To: <C7F844A0-CC32-4570-A255-FAE34A906D0B@gmail.com> References: <CAK=yUGJG=oVfy7XfnMkXB6XRBjbYhaVR8Zdv7R5wGqKjB=425Q@mail.gmail.com> <CANCZdfoaZYnsb6str64ezF0O4ORSQG%2BqMh9r0%2B42GqEQjBThOg@mail.gmail.com> <C4AE5DDB-005E-45B1-8BF6-FC28647B4E90@gmail.com> <C7F844A0-CC32-4570-A255-FAE34A906D0B@gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2020-Oct-7, at 00:20, Kamal Prasad <kamalpr@gmail.com> wrote: > Android has a libc++. I think that can be ported into the kernel. > https://developer.android.com/ndk/guides/cpp-support=20 So far as I know, Android has libc++ but not in its kernel. FreeBSD has libc++, but not in its kernel. In both contexts, libc++ is from LLVM. In both contexts, userspace programs do not need libc++ to be in the kernel. In both contexts, the C++ involved is a "hosted implementation" instead of being limited to a "Freestanding implemenation". See https://en.cppreference.com/w/cpp/freestanding about freestanding vs. hosted. In part: QUOTE In a freestanding implementation execution may happen without an = operating system END QUOTE > thanks > -kamal >=20 >> On Oct 7, 2020, at 12:40 PM, Kamal Prasad <kamalpr@gmail.com> wrote: >>=20 >> Thanks. Why is it difficult to port the C++ runtime to the kernel? I = mean what is the technological hurdle? >>=20 >> thanks >> -kamal >>=20 >>=20 >>=20 >>=20 >>=20 >>=20 >> On Oct 6, 2020, at 10:53 PM, Warner Losh <imp@bsdimp.com> wrote: >>>=20 >>> On Tue, Oct 6, 2020, 11:03 AM Kamal R. Prasad <kamalpr@gmail.com> = wrote: >>>=20 >>>> hello, >>>>=20 >>>> i am curious if it is possible to compile c++ code inside the = freebsd >>>> kernel. >>>>=20 >>>=20 >>>=20 >>> Possible? Yes, with restrictions. Easy? No. >>>=20 >>> There are a number of restrictions on doing this. There is no C++ = runtime >>> support provided in stock FreeBSD. You have to write your own, or = find >>> someone else that has published theirs. And the code is likely to be >>> compiler dependent. People have done it and talked or blogged about = it. >>>=20 >>> Generally, if you don't use exceptions, templates, RTTI, expressions = that >>> result in the automatic allocation of objects, have large objects (> = 1k) on >>> the stack, etc, it may be possible. I tried it in the 90s and had to = write >>> just a few routines to make simple classes work, but there's a lot = of >>> dragons here and very little C++ code is written these days w/o = reference >>> to the standard libraries, which aren't present in the kernel. >>>=20 >>> Some googling turns up: >>> https://github.com/adamlsd/libcpp.ko from 6 years ago >>> = https://lists.freebsd.org/pipermail/freebsd-arch/2018-June/019069.html = has >>> some details from 2 years ago about command line args you might = need. >>>=20 >>> Many have tried. Few have succeeded. Those that have write all their = code >>> to conform to a subset of the language. Few have had success moving = C++ >>> code for other purposes into the kernel, though if it was written = using the >>> proposed (but never ratified) eC++ (embedded subset), then chances = are >>> greater. >>=20 =3D=3D=3D Mark Millard marklmi at yahoo.com ( dsl-only.net went away in early 2018-Mar)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?A0D6771B-8DF0-4BBB-A30A-30937DFC4FB8>