Changing the CHOST variable/de

This document Article description::explains how to change the variable of an existing system.

Changing the CHOST is a big issue that can seriously screw up a system - so why is there a guide for that if it can cause that much havoc?

There are certain situations where changing the CHOST variable is inevitable. Most of them should never be necessary in normal operations (e.g., because they involve bootstrapping for a new architecture). Sometimes however... As an example, switching profile may involve a change of CHOST, e.g., in the case of the upgrade of MIPS machines from the 17.0 to the 23.0 profiles, because we are adapting our settings to common standards.

Even after following the instructions here, problems may arise, so please make sure to read and execute them very carefully. In this example the CHOST variable will be changed from mips64-unknown-linux-gnu to mips64-unknown-linux-gnuabin32. Please change the commands according to the specific situation.

Updating make.conf
To start out with the CHOST variable change, edit the file and add/change the CHOST value to suit the requirements.

Note that profiles provide a default setting for CHOST ; depending on the situation, it may be necessary to override it in or remove an override in. In any case, the important point is that the effective value changes.

Please note that if planning to use another value of CHOST than the profile default, the CHOST_${ABI} variable may need updating as well. It is possible to query the value of this variable of the currently set profile with the portageq tool:

If this value is equal to CHOST, it's good. Otherwise, override it as well, e.g.:

Bau der Pakete
Rebuild the following packages in this order:

Überprüfen, ob die Dinge funktionieren
Now it is time to make sure that the and  settings are sane and that there are no leftovers in.

The output of and  should look like the following:

Next, check to see if there are references to the old CHOST variable in :

Here, binutils is fine - there is one file, and it only contains references to the new CHOST. For gcc, there is a file for both the new and the old CHOST value, so delete the old stale one:

The same also applies to - if there's an extra one, see which is the outdated one and delete it. Next, check the contents of :

There's one stale file with the old CHOST, config-mips64-unknown-linux-gnu, so delete this one.

Time to move on to the directory.

and are fine, but  is another leftover that needs removal.

Now run the following commands to update the environment:

Next, verify everything is fixed in /etc/env.d. If there are still files found, try to track it down before going on.

Finishing the change
Now it is necessary to re-emerge :

It is now possible to rebuild all the packages:

In theory, it should not be necessary to do so, but it cannot be 100% guaranteed that this is actually the case. Alternatively, it is possible to manually rebuild all the known problematic packages:


 * multilib packages using CHOST prefixing or header wrapping,
 * Perl, Python and other tools that store configured compiler path.

Note that paths that do not apply to the current system may need removing from the above invocation.

When encountering other packages that need recompiling, please let us know through the discussion page of this guide.

Common problems
Not so many anymore. Usually this just works, as long as no really exotic change is done. Make sure to not combine the CHOST change with other steps though. Some of the notes below are really old...

When upgrading from gcc 3.3 to 4.1 at the same time as changing the CHOST variable (please don't do that anyway), a couple of users reported broken packages that need recompiling, such as and :

This happens because during the upgrade, the CHOST variable doesn't exactly match the CTARGET variable value, making the compiler assume that the system is using cross-compiling. As a consequence, LDPATH isn't inserted into, resulting in this error.

Please see the for what needs to be rebuilt after a GCC upgrade.

In some rare cases, this can break old versions of python, too. This may be fixed by adding (change accordingly to the old CHOST and gcc version) to, running  and then. However, as can be seen, this situation needs to be avoided - don't change CHOST and gcc at the same time.

Feedback
That should be all, feedback (both if it worked, failed or other problems were encountered) is welcome, please use the discussion page or post to this forum thread. Much in this guide comes from vapier, thanks for the help!