march和mtune的区别
转自: http://blog.openrays.org/blog-htm-do-showone-tid-364.html
给定gcc优化选项时经常要指定march和mtune。我以前都将它们赋为一样的值,例如pentium4.
今天仔细研究了一下它们的区别,原来还是有一些道道的。
首先是man gcc:
-mtune=name
This option is very similar to the -mcpu= option, except that
instead of specifying the actual target processor type, and hence
restricting which instructions can be used, it specifies that GCC
should tune the performance of the code as if the target were of
the type specified in this option, but still choosing the instruc-
tions that it will generate based on the cpu specified by a -mcpu=
option.
上面是gcc3.2的manpage,现在mcpu已经不用了,一般都用march。望文生义,march指定的是当前cpu的架构,而mtune是真正作用于某一型号cpu的选项。
根据链接:
http://gentoo-wiki.com/Safe_Cflags
的解释,march是“紧约束”,mtune是“松约束”。mtune可以提供后向兼容性,也就是mtune=pentium-mmx编译出来的程序,在pentium4处理器上也是可以运行的。
因此,像-march=i686 -mtune=pentium4这样的优化选项编译出来的程序,是为奔腾4处理器优化过的,但是在任何i686上都可以运行。
我猜,如果指定了-march=pentium3,那么在奔腾4处理器上程序是不能运行的。
上面是自己根据别人的文档整理出来的一些说法,具体是不是这么回事没有试验过。若有错误的地方,还请大虾指正:-)
转自:http://www.raspberrypi.org/phpBB3/viewtopic.php?f=54&t=707&start=50
There are stage3-tarballs but I didn't yet create a stage4-image. I could create you a SD that contains just bootloader-stuff (kernel, GPU firmware on the FAT-partition) and the Gentoo-stage3 files on a 4GB-base if you want.
- Posts: 55
- Joined: Tue Jan 17, 2012 3:48 pm
I just got my Pi, and just now really getting started with building Gentoo for it. Having an image has saved me tons of time.
Did any of you have any luck with cross-compiling? I am trying to see how an entire laymen overlay will work, so really need a lot more umph then just running QEMU. I just started the armv6zk-hardfloat-linux-gnueabi crossdev build. Really hoping it works out.
Also the SD card I have is total pain. Have any of you tried usb flash storage? It says you can boot from usb drives, but seems like most are putting the kernel on the SD then loading root from USB.
I am sure I will have a ton more questions. Thank you guys for working on this so that I can have a jumpstart!
- Posts: 7
- Joined: Sat May 19, 2012 10:08 pm
It's going to be interesting to find good ways to get the best aspects of Gentoo on the Pi without suffering its downsides. The prize will be a very streamlined distribution since all options that are considered bloat can be disabled.
No Pi here yet though, probably not until June.
Morgaine. Intolerance is a failure of education. Education is predicated on tolerance of the uneducated.
- Posts: 141
- Joined: Mon Mar 12, 2012 1:13 am
drivintin wrote:Did any of you have any luck with cross-compiling? I am trying to see how an entire laymen overlay will work, so really need a lot more umph then just running QEMU. I just started the armv6zk-hardfloat-linux-gnueabi crossdev build. Really hoping it works out.
Yes, cross-compiling works just as well as distcc. When building your toolchain with crossdev be sure to sync before ( https://bugs.gentoo.org/show_bug.cgi?id=415937) and use "armv6j-hardfloat-linux-gnueabi" as triplet.
drivintin wrote:Also the SD card I have is total pain. Have any of you tried usb flash storage? It says you can boot from usb drives, but seems like most are putting the kernel on the SD then loading root from USB.
Yep, running from SD is pain. I'm using a 2.5"-SATA-HDD with external (USB 2.0) enclosure. and true, the kernel is in the SD-card since you cannot boot w/o SD.
- Posts: 55
- Joined: Tue Jan 17, 2012 3:48 pm
I had Fedora on an SD card that was working. So I got a 32G flash drive that I am going to run Gentoo from. Expanded disneysw image onto the usb drive, copied over the boot partition to the sd card, and modified the root to /dev/sda2. Problem is the kernel does find the USB stick, but doesn't seem to know to make it sda. I actually used the fedora kernel fine, except for the fact that it doesn't contain nfs, which i need to mount the compiling machine.
So really, what I guess I am asking is:
disneysw Can I get your kernel .config so I can try building another one? also what special items do I need to boot the raspberry besides the kernel? I noticed there were other files in the boot partition, i just don't have them in front of me.
- Posts: 7
- Joined: Sat May 19, 2012 10:08 pm
I've successfully deployed Gentoo on my RaspberryPI - CHOST="armv6zk-hardfloat-linux-gnueabi" .
I just wanna ask, if you are running Gentoo on your RaspberryIP box, what values in /etc/make.conf ? I'm interested at values for GCC.
I'm using:
- CODE: SELECT ALL
-
CFLAGS="-O2 -pipe -mcpu=arm1176jzf-s -march=armv6zk -mfpu=vfp -mfloat-abi=hard"
CXXFLAGS="${CFLAGS}"
CHOST="armv6zk-hardfloat-linux-gnueabi"
I think this should be correct, unfortunately when I'm compiling every single package I'm getting this warning:
warning: switch -mcpu=arm1176jzf-s conflicts with -march= switch
According to http://dev.gentoo.org/~armin76/arm/chost.xml arm1176jzf-s should be armv6zk .
Is anyone having such wired warning message? I guess this message is not any serious problem, as it won't terminate compilation process but it's wired.
- Posts: 3
- Joined: Mon May 21, 2012 12:49 am
And suggestions on how to link the nfs share from my crossdev enviroment into the running Pi enviroment?
Thanks again guys.
- Posts: 7
- Joined: Sat May 19, 2012 10:08 pm
coRpTitan wrote:I think this should be correct, unfortunately when I'm compiling every single package I'm getting this warning:
warning: switch -mcpu=arm1176jzf-s conflicts with -march= switch
Just omit the march-switch. Check the resulting binaries with "readelf -A" and you'll see that the mcpu-switch sets the arch automatically.
- Posts: 55
- Joined: Tue Jan 17, 2012 3:48 pm
- CODE: SELECT ALL
-
!!! /usr/armv6zk-hardfloat-linux-gnueabi/etc/make.profile is not a symlink and will probably prevent most merges.
!!! It should point into a profile within /usr/portage/profiles/
!!! (You can safely ignore this message when syncing. It's harmless.)
Looking at the profiles I assume I would point to /usr/portage/profiles/arm/arm6zk
Except that doesn't exist, only a arm6j, is that where I should point it?
Sorry for all the questions, just new to this side of Gentoo.
- Posts: 7
- Joined: Sat May 19, 2012 10:08 pm
drivintin wrote:So on the crossdev machine I am getting
CODE: SELECT ALL
!!! /usr/armv6zk-hardfloat-linux-gnueabi/etc/make.profile is not a symlink and will probably prevent most merges.
I told you here: viewtopic.php?p=80903#p80903
that armv6j-hardfloat-linux-gnueabi is the right triplet
- Posts: 55
- Joined: Tue Jan 17, 2012 3:48 pm
jannis wrote:I told you here: viewtopic.php?p=80903#p80903
that armv6j-hardfloat-linux-gnueabi is the right triplet
Sorry, I think I understand now. The triplet uses armv6j then you use the make.conf of
- CODE: SELECT ALL
-
CFLAGS="-O2 -pipe -mcpu=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard"
CXXFLAGS="${CFLAGS}"
CHOST="armv6j-hardfloat-linux-gnueabi"
to set the hardware float, and the correct cpu. Right, I hope?
- Posts: 7
- Joined: Sat May 19, 2012 10:08 pm
http://rpi.kripserver.net/unofficial/
make.conf will be uploaded there in some minutes (need to connect and boot up my RPi).
*EDIT*: make.conf up: http://rpi.kripserver.net/unofficial/make.conf
- Posts: 55
- Joined: Tue Jan 17, 2012 3:48 pm
jannis wrote:Yep, that one looks right. Sorry if it was formulated a little harsh in the last post, I have a bit of a headache today. If you have kernel problems, here is one I compiled for someone on IRC:
http://rpi.kripserver.net/unofficial/
make.conf will be uploaded there in some minutes (need to connect and boot up my RPi).
*EDIT*: make.conf up: http://rpi.kripserver.net/unofficial/make.conf
Not a problem, got it up and running, having some packages crash, but I will have to take a look at it a bit later. Glad you posted that make, I had not even thought about making a remote portage, makes it soo much faster and easier just to use a network copy and keeping it synced up.
- Posts: 7
- Joined: Sat May 19, 2012 10:08 pm
drivintin wrote:Ok, well here is where I sit.
I had Fedora on an SD card that was working. So I got a 32G flash drive that I am going to run Gentoo from. Expanded disneysw image onto the usb drive, copied over the boot partition to the sd card, and modified the root to /dev/sda2. Problem is the kernel does find the USB stick, but doesn't seem to know to make it sda. I actually used the fedora kernel fine, except for the fact that it doesn't contain nfs, which i need to mount the compiling machine.
So really, what I guess I am asking is:
disneysw Can I get your kernel .config so I can try building another one? also what special items do I need to boot the raspberry besides the kernel? I noticed there were other files in the boot partition, i just don't have them in front of me.
(Sorry, been busy for the past few days trying to build firefox ~3 day compile and Java/Icedtea.)
You can get the .config from a running kernel by uncompressing /proc/config.gz
The kernel on my images is from the pi foundation. Initially I was going to build a stock kernel but a quick browse around github it became clear there a number of customisation were made to support the Pi and it would take time determine exactly what they were. I may revisit this in future.
BTW, given the compile times for some of the larger packages I for one am implementing a crosscompile system!
- Posts: 14
- Joined: Tue May 08, 2012 10:49 am
And suggestions on how to link the nfs share from my crossdev enviroment into the running Pi enviroment?
Thanks again guys.[/quote]
I'd suggest physically plugging your SD card/memorystick into your crosscompile system using a reader if necessary.
Then create an executable script file containing
#! /bin/bash
mkdir -p /mnt/gentoo
mount /dev/sdXXXX /mnt/gentoo
cp /etc/resolv.conf /mnt/gentoo/etc/
mount -t /proc none /mnt/gentoo/proc
mount -o bind /tmp /mnt/gentoo/tmp
mount -o bind /dev /mnt/gentoo/dev
mount -o bind /sys /mnt/gentoo/sys
chroot /mnt/gentoo /bin/bash
run the above script, to chroot into the filesystem on your memory card
run the commands
env-update
source /etc/profile
you should now be good to go!
The above is done from memory so there may be mistakes, if I remember when I get home I will post my 'script'.
The other alternative if you cant physically plug the root filesystem in is to start sshd on the Pi and use 'sshfs' to remotly mount it. Google sshfs & gentoo for more info.
- Posts: 14
- Joined: Tue May 08, 2012 10:49 am
The way to go is to setup a cross-compiler on your x86/x86_64 system (easy with crossdev) and then use distcc for cross-compiling:
http://www.gentoo.org/doc/en/cross-compiling-distcc.xml
Just make sure that the RPi doesn't do any compilation (don't include 127.0.0.1 in /etc/distcc/hosts). Such a setup is working here. The only problem is memory-usage on linking (which is done on the emerging host, distcc off or on). One way around would be to use the gold linker on the RPi ( https://wiki.gentoo.org/wiki/Gold) but I've never tried it since I'm not going to install firefox or java on the Pi (or at least don't plan to do so)
- Posts: 55
- Joined: Tue Jan 17, 2012 3:48 pm
See http://www.gentoo.org/proj/en/base/embe ... t=1&chap=5
distcc would probably be a faster but I have had versioning issues with the in the past that put me off using it. To be fair that was a good number of years ago.
- Posts: 14
- Joined: Tue May 08, 2012 10:49 am
I remember having had versioning issues, too. That was back in the days where x86_64-machines helped x86-machines keep their system up-to-date. Just today I set-up the i686-toolchain again and distcc is working. I guess the "-S"-parameter (use stable versions for the cross-toolchain) helped a lot.
- Posts: 55
- Joined: Tue Jan 17, 2012 3:48 pm
- Posts: 7
- Joined: Sat May 19, 2012 10:08 pm
The first is basically a bootable stage3 install and will fit on a 4GB card
http://com.legato-solutions.raspberrypi ... 13V1-1.zip
The second builds on that to add X11 in prep for a Window Manager - Use this if you want to build KDE, Gnome etc.. Requires an 8GB card
http://com.legato-solutions.raspberrypi ... GB.img.zip
The final adds xfce4 as a window manager - Requires an 8GB card
http://com.legato-solutions.raspberrypi ... GB.img.zip
I'll probably create and release a bootable USB Live version of Gentoo containing distcc and crossdev to allow one or more PC's to assist the compile process as some of the larger packages could/will take days on a physical device.
README:
This zip contains a bootable Gentoo Linux image for the RaspberryPi
It was created by gmcclean at legato-solutions.com as a checkpoint during the build of a customised solution for an embedded application.
The default username is 'pi'
The default password 'raspberry'
You can 'sudo -s' to root or use sudo to run elevated commands or
manually start a GUI by typing 'startxfce4' after logging in.
22 May 2012 Requires 8GB or larger card
Added xfce desktop GUI, ffmpeg, mplayer, vlc, distcc
Support for distcc is not fully enabled yet (It still compiles locally). I will probably create a live USB drive consisting of a minimal gentoo plus distcc and crosscompile to accelerate building for the raspberryPi
Added rpi-update from https://github.com/Hexxeh/rpi-update to enable simple firmware updates
Things still to do - fix hardware video acceleration!!!!! Move /usr/portage to separate file system to reduce footprint
Available from http://com.legato-solutions.raspberrypi ... GB.img.zip
15 May 2012 Requires 8GB or larger card
Added xorg-base as a prelude to building an X11 Window Manager. Personally going with xfce but you could build/use KDE, Gnome or something else. The choice is yours.......
Available from http://com.legato-solutions.raspberrypi ... GB.img.zip
13 May 2012 - Base Gentoo install on RaspberryPi suitable for someone looking for a headless solution with minimal footprint and easily fits on a 4GB SD card. Available from
https://s3-eu-west-1.amazonaws.com/com. ... 13V1-1.zip
(V1.1)
Fixed /etc/make.conf
Resolved issue that would have effected eth0
(V1.0)
Created ext4 filesystem with extra inodes
Installed Stage3
chroot into system
kernel and modules take from debian6-19-04-2012 image
Removed serial tty from /etc/inittab
Updated /etc/make.conf
Added nano, openntpd, sudo
Set /etc/locattime and /etc/timezone to Europe/London
Set uk keyboard in /etc/conf/keymaps
Updated /etc/conf.d/hwclock so avoid error when trying to read no-existent clock
Created "pi" user with "raspberry" password
sudoers updated to give access to 'pi' account
Updated /etc/fstab
- Posts: 14
- Joined: Tue May 08, 2012 10:49 am
jannis wrote:Just omit the march-switch. Check the resulting binaries with "readelf -A" and you'll see that the mcpu-switch sets the arch automatically.
I've did it, and here is output:
- CODE: SELECT ALL
-
raspberrypi ~ # readelf -A /usr/bin/mc
Attribute Section: aeabi
File Attributes
Tag_CPU_name: "ARM1176JZF-S"
Tag_CPU_arch: v6KZ
Tag_ARM_ISA_use: Yes
Tag_THUMB_ISA_use: Thumb-1
Tag_FP_arch: VFPv2
Tag_ABI_PCS_wchar_t: 4
Tag_ABI_FP_denormal: Needed
Tag_ABI_FP_exceptions: Needed
Tag_ABI_FP_number_model: IEEE 754
Tag_ABI_align_needed: 8-byte
Tag_ABI_align_preserved: 8-byte, except leaf SP
Tag_ABI_enum_size: int
Tag_ABI_HardFP_use: SP and DP
Tag_ABI_VFP_args: VFP registers
Tag_DIV_use: Not allowed
Tag_Virtualization_use: TrustZone
raspberrypi ~ #
and according to official gcc documentation( http://gcc.gnu.org/onlinedocs/gcc-4.5.3 ... RM-Options ) it should be: armv6 Z K .
So I guess it's wrongly in gcc documentation or in GCC itself, but I don't care, I've omitted "-march=" completely and warning is no more here.
BTW: Did anyone tried to deploy armv6 j-hardfloat-linux-gnueabi onto rpi and then change CHOST to armv6 zk-hardfloat-linux-gnueabi and recompile gcc?
I was getting error, when compiling it, I've tried to purge ccache cache, disabled distcc and result was still the same. After that I've used USE="vanilla" emerge -av gcc and it worked, so I guess Gentoo patchset is preventing it to compile. So if you will go through this, you can safe lot of testing if you will emerge vanilla gcc :]
- Posts: 3
- Joined: Mon May 21, 2012 12:49 am
jannis wrote:There are stage3-tarballs but I didn't yet create a stage4-image. I could create you a SD that contains just bootloader-stuff (kernel, GPU firmware on the FAT-partition) and the Gentoo-stage3 files on a 4GB-base if you want.
That would be a great help - this will only be the second time I've tried a Gentoo install as I normally stick with Debian. (Yep you guessed it - the last time wasn't a huge success, but I've learn't a little more since then!)
- Posts: 32
- Joined: Sat May 19, 2012 7:56 pm
- Location: UK
disneysw wrote:Ok, so here is the last of the Gentoo stages that I plan to release. In total I have three raspberryPi images at different build stages. All of them are designed to reduce the amount of time it takes to get Gentoo up and running as a platform. It's up to you to customise the images for your own needs.
The first is basically a bootable stage3 install and will fit on a 4GB card
http://com.legato-solutions.raspberrypi ... 13V1-1.zip
The second builds on that to add X11 in prep for a Window Manager - Use this if you want to build KDE, Gnome etc.. Requires an 8GB card
http://com.legato-solutions.raspberrypi ... GB.img.zip
The final adds xfce4 as a window manager - Requires an 8GB card
http://com.legato-solutions.raspberrypi ... GB.img.zip
I'll probably create and release a bootable USB Live version of Gentoo containing distcc and crossdev to allow one or more PC's to assist the compile process as some of the larger packages could/will take days on a physical device.
README:
This zip contains a bootable Gentoo Linux image for the RaspberryPi
It was created by gmcclean at legato-solutions.com as a checkpoint during the build of a customised solution for an embedded application.
The default username is 'pi'
The default password 'raspberry'
You can 'sudo -s' to root or use sudo to run elevated commands or
manually start a GUI by typing 'startxfce4' after logging in.
22 May 2012 Requires 8GB or larger card
Added xfce desktop GUI, ffmpeg, mplayer, vlc, distcc
Support for distcc is not fully enabled yet (It still compiles locally). I will probably create a live USB drive consisting of a minimal gentoo plus distcc and crosscompile to accelerate building for the raspberryPi
Added rpi-update from https://github.com/Hexxeh/rpi-update to enable simple firmware updates
Things still to do - fix hardware video acceleration!!!!! Move /usr/portage to separate file system to reduce footprint
Available from http://com.legato-solutions.raspberrypi ... GB.img.zip
15 May 2012 Requires 8GB or larger card
Added xorg-base as a prelude to building an X11 Window Manager. Personally going with xfce but you could build/use KDE, Gnome or something else. The choice is yours.......
Available from http://com.legato-solutions.raspberrypi ... GB.img.zip
13 May 2012 - Base Gentoo install on RaspberryPi suitable for someone looking for a headless solution with minimal footprint and easily fits on a 4GB SD card. Available from
https://s3-eu-west-1.amazonaws.com/com. ... 13V1-1.zip
(V1.1)
Fixed /etc/make.conf
Resolved issue that would have effected eth0
(V1.0)
Created ext4 filesystem with extra inodes
Installed Stage3
chroot into system
kernel and modules take from debian6-19-04-2012 image
Removed serial tty from /etc/inittab
Updated /etc/make.conf
Added nano, openntpd, sudo
Set /etc/locattime and /etc/timezone to Europe/London
Set uk keyboard in /etc/conf/keymaps
Updated /etc/conf.d/hwclock so avoid error when trying to read no-existent clock
Created "pi" user with "raspberry" password
sudoers updated to give access to 'pi' account
Updated /etc/fstab
Thanks for the great work would you be able to have a twm .img with rpi-update?
- Posts: 12
- Joined: Wed Aug 24, 2011 9:25 pm
Thanks for the great work would you be able to have a twm .img with rpi-update?
np
The image created on 15 May 2012 ( http://com.legato-solutions.raspberrypi ... GB.img.zip) includes twm but not the firmware update app. However it only takes a few minutes to install it by going to Hexxeh’s blog ( http://hexxeh.net/?p=328117855) and following the instructions.
- Posts: 14
- Joined: Tue May 08, 2012 10:49 am
I've been able to add apache2, php, and mysql along with other odd and ends. Building midori right now.
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
