Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
GCC 4.9.4交叉编译器构建(limits.h问题)_Gcc_Cross Compiling_Toolchain - Fatal编程技术网

GCC 4.9.4交叉编译器构建(limits.h问题)

GCC 4.9.4交叉编译器构建(limits.h问题),gcc,cross-compiling,toolchain,Gcc,Cross Compiling,Toolchain,提出该问题的基本步骤: cd linux-2.6.35.9/ make ARCH=x86 INSTALL_HDR_PATH=${PREFIX}/${TARGET} headers_install cd ../ cd build-binutils/ sh ../binutils-2.28/configure --prefix=${PREFIX} --target=${TARGET} make make install cd ../ cd build-gcc/ sh ../gcc-4.9.4/c

提出该问题的基本步骤:

cd linux-2.6.35.9/
make ARCH=x86 INSTALL_HDR_PATH=${PREFIX}/${TARGET} headers_install
cd ../

cd build-binutils/
sh ../binutils-2.28/configure --prefix=${PREFIX} --target=${TARGET}
make
make install
cd ../

cd build-gcc/
sh ../gcc-4.9.4/configure --prefix=${PREFIX} --target=${TARGET} --enable-languages=c,c++ --disable-multilib
make all-gcc
make install-gcc
cd ../
我遇到的问题是,最终安装到${PREFIX}/lib/gcc/${TARGET}/4.9.4/include fixed/limits.h中的内容似乎不正确。具体来说,构建和安装GCC中的“fixincludes”位需要一个名为“sys include”的目录,该目录从未放置到位,如果没有放置到位,则前面提到的limits.h不会引用相关的syslimits.h(在同一目录中)

