-
-
Notifications
You must be signed in to change notification settings - Fork 779
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
开启soname时多次调用xmake导致编译产物被删除 #4706
Comments
Title: When soname is turned on, calling xmake multiple times causes the compiled product to be deleted. |
这里 ok,没法复现,如果代码没改,targetfile 不更新,按理 after_link 都不会被执行才对。。 ruki@0d35ffa77272:/mnt/xmake/tests/projects/c++/shared_library_with_soname$ tree build/
build/
`-- linux
`-- x86_64
`-- release
|-- libfoo.so -> libfoo.so.1
|-- libfoo.so.1 -> libfoo.so.1.0.1
|-- libfoo.so.1.0.1
`-- tests
3 directories, 4 files
ruki@0d35ffa77272:/mnt/xmake/tests/projects/c++/shared_library_with_soname$ xmake
libfoo.so.1
[100%]: build ok, spent 0.311s
ruki@0d35ffa77272:/mnt/xmake/tests/projects/c++/shared_library_with_soname$ tree build/
build/
`-- linux
`-- x86_64
`-- release
|-- libfoo.so -> libfoo.so.1
|-- libfoo.so.1 -> libfoo.so.1.0.1
|-- libfoo.so.1.0.1
`-- tests
3 directories, 4 files
|
This is ok, but it cannot be reproduced. If the code is not changed and the targetfile is not updated, then after_link will not be executed. . ruki@0d35ffa77272:/mnt/xmake/tests/projects/c++/shared_library_with_soname$ tree build/
build/
`--linux
`-- x86_64
`-- release
|-- libfoo.so -> libfoo.so.1
|-- libfoo.so.1 -> libfoo.so.1.0.1
|-- libfoo.so.1.0.1
`--tests
3 directories, 4 files
ruki@0d35ffa77272:/mnt/xmake/tests/projects/c++/shared_library_with_soname$ xmake
libfoo.so.1
[100%]: build ok, spent 0.311s
ruki@0d35ffa77272:/mnt/xmake/tests/projects/c++/shared_library_with_soname$ tree build/
build/
`--linux
`-- x86_64
`-- release
|-- libfoo.so -> libfoo.so.1
|-- libfoo.so.1 -> libfoo.so.1.0.1
|-- libfoo.so.1.0.1
`--tests
3 directories, 4 files
|
提供个完整可复现的 demo 过来 |
Provide a complete and reproducible demo. |
xmake.lua: set_version("1.0.2", {soname = "1", build = "%Y%m%d"})
target("foo")
set_kind("shared")
add_files("src/*.c") src/main.c: #include <stdio.h>
void print()
{
printf("hello world!\n");
} 复现: ❯ xmake -r
[ 25%]: cache compiling.release src/main.c
[ 50%]: linking.release libfoo.so
[100%]: build ok, spent 0.076s
❯ tree build
build
└── linux
└── x86_64
└── release
├── libfoo.so -> libfoo.so.1
├── libfoo.so.1 -> libfoo.so.1.0.2
└── libfoo.so.1.0.2
3 directories, 3 files
❯ ls -lh build/linux/x86_64/release/
total 16K
lrwxrwxrwx 1 xuh xuh 11 Feb 6 17:01 libfoo.so -> libfoo.so.1
lrwxrwxrwx 1 xuh xuh 15 Feb 6 17:01 libfoo.so.1 -> libfoo.so.1.0.2
-rwxr-xr-x 1 xuh xuh 16K Feb 6 17:01 libfoo.so.1.0.2
❯ xmake
[100%]: build ok, spent 0.008s
❯ tree build
build
└── linux
└── x86_64
└── release
├── libfoo.so -> libfoo.so.1
├── libfoo.so.1 -> libfoo.so.1.0.2
└── libfoo.so.1.0.2
3 directories, 3 files
❯ ls -lh build/linux/x86_64/release/
total 0
lrwxrwxrwx 1 xuh xuh 11 Feb 6 17:02 libfoo.so -> libfoo.so.1
lrwxrwxrwx 1 xuh xuh 15 Feb 6 17:02 libfoo.so.1 -> libfoo.so.1.0.2
-rwxr-xr-x 1 xuh xuh 0 Feb 6 17:02 libfoo.so.1.0.2 之前表述不太准确,第二次执行xmake后,libfoo.so.1.0.2变为空文件 |
再试试 xmake update -s dev |
Try xmake update -s dev again |
更新后动态库被覆盖的问题已解决。但现在只修改xmake.lua中版本号,对应的库不会被更新。 复现: ❯ ls -lh build/linux/x86_64/release/
total 16K
lrwxrwxrwx 1 xuh xuh 11 Feb 6 23:38 libfoo.so -> libfoo.so.1
lrwxrwxrwx 1 xuh xuh 15 Feb 6 23:38 libfoo.so.1 -> libfoo.so.1.0.2
-rwxr-xr-x 1 xuh xuh 16K Feb 6 23:38 libfoo.so.1.0.2
❯ nvim xmake.lua
❯ cat xmake.lua
set_version("1.0.3", { soname = "1", build = "%Y%m%d" })
target("foo")
set_kind("shared")
add_files("src/*.c")
❯ xmake
[100%]: build ok, spent 0.164s
❯ ls -lh build/linux/x86_64/release/
total 16K
lrwxrwxrwx 1 xuh xuh 11 Feb 6 23:38 libfoo.so -> libfoo.so.1
lrwxrwxrwx 1 xuh xuh 15 Feb 6 23:38 libfoo.so.1 -> libfoo.so.1.0.2
-rwxr-xr-x 1 xuh xuh 16K Feb 6 23:38 libfoo.so.1.0.2 |
The problem of dynamic libraries being overwritten after the update has been solved. But now only the version number in xmake.lua is modified, and the corresponding library will not be updated. recurrent: ❯ ls -lh build/linux/x86_64/release/
total 16K
lrwxrwxrwx 1 xuh xuh 11 Feb 6 23:38 libfoo.so -> libfoo.so.1
lrwxrwxrwx 1 xuh xuh 15 Feb 6 23:38 libfoo.so.1 -> libfoo.so.1.0.2
-rwxr-xr-x 1 xuh xuh 16K Feb 6 23:38 libfoo.so.1.0.2
❯ nvimxmake.lua
❯ cat xmake.lua
set_version("1.0.3", { soname = "1", build = "%Y%m%d" })
target("foo")
set_kind("shared")
add_files("src/*.c")
❯ xmake
[100%]: build ok, spent 0.164s
❯ ls -lh build/linux/x86_64/release/
total 16K
lrwxrwxrwx 1 xuh xuh 11 Feb 6 23:38 libfoo.so -> libfoo.so.1
lrwxrwxrwx 1 xuh xuh 15 Feb 6 23:38 libfoo.so.1 -> libfoo.so.1.0.2
-rwxr-xr-x 1 xuh xuh 16K Feb 6 23:38 libfoo.so.1.0.2 |
再试试 |
try again |
没问题了。感谢。祝春节快乐。 |
No problem. grateful. Happy Chinese New Year. |
Xmake 版本
2.8.6
操作系统版本和架构
Ubuntu (Windows 11 WSL2)
描述问题
使用
set_version
设置版本号并设置soname=true
时,在未做修改的情况下多次调用xmake导致编译产物被删除。检查 soname 实现逻辑发现以下代码在
after_link
阶段被执行:上述代码执行完成后,targetfile被变为指向重命名后编译产物的软链接。重复调用xmake时,由于没有检测到修改,targetfile未被更新,再次执行上述逻辑,编译产物在targetfile重命名的过程中被覆盖。
期待的结果
多次调用xmake不更新targetfile
工程配置
附加信息和错误日志
无
The text was updated successfully, but these errors were encountered: