Date: Tue, 02 Mar 2010 17:48:01 +0200 From: Giorgos Keramidas <keramida@ceid.upatras.gr> To: Aaron Lewis <aaron.lewis1989@gmail.com> Cc: Paul B Mahol <onemda@gmail.com>, freebsd-questions@freebsd.org Subject: Re: Compiler Flags problem with core2 CPU Message-ID: <87eik27mj2.fsf@kobe.laptop> In-Reply-To: <4B8A7FA7.1070200@gmail.com> (Aaron Lewis's message of "Sun, 28 Feb 2010 22:37:27 %2B0800") References: <4B8A63D5.90104@gmail.com> <3a142e751002280624w6f38d297o65b88301b3e5f8d@mail.gmail.com> <4B8A7FA7.1070200@gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 28 Feb 2010 22:37:27 +0800, Aaron Lewis <aaron.lewis1989@gmail.com> wrote: >Paul B Mahol wrote: >>On 2/28/10, Aaron Lewis <aaron.lewis1989@gmail.com> wrote: >>> Hi, >>> I gonna recompile kernel for my core2 CPU , so i'd like to pass some >>> flags to gcc. Kinds of "-march=core2" , i tried to modify >>> /etc/make.conf >>> >>> e.g CFLAGS += -march=core2 -O20 -ffast-math -mfpmath=sse >>> But it fails .. bad arch switch , core2 cpu is not supported ? >> >> It is bad idea to compile kernel with custom flags. And gcc in FreeBSD >> doesn't know about core2, >> use 'native' if you must. >> >> >>> And is that useful to let gcc select cpu specified asm code ? >> >> Only for some userland stuff like openssl. > > Really ? It's bad to use custom flags to compile kernel , why do you > think so ? I'd like to know more about this : ) > > So setting optimize compiler flags is only useful for userland stuff ? Please do not post your reply on *top* of the original text to this list. The preferred form of replying is bottom-posting here (other lists may have their own rules, but that's ok). I've fixed this message manually, but it would be nice if you posted your reply to the bottom of the quoted text. You can definitely *try* using optimizations for the kernel too. The FreeBSD developers and other users cannot _force_ you to use only a very limited set of options. You are more than free to try new things. This is precisely the reason why we make the source tree available to everyone, including detailed instructions for rebuilding the entire system from source. Note that the kernel is a very special program that may or may not work with some of the optimizations performed by higher GCC levels, though. There may be problems, so if you start building optimized kernels please make sure you keep a 'safe' backup copy of /boot/kernel before you install a new one. This way you will at least be able to boot into the old kernel if anything breaks. One way to keep a backup copy of the kernel is to make sure your /boot partition has enough free space and type as root: # cp -a /boot/kernel /boot/kernel.safe Then if anything goes wrong, you can always break into the loader prompt and type: boot> unload boot> set module_path="/boot/kernel.safe;/boot/modules" boot> load kernel boot> boot -s Note that any optimization levels higher than the defaults are not 'supported' by the FreeBSD team though. As the warning in make.conf says [/usr/share/examples/etc/make.conf]: # CFLAGS controls the compiler settings used when compiling C code. # Note that optimization settings other than -O and -O2 are not recommended # or supported for compiling the world or the kernel - please revert any # nonstandard optimization settings to "-O" or "-O2 -fno-strict-aliasing" # before submitting bug reports without patches to the developers. So if you start building highly-optimized kernels and userland binaries, you are on your own. Bumping in any problem will require that you revert to the standard optimization flags, rebuild everything, try to reproduce the problem again and *then* report it. - Giorgos
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?87eik27mj2.fsf>