让 GMP 与 GCC 4.5.2 一起工作

发布于 2024-10-20 00:09:41 字数 2377 浏览 3 评论 0原文

我正在尝试使用 http://crossgcc 中的文件制作交叉编译器。 rts-software.org/doku.php?id=i386linuxgccformac

我在 Intel Mac(10.6.6,x86_64)上编译:gmp,mpfr,mpc 用于交叉编译器作为 32 位(因为我是在 64 位 Mac 上)但我得到

ld: warning: option -s is obsolete and being ignored
ld: warning: ignoring file /gmp1/lib/libmpc.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
ld: warning: ignoring file /gmp1/lib/libmpfr.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
ld: warning: ignoring file /gmp1/lib/libgmp.dylib, file was built for unsupported file format which is not the architecture being linked (i386)

When compiling GCC with:

--prefix=/usr/local/i386-linux-4.5.2 --target=i386-linux --enable-languages=c --without-headers --disable-shared --disable-threads --disable-nls --with-gmp=/gmp1 --with-gmp-lib=/gmp1 --with-gmp-include=/gmp1 --with-mpfr=/gmp1 --with-mpfr-include=/gmp1 --with-mpfr-lib=/gmp1 --with-mpc=/gmp1 --with-mpc-lib=/gmp1 --with-mpc-include=/gmp1

另外,如果我用以下方式编译 GMP:

./configure --prefix=/gmp1 --host=i386-linux

我得到:

configure: WARNING: +----------------------------------------------------------
configure: WARNING: | Cannot determine global symbol prefix.
configure: WARNING: | link -dump -symbols output doesn't contain a global data symbol.
configure: WARNING: | Will proceed with no underscore.
configure: WARNING: | If this is wrong then you'll get link errors referring
configure: WARNING: | to ___gmpn_add_n (note three underscores).
configure: WARNING: | In this case do a fresh build with an override,
configure: WARNING: |     ./configure gmp_cv_asm_underscore=yes
configure: WARNING: +----------------------------------------------------------
checking how to switch to read-only data section... .data
checking for assembler .type directive... 
checking for assembler .size directive... 
checking for assembler local label prefix... configure: WARNING: "link -dump -symbols" failure
configure: WARNING: cannot determine local label, using default L
L
checking for assembler byte directive... .byte
checking how to define a 32-bit word... link: illegal option -- d

I'm trying to make a cross compiler with the files from http://crossgcc.rts-software.org/doku.php?id=i386linuxgccformac

I'm on an Intel Mac (10.6.6, x86_64) I compiled: gmp, mpfr, mpc for the cross compiler as 32bit (as I'm on a 64bit Mac) but I'm getting

ld: warning: option -s is obsolete and being ignored
ld: warning: ignoring file /gmp1/lib/libmpc.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
ld: warning: ignoring file /gmp1/lib/libmpfr.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
ld: warning: ignoring file /gmp1/lib/libgmp.dylib, file was built for unsupported file format which is not the architecture being linked (i386)

When compiling GCC with:

--prefix=/usr/local/i386-linux-4.5.2 --target=i386-linux --enable-languages=c --without-headers --disable-shared --disable-threads --disable-nls --with-gmp=/gmp1 --with-gmp-lib=/gmp1 --with-gmp-include=/gmp1 --with-mpfr=/gmp1 --with-mpfr-include=/gmp1 --with-mpfr-lib=/gmp1 --with-mpc=/gmp1 --with-mpc-lib=/gmp1 --with-mpc-include=/gmp1

Also, if I compile GMP with:

./configure --prefix=/gmp1 --host=i386-linux

I get:

configure: WARNING: +----------------------------------------------------------
configure: WARNING: | Cannot determine global symbol prefix.
configure: WARNING: | link -dump -symbols output doesn't contain a global data symbol.
configure: WARNING: | Will proceed with no underscore.
configure: WARNING: | If this is wrong then you'll get link errors referring
configure: WARNING: | to ___gmpn_add_n (note three underscores).
configure: WARNING: | In this case do a fresh build with an override,
configure: WARNING: |     ./configure gmp_cv_asm_underscore=yes
configure: WARNING: +----------------------------------------------------------
checking how to switch to read-only data section... .data
checking for assembler .type directive... 
checking for assembler .size directive... 
checking for assembler local label prefix... configure: WARNING: "link -dump -symbols" failure
configure: WARNING: cannot determine local label, using default L
L
checking for assembler byte directive... .byte
checking how to define a 32-bit word... link: illegal option -- d

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

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

