编译 binutils & 的配方海湾合作委员会在一起?

发布于 2024-08-11 04:52:16 字数 692 浏览 12 评论 0原文

根据 gcc 构建说明,您可以在构建 gcc(以及 gmp)的同时构建 binutils 、mpc 等)。

该页面内容如下:

如果您还打算构建 binutils (升级现有的 安装或代替使用 您操作系统的相应工具), 解压 binutils 发行版 在同一目录中或 单独一个。在后一种情况下,添加 到任何组件的符号链接 您打算构建的 binutils 与编译器一起(bfd、binutils、 气体,gprof,ld,操作码,...)到 包含 GCC 源代码的目录。

同样,GMP、MPFR 和 MPC 可以自动构建库 与海湾合作委员会一起。打开 GMP 包装, MPFR 和/或 MPC 源代码分发 在包含 GCC 的目录中 源并重命名其目录 分别为 gmp、mpfr 和 mpc(或 使用相同的符号链接 名称)。

这对于 gmp、mpc、mpfr 工作得很好,但我似乎无法让它构建所有 binutils。 我也无法弄清楚如何让它从 binutils 构建新的黄金链接器。 有问题的版本是 gcc-4.4.2 和 binutils-2.20。

一步一步的指导会很棒(对于我和其他遇到这个问题的人来说)。

According the the gcc build instructions you can build binutils concurrently with building gcc (as well as gmp,mpc,etc).

Here's what that page says :

If you also intend to build binutils
(either to upgrade an existing
installation or for use in place of
the corresponding tools of your OS),
unpack the binutils distribution
either in the same directory or a
separate one. In the latter case, add
symbolic links to any components of
the binutils you intend to build
alongside the compiler (bfd, binutils,
gas, gprof, ld, opcodes, ...) to the
directory containing the GCC sources.

Likewise the GMP, MPFR and MPC
libraries can be automatically built
together with GCC. Unpack the GMP,
MPFR and/or MPC source distributions
in the directory containing the GCC
sources and rename their directories
to gmp, mpfr and mpc, respectively (or
use symbolic links with the same
name).

This works fine for gmp,mpc, mpfr, but I can't seem to get it to build all of binutils.
Nor can I figure out how to get it to build the new gold linker from binutils.
The versions in question are gcc-4.4.2 and binutils-2.20.

A step by step instruction would be great (for me, and for others who run into this issue as well).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一个人练习一个人 2024-08-18 04:52:16

这应该仍然受到支持,因为它通常用于构建交叉编译器。

