【问题标题】:How to compile Xeon phi patched gcc from source?如何从源代码编译 Xeon phi 修补 gcc?
【发布时间】:2015-08-31 20:49:02
【问题描述】:

我从 intel 网站下载了 MPSS 软件堆栈版本 3.5.2 源代码。我正在尝试从源代码编译 xeon phi 移植的 GCC(从 GCC 4.7.0 移植)并将其安装在本地子目录中。但是,我收到以下错误-

k1om-mpss-linux-gcc -dumpspecs > tmp-specs
/bin/sh: k1om-mpss-linux-gcc: command not found

我的配置如下-

# The below directory contains the cross compiled libs
# like assembler and linker
export PATH=$HOME/xeon-phi-gcc/bin
# The configure command
../xeon-phi-gcc/configure \
  --build=x86_64-linux \
  --host=x86_64-mpsssdk-linux \
  --target=k1om-mpss-linux \
  --prefix=$HOME/cross-gcc \
  --enable-languages=c,c++ \
  --with-sysroot=/opt/mpss/3.5.1/sysroots/k1om-mpss-linux \
  --disable-multilib
# Compiling
make

为什么 Makefile 调用 k1om-mpss-linux-gcc ?这不应该是 make 完成后交叉编译的 gcc 二进制文件吗?我该如何解决这个问题或我错过了什么?

编辑 1:我将配置参数更改为 --build=x86_64-mpsssdk-linux --host=x86_64-mpsssdk-linux。我现在收到以下错误-

In file included from gtype-desc.c:30:0:
../../gcc-4.7.0+mpss3.5.2/gcc/tree.h:3179:11: warning: identifier ‘thread_local’ conflicts with C++ keyword [-Wc++-compat]
  unsigned thread_local : 1;
           ^
gtype-desc.c:8696:18: error: subscripted value is neither array nor pointer nor vector
     sizeof (x_rtl[0]),
                  ^
gtype-desc.c:8815:36: error: subscripted value is neither array nor pointer nor vector
     sizeof (default_target_libfuncs[0]),
                                    ^
gtype-desc.c:8899:31: error: subscripted value is neither array nor pointer nor vector
     sizeof (default_target_rtl[0]),
                               ^
gtype-desc.c:8920:31: error: subscripted value is neither array nor pointer nor vector
     sizeof (default_target_rtl[0]),
                               ^
gtype-desc.c:8927:31: error: subscripted value is neither array nor pointer nor vector
     sizeof (default_target_rtl[0]),
                               ^
gtype-desc.c:8934:31: error: subscripted value is neither array nor pointer nor vector
     sizeof (default_target_rtl[0]),
                               ^

gtype-desc.c 是机器生成的文件。

编辑 2:我现在收到错误-

/tmp/cc4aDvmI.s: Assembler messages:
/tmp/cc4aDvmI.s:94: Error: no such instruction: `kmov %esi,%k2'
/tmp/cc4aDvmI.s:147: Error: no such instruction: `kmov %edi,%k2'
/tmp/cc4aDvmI.s:255: Error: no such instruction: `kmov %r8d,%k2'
/tmp/cc4aDvmI.s:258: Error: no such instruction: `vpackstorelq %zmm0,(%rsp){%k2}'

我该如何解决这个问题?这些似乎是向量指令,但我认为 gcc 交叉编译器不支持向量指令。

【问题讨论】:

  • "/tmp/cc4aDvmI.s:258: Error: no such instruction: 'vpackstorelq %zmm0,(%rsp){%k2}'" 表示 GCC 生成该向量指令,但 Assembler 不不支持。尝试将更正 as(来自 MPSS)的路径添加到 $PATH,或者您可能需要使用 --with-as=... 选项重建 GCC。
  • 预安装的汇编器是/usr/bin/as/opt/mpss/3.5.1/sysroots/x86_64-mpsssdk-linux/usr/bin/k1om-mpss-linux/k1om-mpss-linux-as。然而,配置脚本会寻找x86_64-mpsssdk-linux-as。我应该使用哪一个,或者我还需要制作另一个汇编器?
  • 事实上,我尝试使用它们,它们都给出了相同的错误。
  • 你确定GCC真的使用k1om-mpss‌​-linux-as吗? (例如,您可以查看strace -f -o out.strace /path/to/gcc ...)我刚刚尝试使用 MPSS 3.5.1 中的 k1om-mpss‌​-linux-as 组装 'vpackstorelq %zmm0,(%rsp){%k2}',它可以工作。
  • 你说的是普通的 GCC 还是 GCC 交叉编译器?只是为了澄清,我正在尝试安装交叉编译器。仅当使用 icc 或预安装的交叉编译器编译程序时发生此错误时,Google 才会给我结果。我在编译gcc-4.7.0+mpss3.5.2 源代码时收到此错误。

标签: linux gcc cross-compiling porting xeon-phi


【解决方案1】:

您的--build--host--target 机器都是不同的(这被称为canadian 编译,这与cross 编译略有不同,其中--build--host 相同)。这意味着需要额外的编译器来构建目标库。

来自 GCC 文档 (6.1):

如果 build 和 host 不同,您必须已经构建并安装了用于构建目标库的交叉编译器(如果您配置了 --target=foo-bar,此编译器将被称为 foo-bar -gcc)。

因此,由于您的 --targetk1om-mpss-linux,因此您需要该版本的编译器才能构建 GCC。

结果将是在 --build 机器上编译的 GCC,它将在 --host 机器上运行,并生成可以在 --target 机器上运行的代码。

【讨论】:

  • 当我执行intel-provided-cross-compiler-gcc -v 时,我也会得到相同的配置选项。澄清一下,我正在尝试构建交叉编译器,而不是本机编译器。
  • k1om-mpss-linux GCC;您没有进行交叉编译,因为您给出了不同的--target;交叉编译要求--build--host 相同
  • 我不明白为什么我需要 foo-bar-gcc。 target 是新编译器将为其生成二进制文件的体系结构,host 是新编译器将在其上运行的体系结构。因此,要生成新编译器的二进制文件,应该需要buildhost 之间的交叉编译器,还是不需要?
  • 虽然build 更容易(因为它是用于编译的拱门),host 是运行已编译(较新)GCC 的架构,target 是由较新的 GCC 编译的代码。基本上,您说:使用我的x86_64-linux 构建一个将在x86_64-mpsssdk-linux 上运行的编译器,该编译器将为k1om-mpss-linux 生成代码
  • 这正是我所说的。澄清一下,如果k1om-mpss-linux-gcc 是我最终想要做的,你能告诉我正确的配置参数应该是什么。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-05-13
  • 2015-01-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-12-01
相关资源
最近更新 更多