[patch] Cleaning up amd64 kernel optimization options

Dimitry Andric dim at FreeBSD.org
Thu Dec 22 15:35:48 UTC 2011


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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: amd64-opt-1.diff
Type: text/x-diff
Size: 667 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-current/attachments/20111222/f80cb54d/amd64-opt-1.bin


More information about the freebsd-current mailing list