事实上,我刚刚使用 gcc 4.6.0 和 binutils 2.21(使用适当版本的 gmp、mpc 和 mpfr)完成了此操作,并且以下内容似乎工作正常:

  • 获取您正在处理的内容的所有档案将构建(gcc-4.6.0.tar.bz2、binutils-2.21.tar.bz2 等)到新目录,例如 src

  • 将它们全部解压缩到此目录中,因此您最终会得到 gcc-4.6.0/ binutils-2.21/ gmp-5.0.2/ > 还有更多人坐在一起

    tar jxvf gcc-4.6.0.tar.bz2
    ...(在此处解压其他文件,观察文件列表滚动过去)

  • cd gcc-4.6.0 并符号链接 gmp、mpc 和 mpfr 目录,链接中不包含版本号,例如:< /p>

    ln -s ../gmp-5.0.2 gmp

  • 现在对所有内容进行符号链接来自 gcc 目录中不存在的 binutils 目录,因此任何已经存在的内容都将优先,但 binutils 工具对于构建来说是可见的:

    对于 ../binutils-2.21/* 中的文件;执行 ln -s "${file}" ;完成

  • 更改目录并创建一个构建目录,以将所有这些内容单独构建到源中(这始终是推荐的方法,并且它往往仍然比在源目录中构建更可靠):

    cd ..; mkdir 构建

  • 此时您应该拥有一组目录和链接,如下所示:

    binutils-2.21/
    建造/
    gcc-4.6.0/
    GMP-> ../gmp-5.0.2
    mpc-> ../mpc-0.9
    mpfr-> ../mpfr-3.0.1
    bfd-> ../binutils-2.21/bfd
    binutils ->; ../binutils-2.21/binutils
    气体-> ../binutils-2.21/gas
    ...(这里有更多 binutils 的符号链接,加上现有的 gcc 东西)
    GMP-5.0.2/
    mpc-0.9/
    mpfr-3.0.1/

  • 从该目录配置全部内容,使用您需要传递给配置的任何选项:

    ../gcc-4.6.0/configure --prefix=/foo/bar --enable-languages=c,c++,ada

  • 构建、等待、安装(您可能需要使用 make -j4 左右来并行进行一些构建,因为这需要一段时间):

    制作-j4;进行安装

将目标添加到您的路径(如果尚未添加)(如果不在 /etc/ld.so.conf 中指定的范围内,则可能将 lib 目录添加到 LD_LIBRARY_PATH,如有关消息中所述在 make install 步骤中安装库),并且一切都应该在这个新版本中启动并运行。

打开新 shell 后,可能值得检查一下您是否正在使用此已安装版本,并使用 :

    `which gcc`

    `which as`

.. 以及该版本是否符合您的预期:

    `gcc --version`

    `as --version`

.. 以及(当然)测试该版本在您将其释放到代码库之前,已安装的版本可以通过一些简单的示例很好地构建可执行文件:)

编辑:下面的注释包含一些已知可以协同工作的版本集。并非所有组合都有效,因此您可能需要对提到的不同组合进行一些尝试和错误!

稍后编辑:gdb 也可以包含在此构建中(再次需要兼容的组件版本 - 请参阅注释)。
以类似的方式将其添加为 binutils 之后的最后一件事,使用 for f in ../gdb-8.1.1/* ;执行 ln -s "${f}" ;完成并且构建将自动拾取它。

截至 2023 年 5 月 3 日编辑:最新发布的版本 gcc 13.1.0、binutils 2.40、gdb 13.1、cloog 0.18.1、isl 0.24、gmp 6.1.0、mpc 1.2.1、mpfr 4.1.0 都可以很好地构建在一起,至少对于 c、c++、fortran 作为语言集。

This should still be supported OK, as it's commonly used for building cross-compilers.

In fact, I've just done this with gcc 4.6.0 and binutils 2.21 (with gmp, mpc and mpfr at appropriate versions), and the following seemed to work fine:

  • Get all the archives of the stuff you're going to build (gcc-4.6.0.tar.bz2, binutils-2.21.tar.bz2 etc) into a new dir, e.g. src

  • Un-tar them all in this directory, so you end up with gcc-4.6.0/ binutils-2.21/ gmp-5.0.2/ and more sitting alongside one another

    tar jxvf gcc-4.6.0.tar.bz2
    ... (unpack others here, watch file lists scroll past)

  • cd gcc-4.6.0 and symlink the gmp, mpc and mpfr directories without their version numbers in the links, e.g:

    ln -s ../gmp-5.0.2 gmp

  • Now symlink everything from the binutils dir which doesn't exist in the gcc dir, so anything which already exists will take priority but the binutils tools will look be visible to the build:

    for file in ../binutils-2.21/* ; do ln -s "${file}" ; done

  • Change up a dir and make a build directory to build all this in separately to the sources (this always used to be the recommended method, and it tends to still be more reliable than building inside the source dir):

    cd .. ; mkdir build

  • At this point you should have a set of directories and links which looks something like this:

    binutils-2.21/
    build/
    gcc-4.6.0/
    gmp -> ../gmp-5.0.2
    mpc -> ../mpc-0.9
    mpfr -> ../mpfr-3.0.1
    bfd -> ../binutils-2.21/bfd
    binutils -> ../binutils-2.21/binutils
    gas -> ../binutils-2.21/gas
    ... (lots more symlinks for binutils here, plus existing gcc stuff)
    gmp-5.0.2/
    mpc-0.9/
    mpfr-3.0.1/

  • Configure the whole lot from this dir, with whatever options you need to pass to configure:

    ../gcc-4.6.0/configure --prefix=/foo/bar --enable-languages=c,c++,ada

  • Build, wait, install (you'll probably want to use make -j4 or so here to get some builds in parallel as it's going to take a while) :

    make -j4 ; make install

Add the destination to your path if it's not already (and perhaps the lib dir to LD_LIBRARY_PATH if this is outside of those specified in /etc/ld.so.conf, as mentioned in the messages about installing libraries during the make install step), and everything should be up and running with this new version.

It's probably worth checking that you're using this installed version once you've opened a new shell, with :

    `which gcc`

and

    `which as`

..as well as that the version is as you expect with:

    `gcc --version`

and

    `as --version`

..as well as (of course) testing that the installed version builds executables fine with some simple examples before you let it loose on your code-base :)

Edit: The comments below contain some sets of versions which are known to work together. Not all combinations will work, so you might need to go through some trial and error for different combinations to those mentioned!

Much later edit: gdb is also possible to include in this build (again requires compatible component versions - see comments).
Add this as the last thing after binutils in a similar way, using for f in ../gdb-8.1.1/* ; do ln -s "${f}" ; done and the build will automatically pick it up.

Edit as of 2023-05-03: Latest released version gcc 13.1.0, binutils 2.40, gdb 13.1, cloog 0.18.1, isl 0.24, gmp 6.1.0, mpc 1.2.1, mpfr 4.1.0 all build together fine, at least for c,c++,fortran as the language set.

蹲墙角沉默 2024-08-18 04:52:16

您想要做的称为“组合树”或“树内 binutils”构建。您可以在此处那里

What you want to do is called a "combined tree" or "in-tree binutils" build. You can find documentation on how to proceed here and there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文