From owner-freebsd-current@freebsd.org Thu Oct 5 23:00:26 2017 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6E7D4E449EF for ; Thu, 5 Oct 2017 23:00:26 +0000 (UTC) (envelope-from davidtgoldblatt@gmail.com) Received: from mail-wm0-x230.google.com (mail-wm0-x230.google.com [IPv6:2a00:1450:400c:c09::230]) (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 EFF5765069; Thu, 5 Oct 2017 23:00:25 +0000 (UTC) (envelope-from davidtgoldblatt@gmail.com) Received: by mail-wm0-x230.google.com with SMTP id t69so4593688wmt.2; Thu, 05 Oct 2017 16:00:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=m3ctSadbE0w1fwgAlbODWFAg6/Dlpm1WeYBp6eN3uX8=; b=p9gEXSLNthjB6NxqyCdo3FXBkqKr/7qCoTIEOQzo+3nstAaN6GxQzdXM1Q8fnsOIZK 5FcdljIGiSLxwdSSxaog6akbLnF+4bUJbnOCcUIQYjybN/LSpN2N+j1Gr962P6iHC3eL fMRkbDTyJtF/iCLH3kDdoXSrK7C3fQsSpA4xYfMg2QaBSxYMM8IXT3k9N1F1kEd/gkuJ e7vmCLpVY/w1WP8vO50WKCekGfKgevkQx+bpxnVLc8xeSyUwbSEJl2ykVn+XPblnSxzg wBJWF4/9xpimB0ec7bPm0OB8IVxh7ZR1GMSGR3Y5PDyKPV7MfDzBppiBqdqoWLZXKVjD +Z8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=m3ctSadbE0w1fwgAlbODWFAg6/Dlpm1WeYBp6eN3uX8=; b=DNOl6Q/2Yhb3n2vLOFiAfZHiQPga2ic0S4ZxXoInaJMZUf2yXE8z6hpbxJYXp543Z5 DDr8PkyUUa6ukWuVrVyWZhRNlo9GkeuJkClnqwmnL7uRj9JfGQ2GqrGJs0U/Z0jldgc0 xolbpnFKPjc4VTxgX1QrNcSdH/5JcLr3G+Hgx8XvjuArbD9EIySBhD/nitVrikfLtMW1 utqTdXlE+2qRdRuL8LGFriJxoQlyN7C/FJ04JoYS5qSiXmAh+WCGNwo+gbFRNSlsOavF lebu89eDflQEVdtmebBFIkNlCpWNqaAUmmQYWpDnqeStFII9LBvY/eKKHOJOfGvXyZ5N Yxcw== X-Gm-Message-State: AMCzsaUZmTmGLWa3Wf/Ru1NKMeg6HeeNujJKojPKmfyFhokGbqqC8Gfz McVDHK7lxbVvVpdoqRIrRu6d/iX4kx6U0og5Kjk= X-Google-Smtp-Source: AOwi7QCMBTy5s472R6VHimBuytjQp8tKanPUD09eRb0/Q8QVWuAfQ2HUG9xRZ7EvRkgAuuv3PbchogZucYHJtK0K9Fc= X-Received: by 10.28.29.68 with SMTP id d65mr69849wmd.93.1507244424085; Thu, 05 Oct 2017 16:00:24 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.21.196 with HTTP; Thu, 5 Oct 2017 16:00:23 -0700 (PDT) In-Reply-To: References: <1507238672.86205.250.camel@freebsd.org> From: David Goldblatt Date: Thu, 5 Oct 2017 16:00:23 -0700 Message-ID: Subject: Re: C++ in jemalloc To: Warner Losh Cc: Ian Lepore , FreeBSD Current Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Oct 2017 23:00:26 -0000 (apologies if you receive this twice; I subscribed to the list in order to flip the needs-moderation bit for my posts). So it sounds like C++03 (or rather, the version of C++ supported by g++ 4.2) will be fine. Is C++11 a no-go, without breaking libc on non-Clang architectures? (It isn't clear to me if having to use the ports gcc to build was unfortunate or unacceptable from FreeBSD's POV). C++11 would be sort of helpful in the core implementation (we currently have to maintain our own backport of C11 atomics, for instance), but would be really helpful in the test suite (because of how much syntactically simpler it is to, say, spin up a bunch of threads to hammer a local instance of a data structure). On Thu, Oct 5, 2017 at 2:33 PM, Warner Losh wrote: > > > On Thu, Oct 5, 2017 at 2:24 PM, Ian Lepore wrote: > >> On Thu, 2017-10-05 at 14:01 -0700, Warner Losh wrote: >> > On Thu, Oct 5, 2017 at 11:59 AM, David Goldblatt >> > wrote: >> > >> > > >> > > Hi all, >> > > >> > > The jemalloc developers have wanted to start using C++ for a while, to >> > > enable some targeted refactorings of code we have trouble maintaining >> due >> > > to brittleness or complexity (e.g. moving thousand line macro >> definitions >> > > to templates, changing the build->extract symbols->rebuild mangling >> scheme >> > > for internal symbols to one using C++ namespaces). We'd been holding >> off >> > > because we thought that FreeBSD base all had to compile on GCC 4.2, in >> > > order to support some esoteric architectures[1]. >> > > >> > > The other day though, I noticed that there is some C++ shipping with >> > > FreeBSD; /usr/bin/dtc and /sbin/devd (the former claiming in the >> HACKING >> > > document that C++11 is a minimum for FreeBSD 11). This, combined with >> the >> > > fact that ports now points to a modern gcc, makes me think we were >> > > incorrect, and can turn on C++ without breaking FreeBSD builds. >> > > >> > > Am I right? Will anything break if jemalloc needs a C++ compiler to >> build? >> > > We will of course not use exceptions, RTTI, global constructors, the >> C++ >> > > stdlib, or anything else that might affect C source or link >> compatibility. >> > > >> > > Thanks, >> > > David (on behalf of the jemalloc developers >> > > >> > > [1] That being said, we don't compile or test on those architectures, >> and >> > > so probably don't work there in the first place if I'm being honest. >> But >> > > we'd also like to avoid making that a permanent state of affairs that >> can't >> > > be changed. >> > > >> > For FreeBSD 10 and earlier, this would likely break all architectures >> that >> > aren't x86. Starting in FreeBSD 11, arm and powerpc are supported by >> clang, >> > but not super well. For FreeBSD 12, we're getting close for everything >> > except sparc64 (whose fate has not yet been finally decided). >> > >> > So for the popular architectures, this arrangement might work. For >> building >> > with external toolchains, it might also work. Some of the less popular >> > architectures may be a problem. >> > >> > Does that help? It isn't completely cut and dried, but it should be >> helpful >> > for you making a decision. >> > >> > Warner >> >> Wait a sec... we've been compiling C++ code with gcc 4.2 since like >> 2006. What am I missing here that keeps this answer from being a >> simple "go for it"? >> >> Just stay away from C++11 features and gcc 4.2 should work fine. (DTC >> may require C++11, but that was likely the author's choice given that >> there was no requirement for it to work on pre-clang versions of >> freebsd). >> > > It's the ubiquity of C++11 is why I didn't just say "Go for it". > > Warner >