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

[Bug]: target:set('kind', 'static') specified in on_config will compile but not link library specified as dependency #4982

Closed
EnergoStalin opened this issue Apr 16, 2024 · 4 comments
Labels

Comments

@EnergoStalin
Copy link

EnergoStalin commented Apr 16, 2024

Xmake 版本

xmake v2.8.9+HEAD.cb1b650

操作系统版本和架构

Linux energostalinpc 6.8.5-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 11 Apr 2024 01:47:33 +0000 x86_64 GNU/Linux

描述问题

Since it seems to somehow allow building library i expect it to link it as well. Setting it inside on_load it works fine.

Honestly looks like design limitation but then i wonder what's the point in allowing building static library without being able to link it?

The main concern however is whether it possible to include kind into rule package or not.

期待的结果

Link to target.

工程配置

https://github.com/EnergoStalin/xmake-kind-bug

附加信息和错误日志

Log
xmake build -v test
checking for gcc ... /usr/bin/gcc
checking for zig ... no
checking for zig ... no
checking for nim ... no
checking for nim ... no
checking for gcc ... /usr/bin/gcc
checking for the c compiler (cc) ... gcc
checking for /usr/bin/gcc ... ok
checking for flags (-fPIC) ... ok
[ 50%]: cache compiling.release dep.c
/usr/bin/gcc -c -m64 -I. -o build/.objs/lib/linux/x86_64/release/dep.c.o dep.c
checking for flags (-MMD -MF) ... ok
checking for flags (-fdiagnostics-color=always) ... ok
checking for the c compiler (cc) ... gcc
[ 50%]: cache compiling.release main.c
/usr/bin/gcc -c -m64 -I. -o build/.objs/test/linux/x86_64/release/main.c.o main.c
checking for ar ... /usr/bin/ar
checking for the static library archiver (ar) ... ar
[ 62%]: archiving.release liblib.a
/usr/bin/ar -cr build/linux/x86_64/release/liblib.a build/.objs/lib/linux/x86_64/release/dep.c.o
checking for g++ ... /usr/bin/g++
checking for the linker (ld) ... g++
checking for /usr/bin/g++ ... ok
checking for flags (-fPIC) ... ok
[ 87%]: linking.release test
/usr/bin/g++ -o build/linux/x86_64/release/test build/.objs/test/linux/x86_64/release/main.c.o -m64
/usr/bin/ld: build/.objs/test/linux/x86_64/release/main.c.o: in function `main':
main.c:(.text+0xe): undefined reference to `fun'
collect2: error: ld returned 1 exit status
error: execv(/usr/bin/g++ -o build/linux/x86_64/release/test build/.objs/test/linux/x86_64/release/main.c.o -m64) failed(1)
@waruqi
Copy link
Member

waruqi commented Apr 16, 2024

set kind 不要放到 on_config ,因为 deps target 的 link 继承目前也是在 on_config 阶段处理的,你 set kind 设置过于后面,就没法继承到 dep link 了。

这个只能在 on_load 阶段处理

@Issues-translate-bot
Copy link

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


Do not put set kind in on_config, because the link inheritance of deps target is currently processed in the on_config stage. If you set set kind too late, you will not be able to inherit the dep link.

This can only be processed in the on_load phase

@EnergoStalin
Copy link
Author

EnergoStalin commented Apr 16, 2024

Just as i thought design limitation. Well it's a bit unsettling not being able to define kind in package rules maybe i just completely misunderstanding rules initial purpose when trying to use it as target templates which probably better to do other way.

Will be any warning given when trying to set it in on_config stage and/or package rules?

@waruqi
Copy link
Member

waruqi commented Apr 17, 2024

no warning.

@waruqi waruqi closed this as completed Apr 18, 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