From nobody Fri Jun 19 16:29:46 2026 X-Original-To: freebsd-hackers@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 4ghjjm4WTVz6jbQ2 for ; Fri, 19 Jun 2026 16:29:48 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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 "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ghjjm3grJz3MYX; Fri, 19 Jun 2026 16:29:48 +0000 (UTC) (envelope-from dim@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1781886588; 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=uklMtfP+KhZA82CmuKj/7Cah46QQFqaAQf8Xp3B10pI=; b=UpGbT9QifpWMPUmlLImdf8hMaCmpdJ6hJVAPFsHEf19dFW0gaOmnghmEJ78Qbie90Jj1Au AW3NSMUw9RlgDnJ3Bar2j/Pi026VMZLjuQFGfRum+3ZH0KcTMT3fpdqUbhV9Tx09SkuTWT Is+aQOtA41WSC1yhJ0tam84+s+ks0Zp0MowaYWVgXVmtuRbB/Q8rnwtPTh1Wo1q2ocgCAq 62wbZBYxjP9SblYnvG4kCJm2vrLtV/guI/wyv+5p8dKT7u/Z26EA9BdsrUjpon3EGTxbCy DrLSOD/rPlQC2FBMy+JoHmJLDIdd9KDqGV9FIW2Qlu3yXWC045K7NKQ37uuhhQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1781886588; a=rsa-sha256; cv=none; b=S9/AFtcpv8n93Ce96oeGTMZLeHJWxaR3/uI7jw7xES3HUJDmEh0/et+WiSf77n8GvkUIGB BxVWBOjfHwlp9iLxXVc3dQMP9zMZce4ggruOm9amV+yTlXIJoAaEb4dkYh4S60HBUFyAO5 sKui9B6XGGsLkgXmLqY1EJi+m+/YCwTPtss1dzV+LYrgjG+VqUhd6ic2zARK6jNMEcedPh QSL1t6gx1kP+F+BkWMVvSviQANLPyz9qPI3lNYMOSateF4X+hGkFPJ8O8An7PhjsMvb5xP aqZqWp73FDKB2MEa9m4OrZT6UH1QO5udnar6GKP7gnQE3ZDkKS2BvJeT6dyvxQ== 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=1781886588; 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=uklMtfP+KhZA82CmuKj/7Cah46QQFqaAQf8Xp3B10pI=; b=RIKfe6+XdnEuM3gNQClroVkQxDQK4BV3OBtLJauy0yNMFoDsP2g9w6a9DV9UAiGYEv/N51 PQ9z9eGpiSZzZhCUHQO2F4yewTGfA9N53zRP37ByxPQiw23ZUfp5rBeV6qjtxaXz3Oii4U OMcTFfchkJKZ/BHxegEJnlW7M3nJuwrIeFflM3hLNvE5rg/di7QnxUggIeo7oc9S8bfHvB eBj2lKFpC4IoNNVq2ySsX0RLfPpXHum1r8y1OVtKnw+RDjsGzD1mS7OOQmFpn+y/BTvc26 P4H+BMyrmq6rKEMzbk+UoE911Oq/XvelDgmCFXAci0n47r7/mKApVgmaULSF/A== 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 ECDSA (prime256v1) client-digest SHA256) (Client CN "tensor.andric.com", Issuer "YE2" (not verified)) (Authenticated sender: dim) by smtp.freebsd.org (Postfix) with ESMTPSA id 4ghjjm1JcXzwPR; Fri, 19 Jun 2026 16:29:48 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from smtpclient.apple (bladnoch-wifi.home.andric.com [192.168.0.21]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 2C9317B660; Fri, 19 Jun 2026 18:29:47 +0200 (CEST) Content-Type: text/plain; charset=us-ascii List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.700.81.1.8\)) Subject: Re: Do we use -fno-omit-frame-pointers by accident? From: Dimitry Andric In-Reply-To: Date: Fri, 19 Jun 2026 18:29:46 +0200 Cc: freebsd-hackers@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <936E25CE-860F-4187-ADBC-B842E89B8DAE@FreeBSD.org> References: To: Martin Cracauer X-Mailer: Apple Mail (2.3826.700.81.1.8) On 19 Jun 2026, at 17:24, Martin Cracauer wrote: >=20 > Martin Cracauer wrote on Thu, Jun 18, 2026 at 04:51:41PM -0400:=20 >> I was about to propose on BSDCan to turn on -fno-omit-frame-pointer >> for the base system userland and most ports.[*] >>=20 >> So I went benchmarking the performance impact. >>=20 >> I discovered that CFLAGS+=3D-fno-omit-frame-pointer changes nothing >> about our binaries and shared libraries. = CFLAGS+=3D-fomit-frame-pointer >> makes them a little smaller. So it looks like we default to having >> frame pointers... somehow. I verified in the compiler stdout that = the >> flags I set are in fact in effect. >>=20 >> Sizes for 16-current 283959bbe0863917c4fc3200a92d1055a4c89bdc = /bin/sh: >>=20 >> text data bss dec hex filename >> - default:=20 >> 164503 3712 5520 173735 2a6a7 >> - -fomit-frame-pointer >> 163831 3712 6192 173735 2a6a7 >> - -fno-omit-frame-pointer >> 164503 3712 5520 173735 2a6a7 >=20 > Performance measurements confirm. Userland (including llvm) compiled > with -fomit-frame-pointer is 2% faster for `make buildworld > buildkernel`. 2% is generally assumed to be the average slowdown from > frame pointers. >=20 > -fomit-frame-pointer: > 45:50.00 2750.00 real 60147.28 user 1657.93 sys 2247% CPU > default freebsd: > 46:29.94 2789.94 real 61529.67 user 1629.37 sys 2263% CPU >=20 > I conclude that we indeed include frame pointers for userland, but I > can't see where we turn that on. It's due to useFramePointerForTargetByDefault() in = contrib/llvm-project/clang/lib/Driver/ToolChains/CommonArgs.cpp, which = does have a special case for NetBSD: if (Triple.isOSFuchsia() || Triple.isOSNetBSD()) { return !clang::driver::tools::areOptimizationsEnabled(Args); } but not for FreeBSD. The default return value is true. We could consider adding "|| Triple.isOSFreeBSD()" to the above if = statement, which would mean that enabling any optimizations would get = rid of the frame pointer. But it's very annoying for debugging and = profiling. I guess it would be better to have some sort of option for bsd.sys.mk to = enable or disable frame pointers on demand, and explicitly pass the = required options to the compiler. -Dimitry