Star

fPIE 编译错误

Nebula 1.1.0 版本:

因为可执行文,一般都要求加上安全项fPIE pie

然而当增加安全编译连接选项:-fPIE -pie
set(CMAKE_EXE_LINKER_FLAGS “${CMAKE_EXE_LINKER_FLAGS} -fPIE -pie”)

出现编译错误:

/opt/vesoft/toolset/gcc/7.5.0/libexec/gcc/x86_64-vesoft-linux/7.5.0/ld.bfd: /opt/vesoft/third-party/lib64/librocksdb.a(transaction_db_mutex_impl.cc.o): relocation R_X86_64_32S against symbol `_ZTVN7rocksdb24TransactionDBCondVarImplE' can not be used when making a shared object; recompile with -fPIC
/opt/vesoft/toolset/gcc/7.5.0/libexec/gcc/x86_64-vesoft-linux/7.5.0/ld.bfd: /opt/vesoft/third-party/lib64/librocksdb.a(transaction_lock_mgr.cc.o): relocation R_X86_64_32 against symbol `__pthread_key_create@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/opt/vesoft/toolset/gcc/7.5.0/libexec/gcc/x86_64-vesoft-linux/7.5.0/ld.bfd: /opt/vesoft/third-party/lib64/librocksdb.a(transaction_util.cc.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/opt/vesoft/toolset/gcc/7.5.0/libexec/gcc/x86_64-vesoft-linux/7.5.0/ld.bfd: /opt/vesoft/third-party/lib64/librocksdb.a(write_prepared_txn.cc.o): relocation R_X86_64_32S against symbol `_ZNK7rocksdb12SnapshotImpl17GetSequenceNumberEv' can not be used when making a shared object; recompile with -fPIC
/opt/vesoft/toolset/gcc/7.5.0/libexec/gcc/x86_64-vesoft-linux/7.5.0/ld.bfd: /opt/vesoft/third-party/lib64/librocksdb.a(write_unprepared_txn_db.cc.o): relocation R_X86_64_32 against symbol `__pthread_key_create@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/opt/vesoft/toolset/gcc/7.5.0/libexec/gcc/x86_64-vesoft-linux/7.5.0/ld.bfd: /opt/vesoft/third-party/lib64/librocksdb.a(write_batch_with_index.cc.o): relocation R_X86_64_32S against `.rodata._ZNK7rocksdb16WBWIIteratorImpl5EntryEv.str1.1' can not be used when making a shared object; recompile with -fPIC
/opt/vesoft/toolset/gcc/7.5.0/libexec/gcc/x86_64-vesoft-linux/7.5.0/ld.bfd: /opt/vesoft/third-party/lib64/librocksdb.a(write_batch_with_index_internal.cc.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/opt/vesoft/toolset/gcc/7.5.0/libexec/gcc/x86_64-vesoft-linux/7.5.0/ld.bfd: /opt/vesoft/third-party/lib64/librocksdb.a(write_unprepared_txn.cc.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/opt/vesoft/toolset/gcc/7.5.0/libexec/gcc/x86_64-vesoft-linux/7.5.0/ld.bfd: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
make[2]: *** [bin/nebula-metad] Error 1
make[1]: *** [src/daemons/CMakeFiles/nebula-metad.dir/all] Error 2

求助一下专家

为什么要加fPIE, nebula是静态链接。

@dingding
因为编译出的Nebula graphd metad等,都是可执行的文件啊,默认都会加上PIE啊

nebula依赖的是静态库,不需要加,你不需要修改任何东西,直接编译出来的binary就可以用。

@dingding
为什么要加-no-pie啊?

image

因为nebula-graph将所有依赖编译成静态库,不是动态库。方便安装部署。

浙ICP备20010487号