From nobody Thu Mar 07 18:18:24 2024 X-Original-To: freebsd-toolchain@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TrHc312BFz5DYMP for ; Thu, 7 Mar 2024 18:18:27 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TrHc30DQDz4Spv; Thu, 7 Mar 2024 18:18:27 +0000 (UTC) (envelope-from dim@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709835507; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3bCPXVlLUotD81yEer7b0JUf2PEZK5ik1wz/5Mikp5g=; b=QwGoCuRc6gEtc7qN//ig/jmcB7Gx5OvHX9lztZJR9DtGYiHohwefVsbOl5Ws1v57+5L/aw Nu77V3kBcNwG9Qv3QDQLIKg/N7cnRkGXLc3l+BKcLLeW7fG0urZe0in6jXC5yRDPsKTA8Z 2O2WjJAL/HL8HzsNgwLXIGYsfuo5tJxQY0h6w/Q4QNi2BRlWVz7PK8dWpdZ8QRl9B86hLY Q4+mka/i3jJ8Uthw1NzlyvvCXlsrtxCe+gqPnFw8KcfHimSKGZKji8Fqqz6yg1j9i39DNz v+lCYST2GekeXEwlKKTHJ5TTDfAlzXzVlpIEXJm7hgdh7E0x/9qBllyHyr44iw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1709835507; a=rsa-sha256; cv=none; b=ZpCABCK6X1uNwRpeKlxmH56Maqqm3N3AFnAD79vkBUK9tUfiGPYQMm9Xg2dBdZeNCM56S5 4m61luWYv/XY8v2VYH/K2Ghgvef2+SrZFuVfXByDjQNd0D91cL4MGnPxCVvgX7bGT6SCbn IBFVUbXe0Jjbdq1HAj9K3zfBncsiqpu5VlqeiQ05mc0Zntd98QqokK1dZMLH3FzvkwbGD7 mFxhy7gIu25HRsngS/9yQVV+3v0zdAE8OZE3HTLvAvXVPJoulI0UwfAwQmYYwU+vjMYD/H hwmEdxtRdyNKBaro2CN2KGTQs1zLLrx7LgRELHU7A4h42pwaZAlTaTj4yTKZ4g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709835507; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3bCPXVlLUotD81yEer7b0JUf2PEZK5ik1wz/5Mikp5g=; b=sDfJnbKfevSN503zn5B226sJtI8GoO0Fregw5l4aOdm13704KCaFqrzfsUSQTjmM3DD5ND JKJnaAiZrUwp22x3P710ccLwEJVoXxik1cVpcXwZikfkdPTBxiIwqVs9iSzGi8y2rTCFzM prUAZudRUay+y2gpZIahMZuYygOL9GRHqkTQR4n2GzQ2YSuU8DqQCO/rkOzqrp6e1oeEPa rTt86Acj6utnsZ2SrPkY67z+1lOgDzVstcbCSy7VvoQUqYr/lh6Mv+u88CmvLFyIcdJ2NL K05t/9h+BJbWdCSw7YfJrfjtf4HDhX2FBHkWsqtb+nWC2tMTQJnJfLMTcdn9ZA== Received: from tensor.andric.com (tensor.andric.com [87.251.56.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "tensor.andric.com", Issuer "R3" (verified OK)) (Authenticated sender: dim) by smtp.freebsd.org (Postfix) with ESMTPSA id 4TrHc267qbz1C5W; Thu, 7 Mar 2024 18:18:26 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from smtpclient.apple (longrow.home.andric.com [192.168.0.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 8349A4EF4C; Thu, 7 Mar 2024 19:18:24 +0100 (CET) Content-Type: text/plain; charset=utf-8 List-Id: Maintenance of FreeBSD s integrated toolchain List-Archive: https://lists.freebsd.org/archives/freebsd-toolchain List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-toolchain@freebsd.org X-BeenThere: freebsd-toolchain@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6.1.1\)) Subject: Re: System llvm18 libc++: what will the FreeBSD LIBCXX_HARDENING_MODE be set to (one of: none, fast, extensive, debug)? From: Dimitry Andric In-Reply-To: <8938DA5F-2AE1-4EBC-8D40-303397636D0E@yahoo.com> Date: Thu, 7 Mar 2024 19:18:24 +0100 Cc: FreeBSD Toolchain Content-Transfer-Encoding: quoted-printable Message-Id: <42A0D17F-2DB3-4214-A0A1-116895AD8837@FreeBSD.org> References: <8938DA5F-2AE1-4EBC-8D40-303397636D0E.ref@yahoo.com> <8938DA5F-2AE1-4EBC-8D40-303397636D0E@yahoo.com> To: Mark Millard X-Mailer: Apple Mail (2.3731.700.6.1.1) On 7 Mar 2024, at 05:32, Mark Millard wrote: >=20 > 2 of the notes for libc++ 18 for the harding mode are: >=20 > QUOTE > Enabling hardening has no impact on the ABI. > . . > Since the static and shared library components of libc++ are built by = the vendor, setting this macro will have no impact on the hardening mode = for the pre-built components. Most libc++ code is header-based, so a = user-provided value for _LIBCPP_HARDENING_MODE will be mostly respected. > END QUOTE >=20 > The modes are described by: >=20 > QUOTE > =E2=80=A2 Unchecked mode/none, which disables all hardening checks. > =E2=80=A2 Fast mode, which contains a set of security-critical = checks that can be done with relatively little overhead in constant time = and are intended to be used in production. We recommend most projects = adopt this. > =E2=80=A2 Extensive mode, which contains all the checks from fast = mode and some additional checks for undefined behavior that incur = relatively little overhead but aren=E2=80=99t security-critical. = Production builds requiring a broader set of checks than fast mode = should consider enabling extensive mode. The additional rigour impacts = performance more than fast mode: we recommend benchmarking to determine = if that is acceptable for your program. > =E2=80=A2 Debug mode, which enables all the available checks in the = library, including internal assertions, some of which might be very = expensive. This mode is intended to be used for testing, not in = production. > END QUOTE >=20 > Technically, DEBUG builds and non-DEBUG world builds could have = different FreeBSD settings for LIBCXX_HARDENING_MODE I suppose. >=20 > QUOTE (relative to non-prebuilt components) > Users wishing for a different hardening level to their vendor default = are able to control the level by passing one of the following options to = the compiler: >=20 > -D_LIBCPP_HARDENING_MODE=3D_LIBCPP_HARDENING_MODE_NONE > -D_LIBCPP_HARDENING_MODE=3D_LIBCPP_HARDENING_MODE_FAST > -D_LIBCPP_HARDENING_MODE=3D_LIBCPP_HARDENING_MODE_EXTENSIVE > -D_LIBCPP_HARDENING_MODE=3D_LIBCPP_HARDENING_MODE_DEBUG > END QUOTE In the llvm-18-update branch, I have updated the libc++ __config_site = file to use the upstream defaults for when assertions are enabled: = https://github.com/DimitryAndric/freebsd-src/blob/llvm-18-update/lib/libc%= 2B%2B/__config_site#L39 This is emitted by upstream's CMakeLists.txt for libcxx: = https://github.com/llvm/llvm-project/blob/release/18.x/libcxx/CMakeLists.t= xt#L784 The comment there says LIBCXX_ENABLE_ASSERTIONS will be deprecated, but = I think having the extensive option on by default is fine, certainly for = -CURRENT. Note, I have no particular objection if we would "crank down" the level = to "fast" for -STABLE or -RELEASE branches. But I don't know any = specific performance difference statistics for these various levels. Note also that our earlier libc++ builds did not have assertions = enabled, so it may be worth some discussion whether it is desirable at = all. -Dimitry