Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

交叉编译时编译选项设置有问题 #5814

Closed
heheda123123 opened this issue Nov 12, 2024 · 3 comments
Closed

交叉编译时编译选项设置有问题 #5814

heheda123123 opened this issue Nov 12, 2024 · 3 comments
Labels
Milestone

Comments

@heheda123123
Copy link
Contributor

heheda123123 commented Nov 12, 2024

Xmake 版本

v2.9.5 dev.6c2929b

操作系统版本和架构

ubuntu 24

描述问题

ubuntu 24上交叉编译时

xmake f -p cross -a aarch64 -c --cross=aarch64-linux-gnu- -m release

很多依赖都出现了下面的错误

[ 89%]: linking.release libplugin_socks5.so
/usr/bin/aarch64-linux-gnu-g   -o build/cross/aarch64/release/libplugin_socks5.so build/.objs/plugin_socks5/cross/aarch64/release/src/plugin/socks5/dllmain.cpp.o -shared -fPIC -L/home/cat/.xmake/packages/c/cpp-ipc/1.3.0/a5f38dad456340db88e770c8da0c2ff1/lib -L/home/cat/.xmake/packages/j/jsoncpp/1.9.6/a35f4306b8d04c22ba0951436f5774dc/lib -L/home/cat/.xmake/packages/s/spdlog/v1.15.0/cbfcb8dbd3714ff789c197958e006950/lib -L/home/cat/.xmake/packages/f/fmt/11.0.2/796d602e931f45448ce7549a2659bf55/lib -s -lipc -ljsoncpp -lspdlog -lfmt
/usr/lib/gcc-cross/aarch64-linux-gnu/13/../../../../aarch64-linux-gnu/bin/ld: /home/cat/.xmake/packages/j/jsoncpp/1.9.6/a35f4306b8d04c22ba0951436f5774dc/lib/libjsoncpp.a(json_value.cpp.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_ZTVN4Json9ExceptionE' which may bind externally can not be used when making a shared object; recompile with -fPIC
/home/cat/.xmake/packages/j/jsoncpp/1.9.6/a35f4306b8d04c22ba0951436f5774dc/lib/libjsoncpp.a(json_value.cpp.o): in function `Json::Exception::~Exception()':
json_value.cpp:(.text 0x18): dangerous relocation: unsupported relocation
/usr/lib/gcc-cross/aarch64-linux-gnu/13/../../../../aarch64-linux-gnu/bin/ld: /home/cat/.xmake/packages/j/jsoncpp/1.9.6/a35f4306b8d04c22ba0951436f5774dc/lib/libjsoncpp.a(json_value.cpp.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_ZTVN4Json9ExceptionE' which may bind externally can not be used when making a shared object; recompile with -fPIC
/home/cat/.xmake/packages/j/jsoncpp/1.9.6/a35f4306b8d04c22ba0951436f5774dc/lib/libjsoncpp.a(json_value.cpp.o): in function `Json::Exception::~Exception()':
json_value.cpp:(.text 0x58): dangerous relocation: unsupported relocation
/usr/lib/gcc-cross/aarch64-linux-gnu/13/../../../../aarch64-linux-gnu/bin/ld: /home/cat/.xmake/packages/j/jsoncpp/1.9.6/a35f4306b8d04c22ba0951436f5774dc/lib/libjsoncpp.a(json_value.cpp.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_ZN4Json5ValueD1Ev' which may bind externally can not be used when making a shared object; recompile with -fPIC
/home/cat/.xmake/packages/j/jsoncpp/1.9.6/a35f4306b8d04c22ba0951436f5774dc/lib/libjsoncpp.a(json_value.cpp.o): in function `Json::Value::nullSingleton()':
json_value.cpp:(.text 0x848): dangerous relocation: unsupported relocation
/usr/lib/gcc-cross/aarch64-linux-gnu/13/../../../../aarch64-linux-gnu/bin/ld: /home/cat/.xmake/packages/j/jsoncpp/1.9.6/a35f4306b8d04c22ba0951436f5774dc/lib/libjsoncpp.a(json_value.cpp.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_ZTVN4Json9ExceptionE' which may bind externally can not be used when making a shared object; recompile with -fPIC
/home/cat/.xmake/packages/j/jsoncpp/1.9.6/a35f4306b8d04c22ba0951436f5774dc/lib/libjsoncpp.a(json_value.cpp.o): in function `Json::Exception::Exception(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':

/usr/lib/gcc-cross/aarch64-linux-gnu/13/../../../../aarch64-linux-gnu/bin/ld: /home/cat/.xmake/packages/j/jsoncpp/1.9.6/a35f4306b8d04c22ba0951436f5774dc/lib/libjsoncpp.a(json_writer.cpp.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_ZTVN4Json10FastWriterE' which may bind externally can not be used when making a shared object; recompile with -fPIC
/home/cat/.xmake/packages/j/jsoncpp/1.9.6/a35f4306b8d04c22ba0951436f5774dc/lib/libjsoncpp.a(json_writer.cpp.o): in function `Json::FastWriter::~FastWriter()':
json_writer.cpp:(.text._ZN4Json10FastWriterD2Ev[_ZN4Json10FastWriterD5Ev] 0xc): dangerous relocation: unsupported relocation
/usr/lib/gcc-cross/aarch64-linux-gnu/13/../../../../aarch64-linux-gnu/bin/ld: /home/cat/.xmake/packages/j/jsoncpp/1.9.6/a35f4306b8d04c22ba0951436f5774dc/lib/libjsoncpp.a(json_writer.cpp.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_ZTVN4Json10FastWriterE' which may bind externally can not be used when making a shared object; recompile with -fPIC
/home/cat/.xmake/packages/j/jsoncpp/1.9.6/a35f4306b8d04c22ba0951436f5774dc/lib/libjsoncpp.a(json_writer.cpp.o): in function `Json::FastWriter::~FastWriter()':
json_writer.cpp:(.text._ZN4Json10FastWriterD0Ev[_ZN4Json10FastWriterD5Ev] 0x8): dangerous relocation: unsupported relocation
/usr/lib/gcc-cross/aarch64-linux-gnu/13/../../../../aarch64-linux-gnu/bin/ld: /home/cat/.xmake/packages/j/jsoncpp/1.9.6/a35f4306b8d04c22ba0951436f5774dc/lib/libjsoncpp.a(json_writer.cpp.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_ZTVN4Json12StyledWriterE' which may bind externally can not be used when making a shared object; recompile with -fPIC
/home/cat/.xmake/packages/j/jsoncpp/1.9.6/a35f4306b8d04c22ba0951436f5774dc/lib/libjsoncpp.a(json_writer.cpp.o): in function `Json::StyledWriter::~StyledWriter()':
json_writer.cpp:(.text._ZN4Json12StyledWriterD2Ev[_ZN4Json12StyledWriterD5Ev] 0x8): dangerous relocation: unsupported relocation
/usr/lib/gcc-cross/aarch64-linux-gnu/13/../../../../aarch64-linux-gnu/bin/ld: /home/cat/.xmake/packages/j/jsoncpp/1.9.6/a35f4306b8d04c22ba0951436f5774dc/lib/libjsoncpp.a(json_writer.cpp.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_ZTVN4Json12StyledWriterE' which may bind externally can not be used when making a shared object; recompile with -fPIC
/home/cat/.xmake/packages/j/jsoncpp/1.9.6/a35f4306b8d04c22ba0951436f5774dc/lib/libjsoncpp.a(json_writer.cpp.o): in function `Json::StyledWriter::~StyledWriter()':
json_writer.cpp:(.text._ZN4Json12StyledWriterD0Ev[_ZN4Json12StyledWriterD5Ev] 0x8): dangerous relocation: unsupported relocation
/usr/lib/gcc-cross/aarch64-linux-gnu/13/../../../../aarch64-linux-gnu/bin/ld: /home/cat/.xmake/packages/j/jsoncpp/1.9.6/a35f4306b8d04c22ba0951436f5774dc/lib/libjsoncpp.a(json_writer.cpp.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_ZTVN4Json23BuiltStyledStreamWriterE' which may bind externally can not be used when making a shared object; recompile with -fPIC
/home/cat/.xmake/packages/j/jsoncpp/1.9.6/a35f4306b8d04c22ba0951436f5774dc/lib/libjsoncpp.a(json_writer.cpp.o): in function `Json::BuiltStyledStreamWriter::~BuiltStyledStreamWriter()':
json_writer.cpp:(.text._ZN4Json23BuiltStyledStreamWriterD2Ev[_ZN4Json23BuiltStyledStreamWriterD5Ev] 0x8): dangerous relocation: unsupported relocation
/usr/lib/gcc-cross/aarch64-linux-gnu/13/../../../../aarch64-linux-gnu/bin/ld: /home/cat/.xmake/packages/j/jsoncpp/1.9.6/a35f4306b8d04c22ba0951436f5774dc/lib/libjsoncpp.a(json_writer.cpp.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_ZTVN4Json23BuiltStyledStreamWriterE' which may bind externally can not be used when making a shared object; recompile with -fPIC
/home/cat/.xmake/packages/j/jsoncpp/1.9.6/a35f4306b8d04c22ba0951436f5774dc/lib/libjsoncpp.a(json_writer.cpp.o): in function `Json::BuiltStyledStreamWriter::~BuiltStyledStreamWriter()':
json_writer.cpp:(.text._ZN4Json23BuiltStyledStreamWriterD0Ev[_ZN4Json23BuiltStyledStreamWriterD5Ev] 0x8): dangerous relocation: unsupported relocation

但是pic应该是默认启用了才对

期待的结果

交叉编译时,依赖默认没有启用pic

工程配置

add_requires("jsoncpp", {configs = {shared = false}})

add_packages("jsoncpp")

附加信息和错误日志

1

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Title: There is a problem with the compilation option setting during cross compilation

@heheda123123
Copy link
Contributor Author

heheda123123 commented Nov 12, 2024

star恒大佬指点,手动加编译选项就可以了

 add_requires("jsoncpp", {configs = {shared = false, cxflags="-fPIC"}})

看起来确实应该是pic设置没生效?

@waruqi
Copy link
Member

waruqi commented Nov 13, 2024

see #5816 (comment)

@waruqi waruqi added this to the v2.9.7 milestone Nov 13, 2024
@waruqi waruqi closed this as completed Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants