Difference between pages "Xfce Guide" and "Switching gcc"

From Funtoo
(Difference between pages)
Jump to: navigation, search
 
(Changing Default gcc)
 
Line 1: Line 1:
{{fancynote|1=
 
This page should probably be deprecated and merged with the [[Xfce|official Xfce page]].}}
 
  
== Xfce Guide ==
+
== How to switch the gcc version for a specific task ==
So after you have successfully set up Funtoo you might want to add a new desktop environment to the mix. This means installing Xorg and, in this case, XFCE.  
+
 
Set your <tt>VIDEO_CARD</tt> to what you have and your <tt>INPUT_DEVICES</tt> set as well in your <tt>make.conf</tt>.
+
This article describes how you can switch the [http://en.wikipedia.org/wiki/GNU_Compiler_Collection gcc] version.
First thing to do is makes sure that the "udev" is in your USE flags. We're going to set these in <tt>/etc/portage/package.use</tt>. After that we're going to install <tt>xorg-server</tt>. Just emerge it.
+
Let's assume, you want to use gcc-4.4.5, but your main [http://en.wikipedia.org/wiki/GNU_Compiler_Collection gcc] version is 4.6:
 +
 
 
<console>
 
<console>
# ##i## echo "x11-base/xorg-sever udev" >> /etc/portage/package.use
+
# ##i##gcc --version
# ##i## emerge x11-base/xorg-server
+
gcc (Gentoo 4.6.2-r1 p1.4, pie-0.5.0) 4.6.2
 +
Copyright (C) 2011 Free Software Foundation, Inc.
 +
This is free software; see the source for copying conditions.  There is NO
 +
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
</console>
 
</console>
After that's done X should work out of the box. You can run this command though to make sure it works. This will configure X for you, and set a new <tt>/etc/X11/xorg.conf</tt> for you. Need to copy it in though.
+
 
 +
So - what to do? The best and safest way is to switch your [http://en.wikipedia.org/wiki/GNU_Compiler_Collection gcc] version temporarily to the same version that is used by the upstream project.
 +
 
 +
To do that, we use the tool gcc-config. First, we'll have a look on what versions are available on your system. Install the desired version of [http://en.wikipedia.org/wiki/GNU_Compiler_Collection gcc] explicitly:
 +
 
 
<console>
 
<console>
# ##i## X -configure
+
# ##i##emerge =sys-devel/gcc-4.4.5*
# ##i## cp /root/xorg.conf.new /etc/X11/xorg.conf
+
 
</console>
 
</console>
Now, we will set our sights on installing XFCE.
+
 
You're going to want to add some USE flags to your <tt>/etc/make.conf</tt>, I would reccomend <tt>USE="-gnome -kde -minimal -qt4 dbus jpeg lock session startup-notification thunar udev X"</tt>. Just add them to your <tt>make.conf</tt>. 
+
After emerging, you can see that it is installed with <tt>gcc-config</tt>:
And now we are ready to install XFCE. In a recent change a dependency for <tt>Thunar</tt>, it wants to bring in <tt>sys-fs/udisks-1.99</tt> which is a dependency of <tt>sys-fs/udev-180</tt> which is not available. The fix is to emerge <tt>gnome-base/gvfs-1.10.*</tt> and mask anything above it and mask <tt>sys-fs/udisks-1.99</tt> in <tt>/etc/portage/package.mask</tt>. You also need to get a Terminal emulator as well, i.e <tt>x11-terms/terminal</tt>
+
 
<console>
+
# ##i## emerge xfce-base/xfce4-meta x11-terms/terminal
+
# ##i## env-update && source /etc/profile
+
</console>
+
There's a few ways to go about starting XFCE. You can either have it run with <tt>startx</tt> or install a display manager, or login manager, i.e LXDM, GDM, KDM, etc.
+
If you want it to run with <tt>startx</tt>
+
 
<console>
 
<console>
# ##i## echo "exec startxfce4" >> ~/.xinitrc
+
# ##i##gcc-config --list-profiles
 +
[1] x86_64-pc-linux-gnu-4.4.5
 +
[2] x86_64-pc-linux-gnu-4.6.2 *
 +
#
 
</console>
 
</console>
If you want XFCE to run at boot add xdm to rc-update. In which case you need a login manager.
+
 
 +
This list shows the versions of gcc that are now installed. The new compiler is now available and can be called as <tt>gcc-4.4.5</tt>. But the default system compiler (what you get when you call <tt>gcc</tt>) is set to 4.6.2. Like with other Funtoo tools, the asterisk marks the currently active version of gcc.
 +
 
 +
If possible, it is best to modify Makefiles and change the <tt>CC</tt> variable to force any required sources to use <tt>gcc-4.4.5</tt> instead of <tt>gcc</tt> to build. This is a non-invasive change that will be local to your current project, which is the preferred way to make these types of build changes. This is the mechanism we use for building Enterprise kernels that build cleanly with earlier versions of gcc.
 +
 
 +
== Changing Default gcc ==
 +
 
 +
Again, this is not recommended as it will affect the default <tt>gcc</tt> version that the entire system will use. Use this with caution. It is also not supported to run Funtoo Linux with a non-standard system compiler, sicne we are not testing it.
 +
 
 +
Before you switch your [http://en.wikipedia.org/wiki/GNU_Compiler_Collection gcc] version, it is very important that you make a note about what version was the active one before, so you can easily switch it back to the profiles default after you're done.
 +
 
 +
To switch the version to 4.4.5, we make use of gcc-config again. You can define the version you want to switch to either by giving the number printed before the listed version in the output of <code>gcc-config --list-profiles</code> or by entering the whole string. So, giving <code>1</code> or <code>x86_64-pc-linux-gnu-4.4.5</code> to gcc-config leads to the same result:
 +
 
 
<console>
 
<console>
# ##i## rc-update add xdm default
+
# ##i##gcc-config 1
 +
* Switching native-compiler to x86_64-pc-linux-gnu-4.4.5 ...
 +
>>> Regenerating /etc/ld.so.cache...                                                                            [ ok ]
 +
 
 +
* If you intend to use the gcc from the new profile in an already
 +
* running shell, please remember to do:
 +
 
 +
*  # source /etc/profile
 +
#>
 
</console>
 
</console>
There's a few to go along with, but for a lightweight one either <tt>lxde-base/lxdm</tt> or <tt>x11-misc/slim</tt>
+
 
 +
Like it's already suggested in the output from above, the next and last step is to refresh your environment to make use of this switch. You may either issue the following two commands or open another login shell for this. No matter what you do, you should verify that the active [http://en.wikipedia.org/wiki/GNU_Compiler_Collection gcc] version is the one you wanted to switch to:
 +
 
 
<console>
 
<console>
# ##i## emerge -av x11-misc/slim
+
# ##i##gcc --version
 +
gcc (Gentoo 4.6.2-r1 p1.4, pie-0.5.0) 4.6.2
 +
Copyright (C) 2011 Free Software Foundation, Inc.
 +
This is free software; see the source for copying conditions.  There is NO
 +
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 +
 
 +
# ##i##source /etc/profile
 +
# ##i##env-update
 +
>>> Regenerating /etc/ld.so.cache...
 +
# ##i##gcc --version
 +
gcc (Gentoo 4.4.5 p1.3, pie-0.4.5) 4.4.5
 +
Copyright (C) 2010 Free Software Foundation, Inc.
 +
This is free software; see the source for copying conditions.  There is NO
 +
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 +
 
 +
#
 
</console>
 
</console>
Or for <tt>lxde-base/lxdm</tt>
 
<console>
 
# ##i## emerge lxde-base/lxdm
 
</console>
 
Whichever you choose to use you need to add it to <tt>/etc/conf.d/xdm</tt>:
 
<tt>DISPLAYMANAGER="slim"</tt>
 
<tt>DISPLAYMANAGER="lxdm"</tt>
 
For <tt>SLiM</tt> you need to add XFCE to <tt>/etc/env.d/90xsession</tt>
 
<console>
 
# ##i## echo XSESSION=\"Xfce4\" >> /etc/env.d/90xsession
 
# ##i## env-update && source /etc/profile
 
</console>
 
Either reboot or <tt>startx</tt>.
 
<br />There are a lot of plugins available for <tt>Thunar</tt> and XFCE. A simple <tt>emerge -s</tt> will do. Such as:
 
<br /><tt>*  xfce-extra/thunar-volman
 
<br />Description:  Daemon that enforces volume-related policies
 
<br />*  xfce-extra/thunar-vcs-plugin
 
<br />Description:  adds Subversion and GIT actions to the context menu of thunar
 
<br />*  xfce-extra/thunar-shares-plugin
 
<br />Description:  Thunar plugin to share files using Samba
 
<br />*  xfce-extra/thunar-archive-plugin
 
<br />Description:  Archive plug-in for the Thunar filemanager
 
<br />*  xfce-extra/xfce4-volumed
 
<br />Description:  Daemon to control volume up/down and mute keys
 
<br />*  xfce-extra/xfce4-screenshooter
 
<br />Description:  Xfce4 screenshooter application and panel plugin
 
<br />*  xfce-extra/xfce4-notifyd
 
<br />Description:  Notification daemon for the Xfce desktop environment
 
<br />*  xfce-extra/xfce4-mixer
 
<br />Description:  A volume control application (and panel plug-in) for the Xfce desktop environment
 
<br />*  xfce-extra/xfce4-mount-plugin
 
<br />Description:  An mount plug-in for the Xfce panel
 
<br />*  xfce-extra/xfce4-clipman-plugin
 
<br />Description:  A clipboard manager plug-in for the Xfce panel
 
<br />*  xfce-extra/xfce4-battery-plugin
 
<br />Description:  A battery monitor panel plugin for the Xfce desktop environment</tt>
 
<br /> Those are some plugins for XFCE and Thunar that I'd suggest.
 
  
[[Category:Desktop]]
+
As you see here, the current shell is using [http://en.wikipedia.org/wiki/GNU_Compiler_Collection gcc] version 4.4.5 only after you have refreshed your environment. Now you can build your packages / source which need this specific version of [http://en.wikipedia.org/wiki/GNU_Compiler_Collection gcc].
[[Category:Desktop Environments]]
+
 
 +
It is important that you reset the [http://en.wikipedia.org/wiki/GNU_Compiler_Collection gcc] version back to the default of your profile. To do that, simply reply the above steps again but this time, use your profile's default version of [http://en.wikipedia.org/wiki/GNU_Compiler_Collection gcc] to switch to.

Latest revision as of 18:19, 14 August 2012

How to switch the gcc version for a specific task

This article describes how you can switch the gcc version. Let's assume, you want to use gcc-4.4.5, but your main gcc version is 4.6:

# gcc --version
gcc (Gentoo 4.6.2-r1 p1.4, pie-0.5.0) 4.6.2
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

So - what to do? The best and safest way is to switch your gcc version temporarily to the same version that is used by the upstream project.

To do that, we use the tool gcc-config. First, we'll have a look on what versions are available on your system. Install the desired version of gcc explicitly:

# emerge =sys-devel/gcc-4.4.5*

After emerging, you can see that it is installed with gcc-config:

# gcc-config --list-profiles
 [1] x86_64-pc-linux-gnu-4.4.5
 [2] x86_64-pc-linux-gnu-4.6.2 *
#

This list shows the versions of gcc that are now installed. The new compiler is now available and can be called as gcc-4.4.5. But the default system compiler (what you get when you call gcc) is set to 4.6.2. Like with other Funtoo tools, the asterisk marks the currently active version of gcc.

If possible, it is best to modify Makefiles and change the CC variable to force any required sources to use gcc-4.4.5 instead of gcc to build. This is a non-invasive change that will be local to your current project, which is the preferred way to make these types of build changes. This is the mechanism we use for building Enterprise kernels that build cleanly with earlier versions of gcc.

Changing Default gcc

Again, this is not recommended as it will affect the default gcc version that the entire system will use. Use this with caution. It is also not supported to run Funtoo Linux with a non-standard system compiler, sicne we are not testing it.

Before you switch your gcc version, it is very important that you make a note about what version was the active one before, so you can easily switch it back to the profiles default after you're done.

To switch the version to 4.4.5, we make use of gcc-config again. You can define the version you want to switch to either by giving the number printed before the listed version in the output of gcc-config --list-profiles or by entering the whole string. So, giving 1 or x86_64-pc-linux-gnu-4.4.5 to gcc-config leads to the same result:

# gcc-config 1
 * Switching native-compiler to x86_64-pc-linux-gnu-4.4.5 ...
>>> Regenerating /etc/ld.so.cache...                                                                             [ ok ]

 * If you intend to use the gcc from the new profile in an already
 * running shell, please remember to do:

 *   # source /etc/profile
#>

Like it's already suggested in the output from above, the next and last step is to refresh your environment to make use of this switch. You may either issue the following two commands or open another login shell for this. No matter what you do, you should verify that the active gcc version is the one you wanted to switch to:

# gcc --version
gcc (Gentoo 4.6.2-r1 p1.4, pie-0.5.0) 4.6.2
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# source /etc/profile
# env-update
>>> Regenerating /etc/ld.so.cache...
# gcc --version
gcc (Gentoo 4.4.5 p1.3, pie-0.4.5) 4.4.5
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

#

As you see here, the current shell is using gcc version 4.4.5 only after you have refreshed your environment. Now you can build your packages / source which need this specific version of gcc.

It is important that you reset the gcc version back to the default of your profile. To do that, simply reply the above steps again but this time, use your profile's default version of gcc to switch to.