发布评论

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

评论(2

○闲身 2024-10-27 00:09:41

我认为您对应该为哪个平台编译哪个包感到困惑:

  • 需要为 x86_64 MacOS X 主机和 i386-linux 目标编译 GCC。

  • GMP、MPC 和 MPFR 是 GCC 的运行时依赖项。因此,它们还需要针对 GCC 主机(在您的情况下为 x86_64)进行编译。因此,GMP 配置命令中的 --host=i386-linux 选项不正确。

一般来说,只有在GCC编译的程序中链接的库才需要为交叉编译器目标(例如i386-linux)构建。 GMP 和 MPFR 不是此类库,除非您的程序实际上正在使用它们 - 在这种情况下,您将需要此类库的两份副本,一份用于 GCC,一份用于目标的交叉构建。

编辑:

您是否考虑过使用 MacPorts?它具有交叉编译器的所有依赖项:

还有一个用于 i386 的旧版基于 newlib 的交叉编译器

即使您不想使用这些,您仍然可以查看它们的 Portfiles 中的构建说明。

底线是:

  • 应用这些库需要的任何补丁 - MacPorts 已经做到了。

  • 为您的构建主机编译库,即 MacOSX/x86_64。这意味着在其配置调用的任何 --host 选项中,您应该遵循 --host=x86_64-darwin (或您的主机需要的任何内容)。如果 configure 可以自行确定主机,您可以完全跳过 --host 选项。

  • 使用 --host 编译 GCC 作为您的构建主机(64 位 Mac OS X)和 i386-linux 的目标,例如 --目标=i386-linux。如果我是您,我会从仅适用于 C 和 C++ 语言的编译器开始。

另请参阅本教程。它有一些关于如何使用适当的 glibc 生成工作工具链的信息。

也就是说,出于多种原因,我认为您最好在虚拟机中安装适当的 Linux 发行版。您是否有理由特别需要交叉编译器?你想用这个编译器做什么?

I think that you are confused about which package should be compiled for which platform:

  • GCC needs to be compiled for an x86_64 MacOS X host and an i386-linux target.

  • GMP, MPC and MPFR are runtime dependencies for GCC. Therefore they also need to be compiled for the GCC host - x86_64 in your case. Therefore, the --host=i386-linux option in the GMP configure command is incorrect.

In general, only libraries that will be linked in the programs compiled by GCC need to be built for the cross-compiler target (e.g. i386-linux). GMP and MPFR are not such libraries, unless your programs are actually using them - in that case you will need to have two copies of such libraries, one for GCC and a cross-build for the target.

EDIT:

Have you considered using MacPorts? It has all the dependencies for your cross-compiler:

There is also an older newlib-based cross-compiler for i386:

Even if you do not want to use these, you can still have a look at the build instructions in their Portfiles.

The bottom line is:

  • Apply whatever patches these libraries need - MacPorts already do that.

  • Compile the libraries for your build host i.e. MacOSX/x86_64. That means that in any --host options for their configure calls you should be something along the lines of --host=x86_64-darwin (or whatever your host needs). If configure can figure out the host on its own, you can skip the --host options altogether.

  • Compile GCC with --host being your build host (the 64-bit Mac OS X) and a target of i386-linux, e.g. --target=i386-linux. If I were you, I'd start simple with a compiler for the C and C++ languages only.

See also this tutorial. It has some information on how to produce a working toolchain with a proper glibc.

That said, I think that you'd be better off installing a proper Linux distribution in a virtual machine, for a whole bunch of reasons. Is there a reason for you to need a cross-compiler specifically? What do you want to do with that compiler?

鸢与 2024-10-27 00:09:41

编译GMP时是否使用了“ABI=32”选项?如果没有,我认为即使主机/目标被指定为 i386,它也会使用 64 位代码。

Did you use the "ABI=32" option when compiling GMP? If not, I think it will use 64-bit code even if the host/target are specified as i386.

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