Date: Thu, 22 Dec 2011 16:35:46 +0100 From: Dimitry Andric <dim@FreeBSD.org> To: freebsd-current@FreeBSD.org Subject: [patch] Cleaning up amd64 kernel optimization options Message-ID: <4EF34E52.2040905@FreeBSD.org>
next in thread | raw e-mail | index | archive | help
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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4EF34E52.2040905>