使用现有的交叉编译器构建newlib

3

我想使用预装的交叉编译器(mips-linux-gnu-gcc)构建newlib库。该编译器默认链接glibc。

$ mips-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=mips-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/mips-linux-gnu/5/lto-wrapper
Target: mips-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.9' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr     --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libsanitizer --disable-libquadmath --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-mips-cross/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-mips-cross --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-mips-cross --with-arch-directory=mips --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libgcj --enable-multiarch --disable-werror --enable-multilib --with-arch-32=mips32r2 --with-fp-32=xx --enable-targets=all --with-arch-64=mips64r2 --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=mips-linux-gnu --program-prefix=mips-linux-gnu- --includedir=/usr/mips-linux-gnu/include
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.9)

现在我想使用mips编译器编译newlib库:

$ ../newlib-3.0.0.20180226/configure  --target=mips-linux-gnu --prefix=`pwd`                                                                                                 
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... mips-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /bin/sed
checking for gawk... no
checking for mawk... mawk
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o  
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether we are using the GNU C++ compiler... no
checking whether mips-linux-gnu-gcc accepts -g... no
checking whether g++ accepts -static-libstdc++ -static-libgcc... no
checking for gnatbind... no
checking for gnatmake... no
checking whether compiler driver understands Ada... no
checking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1 $$f2
checking for objdir... .libs
checking for isl 0.16, 0.15, or deprecated 0.14... no
recommended isl version is 0.16 or 0.15, the minimum required isl version 0.14 is deprecated
checking for isl 0.16 or 0.15... no
*** This configuration is not supported in the following subdirectories:
 target-newlib target-libgloss
(Any other directories should still work fine.)
checking for default BUILD_CONFIG... 
checking for --enable-vtable-verify... no
checking for bison... bison -y
checking for bison... bison
checking for gm4... no
checking for gnum4... no
checking for m4... m4
checking for flex... no
checking for lex... no
checking for flex... no
checking for makeinfo... makeinfo
checking for expect... no
checking for runtest... no
checking for strip... strip
checking for windres... no
checking for windmc... no
checking for objcopy... objcopy
checking for objdump... objdump
checking for readelf... readelf
checking for mips-linux-gnu-cc... no
checking for mips-linux-gnu-gcc... mips-linux-gnu-gcc
checking for mips-linux-gnu-c++... no
checking for mips-linux-gnu-g++... no
checking for mips-linux-gnu-cxx... no
checking for mips-linux-gnu-gxx... no
checking for mips-linux-gnu-gcc... mips-linux-gnu-gcc
checking for mips-linux-gnu-gcj... no
checking for mips-linux-gnu-gfortran... no
checking for mips-linux-gnu-gccgo... no  
checking for mips-linux-gnu-ar... mips-linux-gnu-ar
checking for mips-linux-gnu-as... mips-linux-gnu-as
checking for mips-linux-gnu-dlltool... no
checking for mips-linux-gnu-ld... mips-linux-gnu-ld
checking for mips-linux-gnu-lipo... no
checking for mips-linux-gnu-nm... mips-linux-gnu-nm
checking for mips-linux-gnu-objcopy... mips-linux-gnu-objcopy
checking for mips-linux-gnu-objdump... mips-linux-gnu-objdump
checking for mips-linux-gnu-ranlib... mips-linux-gnu-ranlib
checking for mips-linux-gnu-readelf... mips-linux-gnu-readelf
checking for mips-linux-gnu-strip... mips-linux-gnu-strip
checking for mips-linux-gnu-windres... no
checking for mips-linux-gnu-windmc... no
checking where to find the target ar... pre-installed
checking where to find the target as... pre-installed
checking where to find the target cc... pre-installed
checking where to find the target c++... pre-installed
checking where to find the target c++ for libstdc++... pre-installed
checking where to find the target dlltool... pre-installed
checking where to find the target gcc... pre-installed
checking where to find the target gcj... pre-installed
checking where to find the target gfortran... pre-installed
checking where to find the target gccgo... pre-installed
checking where to find the target ld... pre-installed
checking where to find the target lipo... pre-installed
checking where to find the target nm... pre-installed
checking where to find the target objcopy... pre-installed
checking where to find the target objdump... pre-installed
checking where to find the target ranlib... pre-installed
checking where to find the target readelf... pre-installed
checking where to find the target strip... pre-installed
checking where to find the target windres... pre-installed
checking where to find the target windmc... pre-installed
checking whether to enable maintainer-specific portions of Makefiles... no
configure: creating ./config.status
config.status: creating Makefile

但是之后我运行 make 命令时没有任何反应:

$ make
make[1]: Entering directory '/home/qfi/newlib-build'
mkdir -p -- ./etc
Configuring in ./etc
configure: creating cache ./config.cache
checking for a BSD-compatible install... /usr/bin/install -c
configure: updating cache ./config.cache
configure: creating ./config.status
config.status: creating Makefile
make[2]: Entering directory '/home/qfi/newlib-build/etc'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/qfi/newlib-build/etc'  
make[1]: Nothing to be done for 'all-target'.
make[1]: Leaving directory '/home/qfi/newlib-build'

当我将CC设置为mips-linux-gnu-gcc时,make命令会抱怨缺少--host选项。我的构建步骤有问题吗?

这个任务一开始似乎很简单,但现在我不知道该如何让它工作。


“--prefix=`pwd`” … 真的吗?这将把它安装到与构建树相同的目录中,这将使从已安装文件中解开构建工件变得困难。如果您不打算安装它,则可以省略“--prefix”选项。 - Jonathan Wakely
1个回答

1

我认为问题在这里展示在newlib配置中:

*** This configuration is not supported in the following subdirectories:
 target-newlib target-libgloss

那意味着它实际上不会为目标构建newlib!我认为问题在于mips-linux-gnu对于newlib来说不是一个有意义的目标,因为这意味着使用glibc,而newlib不想依赖于glibc。我可能错了,但我认为你需要像mips-elf交叉编译器这样的东西来构建newlib(关于目标三元组,所以请检查一下!)。所以首先使用--target=mips-elf --without-headers --prefix=$PATH_WHERE_YOU_WANT_THE_CROSS_COMPILER配置GCC,并且只构建编译器(而不是其运行时库),使用make all-gcc && make install-gcc。然后你可以使用该GCC来构建newlib(使用相同的--target,并确保$PATH_WHERE_YOU_WANT_THE_CROSS_COMPILER/bin在你的$PATH中),然后你可以构建另一个使用刚安装的newlib的GCC。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接