CentOS 6.8 上的 xgboost 构建错误

xgboost build error on CentOS 6.8

操作系统:CentOS 6.8

编译器:gcc 4.8.2 和 g++4.8.2

重现步骤

只需按照 installation guide

中的步骤操作即可

我的脚步

git clone --recursive https://github.com/dmlc/xgboost git submodule init git submodule update cd xgboost make -j4

然后我得到下面的错误

[root@xxx]# make -j4 g++ -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -Idmlc-core/include -Irabit/include -fPIC -fopenmp -MM -MT build/learner.o src/learner.cc >build/learner.d g++ -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -Idmlc-core/include -Irabit/include -fPIC -fopenmp -MM -MT build/logging.o src/logging.cc >build/logging.d g++ -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -Idmlc-core/include -Irabit/include -fPIC -fopenmp -MM -MT build/c_api/c_api.o src/c_api/c_api.cc >build/c_api/c_api.d g++ -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -Idmlc-core/include -Irabit/include -fPIC -fopenmp -MM -MT build/c_api/c_api_error.o src/c_api/c_api_error.cc >build/c_api/c_api_error.d g++ -c -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -Idmlc-core/include -Irabit/include -fPIC -fopenmp src/c_api/c_api_error.cc -o build/c_api/c_api_error.o g++ -c -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -Idmlc-core/include -Irabit/include -fPIC -fopenmp src/learner.cc -o build/learner.o g++ -c -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -Idmlc-core/include -Irabit/include -fPIC -fopenmp src/logging.cc -o build/logging.o g++ -c -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -Idmlc-core/include -Irabit/include -fPIC -fopenmp src/c_api/c_api.cc -o build/c_api/c_api.o g++ -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -Idmlc-core/include -Irabit/include -fPIC -fopenmp -MM -MT build/common/common.o src/common/common.cc >build/common/common.d g++ -c -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -Idmlc-core/include -Irabit/include -fPIC -fopenmp src/common/common.cc -o build/common/common.o g++ -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -Idmlc-core/include -Irabit/include -fPIC -fopenmp -MM -MT build/data/data.o src/data/data.cc >build/data/data.d g++ -c -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -Idmlc-core/include -Irabit/include -fPIC -fopenmp src/data/data.cc -o build/data/data.o g++ -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -Idmlc-core/include -Irabit/include -fPIC -fopenmp -MM -MT build/data/simple_csr_source.o src/data/simple_csr_source.cc >build/data/simple_csr_source.d g++ -c -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -Idmlc-core/include -Irabit/include -fPIC -fopenmp src/data/simple_csr_source.cc -o build/data/simple_csr_source.o /tmp/ccNp7oXM.s: Assembler messages: /tmp/ccNp7oXM.s:148: Error: expecting string instruction after `rep' /tmp/ccNp7oXM.s:1796: Error: expecting string instruction after `rep' /tmp/ccNp7oXM.s:4394: Error: expecting string instruction after `rep' make: *** [build/data/simple_csr_source.o] Error 1 make: *** Waiting for unfinished jobs.... /tmp/ccnxYuhm.s: Assembler messages: /tmp/ccnxYuhm.s:44: Error: expecting string instruction after `rep' /tmp/ccnxYuhm.s:272: Error: expecting string instruction after `rep' /tmp/ccnxYuhm.s:276: Error: expecting string instruction after `rep' /tmp/ccnxYuhm.s:316: Error: expecting string instruction after `rep' /tmp/ccnxYuhm.s:29012: Error: expecting string instruction after `rep' make: *** [build/learner.o] Error 1 /tmp/ccyHo0ol.s: Assembler messages: /tmp/ccyHo0ol.s:331: Error: expecting string instruction after `rep' /tmp/ccyHo0ol.s:386: Error: expecting string instruction after `rep' /tmp/ccyHo0ol.s:555: Error: expecting string instruction after `rep' /tmp/ccyHo0ol.s:11407: Error: expecting string instruction after `rep' /tmp/ccyHo0ol.s:17712: Error: expecting string instruction after `rep' make: *** [build/c_api/c_api.o] Error 1 /tmp/cc3gD7Gv.s: Assembler messages: /tmp/cc3gD7Gv.s:82: Error: expecting string instruction after `rep' make: *** [build/data/data.o] Error 1

对于根本原因有什么建议吗?

我不熟悉 xgboost,但是从错误中可以明显看出某些 ASM 代码没有正确生成:

expecting string instruction after `rep'

ASM中的REP关键字前缀表示"repeat this instruction a number of times (defined by the C register)".

不过也可能是您的工具链有问题。实际上,如果生成此错误的代码不依赖于内联 ASM,这似乎是一个工具链错误。

某些版本的 binutils 认为 rep ret 无效,而实际上它是一个有效的 x86-64 指令。

尝试升级到 binutils 2.23.52.0.1