Rust: Doesn't build object file
Xmake 版本
2.8.3
操作系统版本和架构
ArchLinux
描述问题
Just build an object file and then choose the linker or pass any custom rules later. Tried same test on other supported languages: C++, C, Zig and D. No such problem during the build.
期待的结果
I expected xmake to generate just a rust object file. Allow users to choose the linker!
工程配置
add_rules("mode.debug", "mode.release")
target("xmake_rs_demo")
set_kind("object")
add_files("src/main.rs")
附加信息和错误日志
build set_kind("object"):
xmake -vvD
checking for platform ... linux
checking for architecture ... x86_64
checking for gcc ... /usr/bin/gcc
checking for zig ... /home/kassane/zig/master/files/zig
checking for rustc ... /usr/bin/rustc
checking for the rust compiler (rc) ... rustc
checking for /usr/bin/rustc ... ok
checking for flags (-C opt-level=3) ... ok
> rustc "-C" "opt-level=3"
error: @programdir/modules/async/runjobs.lua:256: @programdir/rules/rust/build/target.lua:52: bad argument #1 to 'mtime' (string expected, got nil)
stack traceback:
[C]: in function 'mtime'
[@programdir/rules/rust/build/target.lua:52]: in function 'build_sourcefiles'
[@programdir/rules/rust/build/target.lua:83]:
[@programdir/actions/build/build.lua:52]: in function 'jobfunc'
[@programdir/modules/async/runjobs.lua:232]:
stack traceback:
[C]: in function 'error'
@programdir/core/base/os.lua:923: in function 'base/os.raiselevel'
(...tail calls...)
@programdir/modules/async/runjobs.lua:256: in field 'catch'
@programdir/core/sandbox/modules/try.lua:123: in global 'try'
@programdir/modules/async/runjobs.lua:218: in upvalue 'cotask'
@programdir/core/base/scheduler.lua:404: in function <@programdir/core/base/scheduler.lua:397>
I tried this a long time ago and failed, it's complicated and doesn't handle links well. rustc also doesn't provide any more interface parameters for me to do this.
Try rustc -C opt-level=3 --edition 2018 --emit=obj src/main.rs - output in $PWD - xmake need move object file
Please, allow choose rust edition, like c++ version! [edition: 2015|2018|2021] - TODO 2024
- https://github.com/rust-lang/rust/issues/117258
Try
rustc -C opt-level=3 --edition 2018 --emit=obj src/main.rs- output in$PWD- xmake need move object filePlease, allow choose rust edition, like c++ version! [edition: 2015|2018|2021] - TODO 2024
I know it, but I don't know how to link these objects with rust system libs, modules, packages. But rustc a.rs b.rs ... will do some automatically.
~~May I ask why by default xmake uses 2018 edition? I don't know how to change it, even though my config toml is using 2021.~~
nevermind I found it, but it seems not in the docs and pretty hard to figure out how to do it.