Closed NameisNone closed 2 months ago
Bot detected the issue body's language is not English, translate it automatically.
Title: The soname configuration of the dynamic library set_version cross-compilation platform does not take effect
通过xmake f --toolchain切换工具链soname是可以生效的,但是某些库是按平台做路径区分的,所以想通过设置plat的方式动态切换一些路径和编译工具链。
Bot detected the issue body's language is not English, translate it automatically.
Switching the tool chain soname through xmake f --toolchain can take effect, but some libraries are path-divided according to platforms, so I want to dynamically switch some paths and compilation tool chains by setting plat.
可以的么
$ xmake f -p cross
$ xmake
$ tree build/cross/none/release/
build/cross/none/release/
├── libfoo.so -> libfoo.so.1
├── libfoo.so.1 -> libfoo.so.1.0.0.19
├── libfoo.so.1.0.0.19
└── test
set_version("1.0.0.19", { soname = true })
toolchain("imx8m_cc")
set_kind("standalone")
set_sdkdir("~/.xmake/packages/m/muslcc/20210202/d8df8518d75f4c899fdd7b947fb7c863/")
toolchain_end()
set_toolchains("imx8m_cc")
target("foo")
set_kind("shared")
add_files("src/foo.cpp")
target("test")
set_kind("binary")
add_deps("foo")
add_files("src/main.cpp")
可以的么
$ xmake f -p cross $ xmake $ tree build/cross/none/release/ build/cross/none/release/ ├── libfoo.so -> libfoo.so.1 ├── libfoo.so.1 -> libfoo.so.1.0.0.19 ├── libfoo.so.1.0.0.19 └── test
set_version("1.0.0.19", { soname = true }) toolchain("imx8m_cc") set_kind("standalone") set_sdkdir("~/.xmake/packages/m/muslcc/20210202/d8df8518d75f4c899fdd7b947fb7c863/") toolchain_end() set_toolchains("imx8m_cc") target("foo") set_kind("shared") add_files("src/foo.cpp") target("test") set_kind("binary") add_deps("foo") add_files("src/main.cpp")
目前是有多个平台需要通过xmake f -p imx8m,xmake f -p imx6u来切换,只能xmake f -p cross吗? 按照您这里的示例,set_toolchains放在全局是可以的,在target描述域里面根据平台判断再set_toolchains也不行:
add_rules("mode.debug", "mode.release")
toolchain("imx8m_cc")
set_kind("standalone")
set_sdkdir("../projects/toolchain/toolchain-imx8m/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu")
toolchain_end()
-- set_toolchains("imx8m_cc")
target("foo")
set_kind("shared")
set_version("1.0.0.19", { soname = true })
add_files("src/foo.cpp")
if is_plat("imx8m") then
set_toolchains("imx8m_cc")
end
target("test")
set_kind("binary")
add_deps("foo")
add_files("src/main.cpp")
if is_plat("imx8m") then
set_toolchains("imx8m_cc")
end
配置和编译结果:
none@ubuntu:~/test$ tree build/
build/
└── imx8m
└── x86_64
└── release
├── libfoo.so
└── test
3 directories, 2 files
none@ubuntu:~/test$ xmake f -v
configure
{
target_os = linux
host = linux
plat = imx8m
mode = release
buildir = build
arch = x86_64
ndk_stdcxx = true
kind = static
ccache = true
}
编译输出,可以看到没有设置-Wl,-soname:
~/test$ xmake -rv
[ 37%]: cache compiling.release src/foo.cpp
../projects/toolchain/toolchain-imx8m/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc -c -fPIC -O3 -DNDEBUG -o build/.objs/foo/imx8m/x86_64/release/src/foo.cpp.o src/foo.cpp
[ 50%]: cache compiling.release src/main.cpp
../projects/toolchain/toolchain-imx8m/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc -c -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -o build/.objs/test/imx8m/x86_64/release/src/main.cpp.o src/main.cpp
[ 62%]: linking.release libfoo.so
../projects/toolchain/toolchain-imx8m/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-g++ -o build/imx8m/x86_64/release/libfoo.so build/.objs/foo/imx8m/x86_64/release/src/foo.cpp.o -shared -fPIC -s
[ 87%]: linking.release test
../projects/toolchain/toolchain-imx8m/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-g++ -o build/imx8m/x86_64/release/test build/.objs/test/imx8m/x86_64/release/src/main.cpp.o -Lbuild/imx8m/x86_64/release -Wl,-rpath=$ORIGIN -s -lfoo
[100%]: build ok, spent 0.198s
再试试,xmake update -s dev
Bot detected the issue body's language is not English, translate it automatically.
Try again,
xmake update -s dev
再试试,
xmake update -s dev
可以了
Bot detected the issue body's language is not English, translate it automatically.
Try again,
xmake update -s dev
That's ok
Xmake 版本
2.9.4
操作系统版本和架构
windows11 23H2 WSL2 ubuntu22.04.3
描述问题
通过xmake f -p xxx,设置一个嵌入式交叉编译平台,交叉编译一个动态库,需要设置库的soname,通过以下设置未生效,未生成对应的软链接文件,且无readelf -d 查看动态库,未设置soname: set_version("1.0.0.19", { soname = true })
期待的结果
xmake f -p xxx切换平台,编译后生成对应软链接文件,且存在soname字段
工程配置
附加信息和错误日志