我尝试使用GCC 4.9为IBM Blue Gene / Q编译一些东西。作为依赖,我需要gmp(GNU Multi Precision)库,我使用的是版本6.1.1。这与GNU Autotools一起提供。 奇怪的是,之前曾与LLVM合作过。昨天它在中午没有工作,但在晚上又没有了,今天也没有了。老实说,我很困惑。
在Blue Gene / Q上,您在IBM PowerPC 740上编译并让它在IBM PowerPC A2处理器上运行。因此,您需要使用交叉编译器。我的configure
如下:
/homec/hbn28/hbn28e/Sources/gmp-6.1.1/configure \
--prefix=/homec/hbn28/hbn28e/local-juqueen \
--host=powerpc64-bgq-linux \
--build=powerpc64-unknown-linux-gnu \
--disable-shared \
--enable-static \
CC=/bgsys/local/gcc/4.9.3/bin/mpigcc \
CXX=/bgsys/local/gcc/4.9.3/bin/mpig++ \
'CFLAGS=-O2 \
-finline-limit=50000 \
-Wall \
-Wpedantic \
-fmax-errors=1 \
-fdiagnostics-color=auto \
-Drestrict=__restrict__ \
--std=gnu99'
第一个问题是这个错误。
/usr/include/stdio.h:34:21: error: stddef.h: No such file or directory
生成的Makefile
已将CC
用于少量文件,但随后使用CC=$(CC_FOR_BUILD)
反复调用。这只是默认设置为cc
,前端编译器在计算后端没有任何好处。所以我在CC_FOR_BUILD=/bgsys/local/gcc/4.9.3/bin/mpigcc
标志中添加了configure
。这解决了这个错误。
然后configure
脚本运行得更远:
checking build system type... powerpc64-unknown-linux-gnu
checking host system type... powerpc64-bgq-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for powerpc64-bgq-linux-strip... no
checking for strip... strip
configure: WARNING: using cross tools not prefixed with host triplet
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking ABI=mode64
checking whether /bgsys/local/gcc/4.9.3/bin/mpigcc is gcc... yes
checking compiler /bgsys/local/gcc/4.9.3/bin/mpigcc -O2 -finline-limit=50000 -Wall -Wpedantic -fmax-errors=1 -fdiagnostics-color=auto -Drestrict=__restrict__ --std=gnu99 ... yes
checking compiler /bgsys/local/gcc/4.9.3/bin/mpigcc -O2 -finline-limit=50000 -Wall -Wpedantic -fmax-errors=1 -fdiagnostics-color=auto -Drestrict=__restrict__ --std=gnu99 has sizeof(long)==8... yes
checking for powerpc64-bgq-linux-gcc... /bgsys/local/gcc/4.9.3/bin/mpigcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /bgsys/local/gcc/4.9.3/bin/mpigcc accepts -g... yes
checking for /bgsys/local/gcc/4.9.3/bin/mpigcc option to accept ISO C89... none needed
checking whether /bgsys/local/gcc/4.9.3/bin/mpigcc understands -c and -o together... yes
checking for /bgsys/local/gcc/4.9.3/bin/mpigcc option to accept ISO C99... none needed
checking for /bgsys/local/gcc/4.9.3/bin/mpigcc option to accept ISO Standard C... (cached) none needed
checking how to run the C preprocessor... /bgsys/local/gcc/4.9.3/bin/mpigcc -E
checking build system compiler /bgsys/local/gcc/4.9.3/bin/mpigcc... no
configure: error: Specified CC_FOR_BUILD doesn't seem to work
查看config.log
,它说
configure:9899: checking build system compiler /bgsys/local/gcc/4.9.3/bin/mpigcc
configure:9912: /bgsys/local/gcc/4.9.3/bin/mpigcc conftest.c
configure:9915: $? = 0
/bgsys/source/srcV1R2M4.29840/comm/sys/buildtools/pami/common/bgq/BgqPersonality.h:102:
/bgsys/source/srcV1R2M4.29840/comm/sys/buildtools/pami/common/bgq/BgqPersonality.h<102>
/homec/hbn28/hbn28e/Sources/gmp-6.1.1/configure: line 10000: 26929 Aborted (core dumped) ./a.out
/homec/hbn28/hbn28e/Sources/gmp-6.1.1/configure: line 9917: ./b.out: No such file or directory
/homec/hbn28/hbn28e/Sources/gmp-6.1.1/configure: line 9917: ./a.exe: No such file or directory
/homec/hbn28/hbn28e/Sources/gmp-6.1.1/configure: line 9917: ./a_out.exe: No such file or directory
/homec/hbn28/hbn28e/Sources/gmp-6.1.1/configure: line 9917: ./conftest: No such file or directory
configure:9922: result: no
configure:9927: error: Specified CC_FOR_BUILD doesn't seem to work
似乎使用了正确的编译器。当在前端(我编译的地方)运行程序时,它失败,因为BgqPersonality.h
有关于计算后端的特殊信息,程序无法在前端运行。
configure
假定编译器已损坏(可以说是前端)并停止构建。以前我没有LLVM的错误,交叉编译工作正常。 configure
甚至说checking whether we are cross compiling... yes
因此必须了解情况。也许CC_FOR_BUILD
用于前端,而CC
用于计算后端。没有CC_FOR_BUILD
我无法编译,如上所述。
有没有办法让这个交叉编译正确?
答案 0 :(得分:2)
CC_FOR_BUILD
应该是一个可以为当前系统编译工具的编译器,而不是你想为其构建二进制文件的工具。该名称来自于CBUILD
是引用构建所发生的系统的名称。
I wrote a blog post some time ago解释了这些系统的命名以及它们应该如何使用。