From owner-freebsd-arch@freebsd.org Fri Jun 29 08:00:26 2018 Return-Path: Delivered-To: freebsd-arch@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 28AFF1034349 for ; Fri, 29 Jun 2018 08:00:26 +0000 (UTC) (envelope-from lists@eitanadler.com) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id B158580EA5 for ; Fri, 29 Jun 2018 08:00:25 +0000 (UTC) (envelope-from lists@eitanadler.com) Received: by mailman.ysv.freebsd.org (Postfix) id 67E5B1034348; Fri, 29 Jun 2018 08:00:25 +0000 (UTC) Delivered-To: arch@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 454CC1034341 for ; Fri, 29 Jun 2018 08:00:25 +0000 (UTC) (envelope-from lists@eitanadler.com) Received: from mail-yw0-x22a.google.com (mail-yw0-x22a.google.com [IPv6:2607:f8b0:4002:c05::22a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D7E5E80EA1 for ; Fri, 29 Jun 2018 08:00:24 +0000 (UTC) (envelope-from lists@eitanadler.com) Received: by mail-yw0-x22a.google.com with SMTP id w13-v6so3102874ywa.5 for ; Fri, 29 Jun 2018 01:00:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eitanadler.com; s=0xdeadbeef; h=mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=Kn28wyWKx9423cTVrRmoVCVjuh9pfOEBORHzi+nngxo=; b=Jm3ztOz7OExPkKtR4F1YI4O0FFA/l58pJLDQIYkDZNK9JChUBVaYfAmoOrH3ejGqLI fFcWLBlhcfcwjWZVe1d9vLh0BDAMKnziYomrHtT88pFof9lHvVNQvg6MQaz1MCRl/5pn h8LDr2CzqZySv5I1yF0rls+YYTxZExb01nlGc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to :content-transfer-encoding; bh=Kn28wyWKx9423cTVrRmoVCVjuh9pfOEBORHzi+nngxo=; b=oVtmjCyOJfkIrhBVeeodA23vsV5L/gwOfqPCCjxffmOtjCkgjrB4zn4F/MC3Dolrul dFDCRfCvgXVvGHnHY+7VmisOcXoCJ+kpBmBgqCftYuQQl9hzNe0yHv7M3aa28WhGEm7/ wb5FZeykiHsoI7S1faiF8geKMNBOom6jjblDoXSNU/QZLqsZ8mSJXuv+jxbE91f5swMi HzejGvAXV2NjcHeTlTDYc9XFtqkjPShuI8ZhEPC1UOuC7H7M+SFWwVen9AmPepr4iv+n ClP36mitho8hbamorIp5xZKnI84rGoIpq9mkgDmtISPCbndQzoxpgEdaqKW4zDJMUoaE HneQ== X-Gm-Message-State: APt69E1HMd21iKBsXJyD7ny0zf0Bjh0vrnH/tsj2yPSETRltpUXBolCQ 2wmYO6lgTIOQLmuxghaHCdkfWFU1w7eYq7lMIQvLENtU X-Google-Smtp-Source: AAOMgpeQpm3No+qVhodQ48tyrDBnbQn49MOEXEOwYQiYHZXOvkWERCM2ud2DkQURC+9i0xZ5hRyZ6t7Jm8JzSt4t0Zo= X-Received: by 2002:a0d:e848:: with SMTP id r69-v6mr6829826ywe.19.1530259223894; Fri, 29 Jun 2018 01:00:23 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a25:ef50:0:0:0:0:0 with HTTP; Fri, 29 Jun 2018 00:59:53 -0700 (PDT) From: Eitan Adler Date: Fri, 29 Jun 2018 00:59:53 -0700 Message-ID: Subject: C++ in the kernel? To: "freebsd-arch@freebsd.org" , David Chisnall , Justin Hibbits , Maxim Sobolev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jun 2018 08:00:26 -0000 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