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 “home register”." - 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.
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
_______________________________________________ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"