如果我查看build/install序列的输出,其中有一个引用,用于从组件limitx.h、limity.h和其他一些位构建此文件。这个测试失败了,它只安装了GCC附带的“generic”limits.h(它不包括对syslimits.h的引用,syslimits.h使用GCC的#include_next指令来包含${PREFIX}/${TARGET}/include/limits.h,其中包含实际的内容,我需要像NAME_MAX和PATH_MAX这样的内容)

文件中缺少的位是:

/* This administrivia gets added to the beginning of limits.h
   if the system has its own version of limits.h.  */

/* We use _GCC_LIMITS_H_ because we want this not to match
   any macros that the system's limits.h uses for its own purposes.  */
#ifndef _GCC_LIMITS_H_  /* Terminated in limity.h.  */
#define _GCC_LIMITS_H_

#ifndef _LIBC_LIMITS_H_
/* Use "..." so that we find syslimits.h only in this same directory.  */
#include "syslimits.h"
#endif
那么,是否有一个选项我没有传递给GCC的配置脚本,或者我没有在这一步之前传递给正确创建sys include目录的东西

[编辑]

TARGET=i686 redhat linux
(我们用于项目的构建服务器上的“gcc-dumpmachine”中的目标三元组)


可能更有用的信息(?):这些包只是从各自的档案中提取的“wget”。我正在安装一个最新的Ubuntu 16.04,在那里我安装了libgmp-dev和libmpfr-dev,以避免用编译器源代码编译它们。

经过更多的挖掘和反复尝试,我将一些我开始使用的东西与一个明显不推荐的选项的信息进行了匹配
——带有用于配置的标题海湾合作委员会。(
--with headers=${PREFIX}/${TARGET}/include/linux
)可以工作,但是当我构建编译器支持库时,它抱怨缺少
位/stdio_lim.h
。我找到了另一篇关于这个问题的帖子(你必须在线程中增加一点),并且在我提到的第一页提到了触摸
gnu/stubs.h
这件事

从下面我自己的评论中添加,以注意您必须删除在
make install gcc
步骤后生成的
${PREFIX}/${TARGET}/sys include
目录,否则您的普通C头将与默认情况下包含在搜索路径中的Linux内核特定头冲突

我只想说,在对我正在使用的旧Glibc(2.11.3)应用补丁后,整个序列的结果如下:

export TARGET=i686-redhat-linux
export PREFIX=$(pwd)/output
export PATH=${PATH}:${PREFIX}/bin

mkdir build-binutils
mkdir build-gcc
mkdir build-glibc

cd linux-2.6.35.9/
make ARCH=x86 INSTALL_HDR_PATH=${PREFIX}/${TARGET} headers_install
cd ../

cd build-binutils/
sh ../binutils-2.28/configure --prefix=${PREFIX} --target=${TARGET}
make
make install
cd ../

cd build-gcc/
sh ../gcc-4.9.4/configure --prefix=${PREFIX} --target=${TARGET} --enable-languages=c,c++ --disable-multilib --with-headers=${PREFIX}/${TARGET}/include/linux
make all-gcc
make install-gcc
cd ../
rm --recursive --force ${PREFIX}/${TARGET}/sys-include

cd build-glibc/
sh ../glibc-2.11.3/configure --prefix=${PREFIX}/${TARGET} --build=$(gcc -dumpmachine) --host=${TARGET} --target=${TARGET} --disable-multilib libc_cv_forced_unwind=yes libc_cv_c_cleanup=yes
make install-bootstrap-headers=yes install-headers
make csu/subdir_lib
install csu/crt1.o csu/crti.o csu/crtn.o ${PREFIX}/${TARGET}/lib
${TARGET}-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o ${PREFIX}/${TARGET}/lib/libc.so
touch ${PREFIX}/${TARGET}/include/gnu/stubs.h ${PREFIX}/${TARGET}/include/bits/stdio_lim.h
cd ../

cd build-gcc/
make all-target-libgcc
make install-target-libgcc
cd ../

cd build-glibc/
make
make install
cd ../
我没有看到任何页面真正达到这种深度(可能编程页面上的预显示实际上并不完全正确?),但我将测试此配置,并确保软件完全针对目标构建,没有问题。(我在一个文件中测试了limits.h中的NAME_MAX,它似乎工作得很好。)

我也不知道我是否需要加入
--禁用multilib
的功能,但其他页面似乎都在这么做。GCC邮件列表中的那条链谈到使用
——带有newlib
——禁用共享
作为选项,但线程中的人不同意这两个选项都是正确的解决方案

如果有人对这个问题有更好的了解,我肯定会感激一个更少的黑客,更正式的解决方案

如果有人想知道,修复Glibc 2.11.3的补丁(有两个)是一个自定义修复,用于配置脚本与GNU Make 4+一起工作:

sed -i 's/\(3.79\)/4.* | \1/' glibc-2.11.3/configure
。。。和库中两个文件的实际修补程序,以修复i686支持:

patch glibc-2.11.3/nptl/sysdeps/pthread/pt-initfini.c <<__EOF__
@@ -45,6 +45,11 @@
 /* Embed an #include to pull in the alignment and .end directives. */
 asm ("\n#include \"defs.h\"");

+asm ("\n#if defined __i686 && defined __ASSEMBLER__");
+asm ("\n#undef __i686");
+asm ("\n#define __i686 __i686");
+asm ("\n#endif");
+
 /* The initial common code ends here. */
 asm ("\n/*@HEADER_ENDS*/");

__EOF__
patch glibc-2.11.3/sysdeps/unix/sysv/linux/i386/sysdep.h <<__EOF__
@@ -29,6 +29,10 @@
 #include <dl-sysdep.h>
 #include <tls.h>

+#if defined __i686 && defined __ASSEMBLER__
+#undef __i686
+#define __i686 __i686
+#endif

 /* For Linux we can use the system call table in the header file
        /usr/include/asm/unistd.h
__EOF__

修补程序glibc-2.11.3/nptl/sysdeps/pthread/pt initfini.c经过更多的挖掘和尝试,我将一些我开始使用的东西与一个明显不推荐使用的选项的信息进行了匹配
——带有用于配置GCC的标题。(
--with headers=${PREFIX}/${TARGET}/include/linux
)可以工作,但是当我构建编译器支持库时,它抱怨缺少
位/stdio_lim.h
。我找到了另一篇关于这个问题的帖子(你必须在线程中增加一点),并且在我提到的第一页提到了触摸
gnu/stubs.h
这件事

从下面我自己的评论中添加,以注意您必须删除在
make install gcc
步骤后生成的
${PREFIX}/${TARGET}/sys include
目录,否则您的普通C头将与默认情况下包含在搜索路径中的Linux内核特定头冲突

我只想说,在对我正在使用的旧Glibc(2.11.3)应用补丁后,整个序列的结果如下:

export TARGET=i686-redhat-linux
export PREFIX=$(pwd)/output
export PATH=${PATH}:${PREFIX}/bin

mkdir build-binutils
mkdir build-gcc
mkdir build-glibc

cd linux-2.6.35.9/
make ARCH=x86 INSTALL_HDR_PATH=${PREFIX}/${TARGET} headers_install
cd ../

cd build-binutils/
sh ../binutils-2.28/configure --prefix=${PREFIX} --target=${TARGET}
make
make install
cd ../

cd build-gcc/
sh ../gcc-4.9.4/configure --prefix=${PREFIX} --target=${TARGET} --enable-languages=c,c++ --disable-multilib --with-headers=${PREFIX}/${TARGET}/include/linux
make all-gcc
make install-gcc
cd ../
rm --recursive --force ${PREFIX}/${TARGET}/sys-include

cd build-glibc/
sh ../glibc-2.11.3/configure --prefix=${PREFIX}/${TARGET} --build=$(gcc -dumpmachine) --host=${TARGET} --target=${TARGET} --disable-multilib libc_cv_forced_unwind=yes libc_cv_c_cleanup=yes
make install-bootstrap-headers=yes install-headers
make csu/subdir_lib
install csu/crt1.o csu/crti.o csu/crtn.o ${PREFIX}/${TARGET}/lib
${TARGET}-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o ${PREFIX}/${TARGET}/lib/libc.so
touch ${PREFIX}/${TARGET}/include/gnu/stubs.h ${PREFIX}/${TARGET}/include/bits/stdio_lim.h
cd ../

cd build-gcc/
make all-target-libgcc
make install-target-libgcc
cd ../

cd build-glibc/
make
make install
cd ../
我没有看到任何页面真正达到这种深度(可能编程页面上的预显示实际上并不完全正确?),但我将测试此配置,并确保软件完全针对目标构建,没有问题。(我在一个文件中测试了limits.h中的NAME_MAX,它似乎工作得很好。)

我也不知道我是否需要加入
--禁用multilib
的功能,但其他页面似乎都在这么做。GCC邮件列表中的那条链谈到使用
——带有newlib
——禁用共享
作为选项,但线程中的人不同意这两个选项都是正确的解决方案

如果有人对这个问题有更好的了解,我肯定会感激一个更少的黑客,更正式的解决方案

如果有人想知道,修复Glibc 2.11.3的补丁(有两个)是一个自定义修复,用于配置脚本与GNU Make 4+一起工作:

sed -i 's/\(3.79\)/4.* | \1/' glibc-2.11.3/configure
。。。和库中两个文件的实际修补程序,以修复i686支持:

patch glibc-2.11.3/nptl/sysdeps/pthread/pt-initfini.c <<__EOF__
@@ -45,6 +45,11 @@
 /* Embed an #include to pull in the alignment and .end directives. */
 asm ("\n#include \"defs.h\"");

+asm ("\n#if defined __i686 && defined __ASSEMBLER__");
+asm ("\n#undef __i686");
+asm ("\n#define __i686 __i686");
+asm ("\n#endif");
+
 /* The initial common code ends here. */
 asm ("\n/*@HEADER_ENDS*/");

__EOF__
patch glibc-2.11.3/sysdeps/unix/sysv/linux/i386/sysdep.h <<__EOF__
@@ -29,6 +29,10 @@
 #include <dl-sysdep.h>
 #include <tls.h>

+#if defined __i686 && defined __ASSEMBLER__
+#undef __i686
+#define __i686 __i686
+#endif

 /* For Linux we can use the system call table in the header file
        /usr/include/asm/unistd.h
__EOF__

补丁glibc-2.11.3/nptl/sysdeps/pthread/pt initfini.c
${TARGET}
的值是多少?请编辑问题以进行改进。已更新