From owner-freebsd-current@FreeBSD.ORG Thu Dec 22 15:35:48 2011 Return-Path: Delivered-To: freebsd-current@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6416A106564A for ; Thu, 22 Dec 2011 15:35:48 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (cl-327.ede-01.nl.sixxs.net [IPv6:2001:7b8:2ff:146::2]) by mx1.freebsd.org (Postfix) with ESMTP id 254C28FC0C for ; Thu, 22 Dec 2011 15:35:48 +0000 (UTC) Received: from [IPv6:2001:7b8:3a7:0:64be:2ed2:2384:1368] (unknown [IPv6:2001:7b8:3a7:0:64be:2ed2:2384:1368]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 678FC5C37 for ; Thu, 22 Dec 2011 16:35:47 +0100 (CET) Message-ID: <4EF34E52.2040905@FreeBSD.org> Date: Thu, 22 Dec 2011 16:35:46 +0100 From: Dimitry Andric Organization: The FreeBSD Project User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0) Gecko/20111214 Thunderbird/9.0 MIME-Version: 1.0 To: freebsd-current@FreeBSD.org Content-Type: multipart/mixed; boundary="------------070906020909010701040509" Cc: Subject: [patch] Cleaning up amd64 kernel optimization options X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 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, 22 Dec 2011 15:35:48 -0000 This is a multi-part message in MIME format. --------------070906020909010701040509 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: quoted-printable Hi, I would like to ask some feedback on the attached patch, which cleans up the kernel optimization options for amd64. This was touched upon earlier by Alexander Best in freebsd-toolchain, here: http://lists.freebsd.org/pipermail/freebsd-toolchain/2011-October/000270.= html What this patch attempts to fix is the following: - When you compile amd64 kernels for debug, they still get optimized with "-O2 -frename-registers", which is almost certain to make debugging miserable. Optimizing at higher levels makes variables and code move around, or disappear altogether. About -frename-registers the gcc documentation even says: "Depending on the debug information format adopted by the target, however, it can make debugging impossible, since variables will no longer stay in a =93home register=94= =2E" - Clang doesn't support the -frename-registers option, so you get harmless but annoying "warning: argument unused during compilation: '-frename-registers'" messages during buildkernel. The patch makes it so that: - For normal amd64 kernel builds, it uses "-O2 -frename-registers", unless Clang is used, then it uses plain "-O2". - For debug amd64 kernel builds, it uses "-O", just like all the other arches. --------------070906020909010701040509 Content-Type: text/x-diff; name="amd64-opt-1.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="amd64-opt-1.diff" Index: sys/conf/kern.pre.mk =================================================================== --- sys/conf/kern.pre.mk (revision 228799) +++ sys/conf/kern.pre.mk (working copy) @@ -29,15 +29,13 @@ .else .if ${MACHINE_CPUARCH} == "powerpc" _MINUS_O= -O # gcc miscompiles some code at -O2 +.elif ${MACHINE_CPUARCH} == "amd64" && ${CC:T:Mclang} != "clang" +_MINUS_O= -O2 -frename-registers .else _MINUS_O= -O2 .endif .endif -.if ${MACHINE_CPUARCH} == "amd64" -COPTFLAGS?=-O2 -frename-registers -pipe -.else COPTFLAGS?=${_MINUS_O} -pipe -.endif .if !empty(COPTFLAGS:M-O[23s]) && empty(COPTFLAGS:M-fno-strict-aliasing) COPTFLAGS+= -fno-strict-aliasing .endif --------------070906020909010701040509--