From owner-freebsd-questions@FreeBSD.ORG Tue Mar 2 19:45:18 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 397C2106564A for ; Tue, 2 Mar 2010 19:45:18 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from poseidon.ceid.upatras.gr (poseidon.ceid.upatras.gr [150.140.141.169]) by mx1.freebsd.org (Postfix) with ESMTP id 9F8268FC23 for ; Tue, 2 Mar 2010 19:45:17 +0000 (UTC) Received: from mail.ceid.upatras.gr (unknown [10.1.0.143]) by poseidon.ceid.upatras.gr (Postfix) with ESMTP id 8EDA7EB4839; Tue, 2 Mar 2010 21:45:16 +0200 (EET) Received: from localhost (europa.ceid.upatras.gr [127.0.0.1]) by mail.ceid.upatras.gr (Postfix) with ESMTP id 93330160D1C; Tue, 2 Mar 2010 21:45:16 +0200 (EET) X-Virus-Scanned: amavisd-new at ceid.upatras.gr Received: from mail.ceid.upatras.gr ([127.0.0.1]) by localhost (europa.ceid.upatras.gr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id au44w-QdwyGY; Tue, 2 Mar 2010 21:45:16 +0200 (EET) Received: from kobe.laptop (ppp-94-64-230-198.home.otenet.gr [94.64.230.198]) by mail.ceid.upatras.gr (Postfix) with ESMTP id 3DC22160D15; Tue, 2 Mar 2010 21:45:16 +0200 (EET) Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.4/8.14.4) with ESMTP id o22JjCiS003179 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 2 Mar 2010 21:45:13 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by kobe.laptop (8.14.4/8.14.4/Submit) id o22Fm1g8002985; Tue, 2 Mar 2010 17:48:01 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) From: Giorgos Keramidas To: Aaron Lewis References: <4B8A63D5.90104@gmail.com> <3a142e751002280624w6f38d297o65b88301b3e5f8d@mail.gmail.com> <4B8A7FA7.1070200@gmail.com> Date: Tue, 02 Mar 2010 17:48:01 +0200 In-Reply-To: <4B8A7FA7.1070200@gmail.com> (Aaron Lewis's message of "Sun, 28 Feb 2010 22:37:27 +0800") Message-ID: <87eik27mj2.fsf@kobe.laptop> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.92 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Paul B Mahol , freebsd-questions@freebsd.org Subject: Re: Compiler Flags problem with core2 CPU X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Mar 2010 19:45:18 -0000 On Sun, 28 Feb 2010 22:37:27 +0800, Aaron Lewis wrote: >Paul B Mahol wrote: >>On 2/28/10, Aaron Lewis 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