Changing the CHOST variable/zh-cn

本文档Article description::解释了如何更改现有系统的 [[CHOST 变量. ]]

介绍
更改 CHOST 是一个大问题，可能会严重搞砸系统——那么，如果它会造成如此大的破坏，为什么会有此指南？

在某些情况下，更改 CHOST 变量是不可避免的，例如当升级到仅支持 NTPL 的 glibc 2.4 时，用户发现当前的 CHOST 是 i386，导致无法使用 NTPL. 在这种情况下，没有很多选择，更改 CHOST 就是其中之一.

即使按照这些说明进行操作，也可能会出现问题，因此请务必仔细阅读并执行这些说明. 在本例中， CHOST 变量将从 i386 更改为 i686. 请根据具体情况更改命令.

更新 make.conf
要开始更改 CHOST 变量，请编辑 文件并添加/更改 CHOST 值以适应要求.

请注意，如果你计划使用其它 CHOST 值而不是特定配置文件默认值，你可能还需要更新 CHOST_${ABI} 变量. 你可以通过“portageq”工具查询这些变量的当前值：

如果相应值等于你的 CHOST，那没问题. 否则你应该覆盖它，例如：

构建包
按此顺序重建以下包：

配置验证
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:

接下来，检查 中是否存在对旧的 CHOST 变量的引用：

在删除文件之前，让我们检查已更新 CHOST 值的文件：

This one looks good as there should always be only one file for  in  ( in this example), so delete the one with the wrong references:

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 :

那个看起来不错，那两个文件应该在那里. 是时候进入 目录了.

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

现在运行以下命令来更新环境：

接下来，验证一切都已修复：

如果仍然能找到相关文件，请在继续之前尝试对其进行追踪.

完成更改
Now it is necessary to re-emerge and run  which can be found in. Make sure to use the correct gcc version (the current one, 4.1.1 here) and pass the old architecture (i386 here) as argument. Replace  with the new CHOST value, and   with the gcc version. This example assumes a CHOST value applicable to i686.

现在可以重建所有包：

In theory, it should not be necessary to do so, but it cannot be 100% guaranteed that this is actually the case. Alternatively, you can 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.

请注意，你可能需要从上述调用中删除不适用于系统的路径.

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

常见问题
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 GCC upgrade guide 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.

反馈
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 your help!