-
-
Notifications
You must be signed in to change notification settings - Fork 817
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
Zig Language #955
Comments
Because the support for zig is still in the experimental stage, there are still some problems, so I did not add the project template. The new version of zig seems to have solved some problems, so this version I will add them |
I have added console/static/shared project tempaltes for zig. But there are some problems caused by zig itself, you can look at related issues. ziglang/zig#5825 It may be necessary to wait for the official release of a new version of zig before xmake will go back and try to further support and fix it. |
Oh, new issues for zig 0.7.0 ziglang/zig#7045 and this issue ziglang/zig#5825 (comment) does not solved yet for zig 0.7.0 another issue ziglang/zig#7046 |
Oh, two new issues. I think the current version of zig is not very stable yet, and I plan to continue to support it after it becomes more stable. |
zig/master have fixed some of the problems I raised before, xmake is now able to compile zig projects on macOS/Linux well, although there are still many problems on windows (ziglang/zig#5825 ziglang/zig#7065 ziglang/zig#7066). And we can use $ xmake create -l zig console
$ cd console
$ xmake -v
[ 40%]: ccache compiling.release src/main.zig
zig build-obj -O ReleaseFast --cache-dir build/.objs/test/macosx/x86_64/release/zig-cache -femit-bin=build/.objs/test/macosx/x86_64/release/src/main.zig.o src/main.zig
[ 60%]: ccache compiling.release src/test.zig
zig build-obj -O ReleaseFast --cache-dir build/.objs/test/macosx/x86_64/release/zig-cache -femit-bin=build/.objs/test/macosx/x86_64/release/src/test.zig.o src/test.zig
[ 80%]: linking.release test
zig build-exe --strip -lz -femit-bin=build/macosx/x86_64/release/test build/.objs/test/macosx/x86_64/release/src/main.zig.o build/.objs/test/macosx/x86_64/release/src/test.zig.o
[100%]: build ok!
$ xmake run
Hello, world! And I also added an example to build zig project with c codes. see https://github.com/xmake-io/xmake/tree/dev/tests/projects/zig/console_c_call_zig |
@waruqi, cool! But you could also try using rust with zig. Like this project for example: |
Ok, I will try it. |
It was being discussed by the zig community, the use of the Unix-like$> export CC="zig cc $@"
$> export CXX="zig c++ $@"
...
# your build system
$> cmake or meson - commands Windows - (not tested yet)PS C:\Users\My-PC\project> $Env:CC="zig cc %*"
PS C:\Users\My-PC\project> cmake or meson - commands or Batch script: set PATH=zig_PATH;%PATH%
set ZIG_LOCAL_CACHE="%TEMP%"" && zig cc %* I tried the same using xmake and this happens: error: @programdir/core/main.lua:290: @programdir/actions/build/main.lua:147:
...mdir/core/sandbox/modules/import/core/base/scheduler.lua:87:
...mdir/core/sandbox/modules/import/core/base/scheduler.lua:47:
@programdir/modules/private/async/runjobs.lua:217:
...amdir/core/sandbox/modules/import/core/tool/compiler.lua:37: cannot find known tool script for zig c++
stack traceback:
[C]: in function 'error'
[@programdir/core/base/os.lua:787]: in function 'raise'
[...amdir/core/sandbox/modules/import/core/tool/compiler.lua:37]: in function 'load'
[@programdir/modules/private/action/build/object.lua:39]: in function 'script'
[@programdir/modules/private/action/build/object.lua:91]: in function '_build_object'
[@programdir/modules/private/action/build/object.lua:116]: in function 'jobfunc'
[@programdir/modules/private/async/runjobs.lua:193]:
[C]: in function 'trycall'
[@programdir/core/sandbox/modules/try.lua:121]: in function 'try'
[@programdir/modules/private/async/runjobs.lua:186]: in function 'cotask'
[@programdir/core/base/scheduler.lua:317]:
stack traceback:
[C]: in function 'error'
@programdir/core/base/os.lua:787: in function 'raise'
@programdir/modules/private/async/runjobs.lua:217: in function 'catch'
@programdir/core/sandbox/modules/try.lua:127: in function 'try'
@programdir/modules/private/async/runjobs.lua:186: in function 'cotask'
@programdir/core/base/scheduler.lua:317: in function <@programdir/core/base/scheduler.lua:315>
stack traceback:
[C]: in function 'error'
@programdir/core/base/os.lua:787: in function 'raise'
...mdir/core/sandbox/modules/import/core/base/scheduler.lua:47: in function 'co_start_named'
@programdir/modules/private/async/runjobs.lua:184: in function <@programdir/modules/private/async/runjobs.lua:144>
[C]: in function 'trycall'
@programdir/core/base/scheduler.lua:423: in function 'co_group_begin'
...mdir/core/sandbox/modules/import/core/base/scheduler.lua:85: in function 'co_group_begin'
@programdir/modules/private/async/runjobs.lua:144: in function 'runjobs'
@programdir/actions/build/build.lua:223: in function 'build'
@programdir/actions/build/main.lua:134: in function <@programdir/actions/build/main.lua:124>
[C]: in function 'trycall'
@programdir/core/sandbox/modules/try.lua:121: in function 'try'
@programdir/actions/build/main.lua:123: in function <@programdir/actions/build/main.lua:97>
[C]: in function 'load'
@programdir/core/base/task.lua:519: in function 'run'
@programdir/core/main.lua:288: in function 'cotask'
@programdir/core/base/scheduler.lua:317: in function <@programdir/core/base/scheduler.lua:315>
stack traceback:
[C]: in function 'error'
@programdir/core/base/os.lua:787: in function 'raise'
@programdir/core/main.lua:290: in function 'cotask'
@programdir/core/base/scheduler.lua:317: in function <@programdir/core/base/scheduler.lua:315> |
Currently, it is not supported to switch to zig cc compiler via $CC, but you can enable it with the following command.
|
I have supported to use export CC="zig cc"
export LD="zig c++"
xmake or xmake f --cc="zig cc" --ld="zig c++" -c
xmake |
I just tested this command but there is still an error.
and also
Output: checking for platform ... linux
checking for architecture ... x86_64
checking for gcc ... /usr/bin/gcc
checking for the c++ compiler (cxx) ... gcc
checking for /usr/bin/gcc ... ok
checking for flags (-fvisibility-inlines-hidden) ... ok
> gcc "-fvisibility-inlines-hidden"
checking for flags (-O3) ... ok
> gcc "-O3"
checking for flags (-DNDEBUG) ... ok
> gcc "-DNDEBUG"
checking for zig ... /home/kassane/.local/bin/zig
checking for the zig linker (zcld) ... zig
[ 50%]: linking.release xmake_test
/home/kassane/.local/bin/zig build-exe -target x86_64-linux-gnu --strip -femit-bin=build/linux/x86_64/release/xmake_test build/.objs/xmake_test/linux/x86_64/release/src/main.cpp.o
error: @programdir/modules/private/async/runjobs.lua:217: @programdir/actions/build/kinds/binary.lua:73: @programdir/core/sandbox/modules/os.lua:258: ld.lld: error: undefined symbol: std::cout
>>> referenced by main.cpp
>>> build/.objs/xmake_test/linux/x86_64/release/src/main.cpp.o:(main)
>>> referenced by main.cpp
>>> build/.objs/xmake_test/linux/x86_64/release/src/main.cpp.o:(main)
>>> referenced by main.cpp
>>> build/.objs/xmake_test/linux/x86_64/release/src/main.cpp.o:(main)
>>> referenced 1 more times
ld.lld: error: undefined symbol: std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)
>>> referenced by main.cpp
>>> build/.objs/xmake_test/linux/x86_64/release/src/main.cpp.o:(main)
ld.lld: error: undefined symbol: std::ostream::put(char)
>>> referenced by main.cpp
>>> build/.objs/xmake_test/linux/x86_64/release/src/main.cpp.o:(main)
ld.lld: error: undefined symbol: std::ostream::flush()
>>> referenced by main.cpp
>>> build/.objs/xmake_test/linux/x86_64/release/src/main.cpp.o:(main)
ld.lld: error: undefined symbol: std::ctype<char>::_M_widen_init() const
>>> referenced by main.cpp
>>> build/.objs/xmake_test/linux/x86_64/release/src/main.cpp.o:(main)
ld.lld: error: undefined symbol: std::__throw_bad_cast()
>>> referenced by main.cpp
>>> build/.objs/xmake_test/linux/x86_64/release/src/main.cpp.o:(main)
ld.lld: error: undefined symbol: std::ios_base::Init::Init()
>>> referenced by main.cpp
>>> build/.objs/xmake_test/linux/x86_64/release/src/main.cpp.o:(_GLOBAL__sub_I_main)
ld.lld: error: undefined symbol: std::ios_base::Init::~Init()
>>> referenced by main.cpp
>>> build/.objs/xmake_test/linux/x86_64/release/src/main.cpp.o:(_GLOBAL__sub_I_main)
ld.lld: error: undefined symbol: __cxa_atexit
>>> referenced by main.cpp
>>> build/.objs/xmake_test/linux/x86_64/release/src/main.cpp.o:(_GLOBAL__sub_I_main)
error: LLDReportedFailure
stack traceback:
[C]: in function 'error'
[@programdir/core/base/os.lua:787]: in function 'raise'
[@programdir/core/sandbox/modules/os.lua:258]: in function 'runv'
[@programdir/modules/core/tools/zig.lua:125]:
[C]: in function 'link'
[@programdir/actions/build/kinds/binary.lua:73]: in function 'callback'
[@programdir/modules/core/project/depend.lua:186]: in function 'on_changed'
[@programdir/actions/build/kinds/binary.lua:54]: in function '_do_link_target'
[@programdir/actions/build/kinds/binary.lua:94]:
[@programdir/actions/build/kinds/binary.lua:115]: in function '_link_target'
[@programdir/actions/build/kinds/binary.lua:137]: in function 'jobfunc'
[@programdir/modules/private/async/runjobs.lua:193]:
[C]: in function 'trycall'
[@programdir/core/sandbox/modules/try.lua:121]: in function 'try'
[@programdir/modules/private/async/runjobs.lua:186]: in function 'cotask'
[@programdir/core/base/scheduler.lua:317]:
stack traceback:
[C]: in function 'error'
@programdir/core/base/os.lua:787: in function 'raise'
@programdir/modules/private/async/runjobs.lua:217: in function 'catch'
@programdir/core/sandbox/modules/try.lua:127: in function 'try'
@programdir/modules/private/async/runjobs.lua:186: in function 'cotask'
@programdir/core/base/scheduler.lua:317: in function <@programdir/core/base/scheduler.lua:315> Works: $> xmake f --cc="gcc@zig cc" --cxx="g++@zig c++" --ld="g++@zig c++" -c;xmake Output: checking for platform ... linux
checking for architecture ... x86_64
checking for zig c++ ... ok
checking for flags (-fvisibility-inlines-hidden) ... ok
checking for flags (-O3) ... ok
checking for flags (-DNDEBUG) ... ok
checking for ccache ... /usr/bin/ccache
[ 25%]: ccache compiling.release src/main.cpp
/usr/bin/ccache zig c++ -c -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -o build/.objs/xmake_test/linux/x86_64/release/src/main.cpp.o src/main.cpp
checking for flags (-MMD -MF) ... ok
checking for flags (-fdiagnostics-color=always) ... ok
[ 50%]: linking.release xmake_test
"zig c++" -o build/linux/x86_64/release/xmake_test build/.objs/xmake_test/linux/x86_64/release/src/main.cpp.o -m64 -s
[100%]: build ok! |
yeah, you need pass It works for me. $ xmake f --cc="zig cc" --cxx="zig c++" --ld="zig c++" -c --ccache=n
checking for platform ... linux
checking for architecture ... x86_64
$ xmake -rv
checking for zig c++ ... ok
checking for flags (-fvisibility-inlines-hidden) ... ok
checking for flags (-O3) ... ok
checking for flags (-DNDEBUG) ... ok
[ 25%]: compiling.release src/main.cpp
"zig c++" -c -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -o build/.objs/test/linux/x86_64/release/src/main.cpp.o src/main.cpp
checking for flags (-MMD -MF) ... ok
checking for flags (-fdiagnostics-color=always) ... ok
[ 50%]: linking.release test
"zig c++" -o build/linux/x86_64/release/test build/.objs/test/linux/x86_64/release/src/main.cpp.o -m64 -s
[100%]: build ok! |
Windows - MinGWNote: You will have to specify the target xmake f -p mingw --cc="gcc@zig cc -target x86_64-windows-gnu" --cxx="g++@zig c++ -target x86_64-windows-gnu" --ld="g++@zig c++ -target x86_64-windows-gnu" -c --ccache=n
xmake -rv It does not work in v2.5.1 with Output: checking for architecture ... x86_64
checking for mingw directory ... C:\Users\Catarino\scoop\apps\msys2\2020-07-20\mingw64
checking for zig c++ -target x86_64-windows-gnu ... ok
checking for flags (-fvisibility-inlines-hidden) ... ok
checking for flags (-O3) ... ok
checking for flags (-DNDEBUG) ... ok
[ 25%]: compiling.release src\main.cpp
"zig c++ -target x86_64-windows-gnu" -c -Qunused-arguments -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -o build\.objs\test\mingw\x86_64\release\src\main.cpp.obj src\main.cpp
checking for flags (-MMD -MF) ... ok
[ 50%]: linking.release test.exe
"zig c++ -target x86_64-windows-gnu" -o build\mingw\x86_64\release\test.exe build\.objs\test\mingw\x86_64\release\src\main.cpp.obj -m64 -s
[100%]: build ok! |
I have improved it, try it again on dev branch. |
xmake f -p mingw --cc="zig cc" --cxx="zig c++" --ld="zig c++" -c --ccache=n
xmake -rv Output: checking for architecture ... x86_64
checking for mingw directory ... C:\Users\Catarino\scoop\apps\msys2\2020-07-20\mingw64
checking for zig c++ ... no
[ 25%]: compiling.release src\main.cpp
"zig c++" -c -target x86_64-windows-gnu -m64 -fvisibility=hidden -o build\.objs\test\mingw\x86_64\release\src\main.cpp.obj src\main.cpp
[ 50%]: linking.release test.exe
"zig c++" -o build\mingw\x86_64\release\test.exe build\.objs\test\mingw\x86_64\release\src\main.cpp.obj -target x86_64-windows-gnu -m64 -s
[100%]: build ok!
warning: add_cxflags("-DNDEBUG") is ignored, please pass `{force = true}` or call `set_policy("check.auto_ignore_flags", false)` if you want to set it. |
You can update to dev branch and try |
Well done! I tested it in both Windows and Linux environments.You have tried to compile on your machine, you no longer need to test on Windows exclusively! Output: checking for zig c++ --target=x86_64-windows-gnu ... ok
checking for the linker (ld) ... zig c++ --target=x86_64-windows-gnu
checking for the c++ compiler (cxx) ... zig c++ --target=x86_64-windows-gnu
checking for zig c++ --target=x86_64-windows-gnu ... ok
checking for flags (-fvisibility-inlines-hidden) ... ok
checking for flags (-O3) ... ok
checking for flags (-DNDEBUG) ... ok
[ 25%]: compiling.release src/main.cpp
"zig c++ --target=x86_64-windows-gnu" -c -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -o build/.objs/xmake_test/mingw/x86_64/release/src/main.cpp.obj src/main.cpp
checking for flags (-MMD -MF) ... ok
checking for flags (-fdiagnostics-color=always) ... ok
[ 50%]: linking.release xmake_test.exe
"zig c++ --target=x86_64-windows-gnu" -o build/mingw/x86_64/release/xmake_test.exe build/.objs/xmake_test/mingw/x86_64/release/src/main.cpp.obj -m64 -s
[100%]: build ok! I believe that with zig, we won't need to use other external kits like mingw or mxe to compile from any platform to another. |
error: error: unknown target CPU 'generic' |
@waruqi , My suggestion:xmake/xmake/modules/core/tools/zig_cc.lua Lines 30 to 41 in 80e2428
Change to: if not self:program():find("target", 1, true) then
local march
if is_plat("macosx") then
if is_arch("x86" or "x86_64") then
march = is_arch("x86") and "i386-macos-gnu" or "x86_64-macos-gnu"
else
march = is_arch("arm64") and "aarch64-macos-gnu"
end
elseif is_plat("linux") then
if is_arch("x86" or "x86_64") then
march = is_arch("x86") and "i386-linux-gnu" or "x86_64-linux-gnu"
elseif is_arch("arm" or "arm64") then
march = is_arch("arm64") and "aarch64-linux-gnu" or "arm-linux-gnu"
end
elseif is_plat("windows") then
march = is_arch("x86") and "i386-windows-msvc" or "x86_64-windows-msvc"
elseif is_plat("mingw") then
march = is_arch("x86") and "i386-windows-gnu" or "x86_64-windows-gnu"
end TestMacOSXCommand: xmake f -p macosx --toolchain=zig -c --ccache=n
xmake -rv Output: checking for architecture ... x86_64
checking for Xcode directory ... %s
checking for Codesign Identity of Xcode ... no
checking for SDK version of Xcode for macosx (x86_64) ... nil
checking for Minimal target version of Xcode for macosx (x86_64) ... nil
checking for zig c++ ... ok
checking for the linker (ld) ... zig c++
checking for zig cc ... ok
checking for the c compiler (cc) ... zig cc
checking for zig cc ... ok
checking for flags (-O3) ... ok
checking for flags (-DNDEBUG) ... ok
[ 25%]: compiling.release src/main.c
"zig cc" -c -arch x86_64 -fvisibility=hidden -O3 -DNDEBUG -o build/.objs/xmake_test/macosx/x86_64/release/src/main.c.o src/main.c
checking for flags (-MMD -MF) ... ok
checking for flags (-fdiagnostics-color=always) ... ok
[ 50%]: linking.release xmake_test
"zig c++" -o build/macosx/x86_64/release/xmake_test build/.objs/xmake_test/macosx/x86_64/release/src/main.c.o -arch x86_64 -stdlib=libc++ -Wl,-x -lz
[100%]: build ok! MacOSX - ARM64Command: xmake f -p macosx -a arm64 --toolchain=zig -c --ccache=n
xmake -rv Output: checking for Xcode directory ... %s
checking for Codesign Identity of Xcode ... no
checking for SDK version of Xcode for macosx (arm64) ... nil
checking for Minimal target version of Xcode for macosx (arm64) ... nil
checking for zig c++ ... ok
checking for the linker (ld) ... zig c++
checking for zig cc ... ok
checking for the c compiler (cc) ... zig cc
checking for zig cc ... ok
checking for flags (-O3) ... ok
checking for flags (-DNDEBUG) ... ok
[ 25%]: compiling.release src/main.c
"zig cc" -c -target aarch64-macos-gnu -arch arm64 -fvisibility=hidden -O3 -DNDEBUG -o build/.objs/xmake_test/macosx/arm64/release/src/main.c.o src/main.c
checking for flags (-MMD -MF) ... ok
checking for flags (-fdiagnostics-color=always) ... ok
[ 50%]: linking.release xmake_test
"zig c++" -o build/macosx/arm64/release/xmake_test build/.objs/xmake_test/macosx/arm64/release/src/main.c.o -target aarch64-macos-gnu -arch arm64 -stdlib=libc++ -Wl,-x -lz
[100%]: build ok! |
I have added it.
error: error: unknown target CPU 'generic' |
Which version of the zig? You have already tried it manually? zig cc src/main.c -target aarch64-macos-gnu
# or
zig cc src/main.c -target x86_64-macos-gnu I think the problem involves lld in the macosx exclusively. Project under development: |
I have improved it, you can try it again xmake f --toolchain=zig -a arm64 -c
xmake |
Well done! Linux ARM64 checking for platform ... linux
checking for zig c++ ... ok
checking for the linker (ld) ... zig c++
checking for zig cc ... ok
checking for the c compiler (cc) ... zig cc
checking for zig cc ... ok
checking for flags (-O3) ... ok
checking for flags (-DNDEBUG) ... ok
[ 25%]: compiling.release src/main.c
"zig cc" -c -target aarch64-linux-gnu -fvisibility=hidden -O3 -DNDEBUG -o build/.objs/xmake_test/linux/arm64/release/src/main.c.o src/main.c
checking for flags (-MMD -MF) ... ok
checking for flags (-fdiagnostics-color=always) ... ok
[ 50%]: linking.release xmake_test
"zig c++" -o build/linux/arm64/release/xmake_test build/.objs/xmake_test/linux/arm64/release/src/main.c.o -target aarch64-linux-gnu -s
[100%]: build ok! MacOSX - ARM64 checking for zig c++ ... ok
checking for the linker (ld) ... zig c++
checking for zig cc ... ok
checking for the c compiler (cc) ... zig cc
checking for zig cc ... ok
checking for flags (-O3) ... ok
checking for flags (-DNDEBUG) ... ok
[ 25%]: compiling.release src/main.c
"zig cc" -c -target aarch64-macos-gnu -fvisibility=hidden -O3 -DNDEBUG -o build/.objs/xmake_test/macosx/arm64/release/src/main.c.o src/main.c
checking for flags (-MMD -MF) ... ok
checking for flags (-fdiagnostics-color=always) ... ok
[ 50%]: linking.release xmake_test
"zig c++" -o build/macosx/arm64/release/xmake_test build/.objs/xmake_test/macosx/arm64/release/src/main.c.o -target aarch64-macos-gnu -Wl,-x
[100%]: build ok! Can you add more platforms for testing? zig targets | jq .libc Output: [
"aarch64_be-linux-gnu",
"aarch64_be-linux-musl",
"aarch64_be-windows-gnu",
"aarch64-linux-gnu",
"aarch64-linux-musl",
"aarch64-windows-gnu",
"aarch64-macos-gnu",
"armeb-linux-gnueabi",
"armeb-linux-gnueabihf",
"armeb-linux-musleabi",
"armeb-linux-musleabihf",
"armeb-windows-gnu",
"arm-linux-gnueabi",
"arm-linux-gnueabihf",
"arm-linux-musleabi",
"arm-linux-musleabihf",
"arm-windows-gnu",
"i386-linux-gnu",
"i386-linux-musl",
"i386-windows-gnu",
"mips64el-linux-gnuabi64",
"mips64el-linux-gnuabin32",
"mips64el-linux-musl",
"mips64-linux-gnuabi64",
"mips64-linux-gnuabin32",
"mips64-linux-musl",
"mipsel-linux-gnu",
"mipsel-linux-musl",
"mips-linux-gnu",
"mips-linux-musl",
"powerpc64le-linux-gnu",
"powerpc64le-linux-musl",
"powerpc64-linux-gnu",
"powerpc64-linux-musl",
"powerpc-linux-gnu",
"powerpc-linux-musl",
"riscv64-linux-gnu",
"riscv64-linux-musl",
"s390x-linux-gnu",
"s390x-linux-musl",
"sparc-linux-gnu",
"sparcv9-linux-gnu",
"wasm32-freestanding-musl",
"x86_64-linux-gnu",
"x86_64-linux-gnux32",
"x86_64-linux-musl",
"x86_64-windows-gnu",
"x86_64-macos-gnu"
] Is it plausible to add QEMU support to run other architecture/platform applications? |
xmake f -p linux -a [mips|mips64| riscv64|ppc|ppc64|s390x ...] --toolchain=zig --ccache=n
xmake or xmake f -p cross --cross=riscv64-linux-musl --toolchain=zig --ccache=n
xmake on dev |
I did some tests on several platforms/architectures both of the mentioned commands work perfectly. However, the fact that the zig compiler is unstable, currently in some occur some errors on the part of the compiler. Like for example: |
This just needs to wait for zig to improve them, xmake does not need to care about these |
@waruqi , nice work again! |
If there are no other problem about zig, I am going to close this issue. It should work for zig. |
Hi, does https://dev.to/kristoff/zig-makes-go-cross-compilation-just-work-29ho |
Not yet supported |
Hi @DrSensor, as @waruqi already informed xmake there is no cgo support. But already in the next release version or currently in development version it already allows us to interoperate with rust projects. See example set_xmakever("2.5.2") -- (current: latest dev branch) Zig toolchain support
add_rules("mode.debug", "mode.release")
target("math_rust")
set_kind("static")
add_files("math_ffi/rust/src/lib.rs")
after_build(function (target) -- rename rlib to ...
local prefix
if is_plat("windows") then prefix = ".lib"
else prefix=".a"
end
os.mv(target:targetfile(), path.join(path.directory(target:targetfile()), path.basename(target:targetfile()) .. prefix))
end)
set_toolchains("rust")
target("math_zig")
set_kind("static")
add_files("math_ffi/zig/src/main.zig")
add_zcflags("-fPIC", "--single-threaded", "--strip", {force = true})
set_toolchains("zig")
target("rust_app")
set_kind("binary")
add_files("app_rs/src/*.rs")
add_deps("math_zig")
add_linkdirs("$(buildir)")
set_toolchains("rust")
target("zig_app")
set_kind("binary")
add_files("app_zig/src/main.zig")
add_deps("math_rust")
set_toolchains("zig") If you are interested in this, you can see some examples here. |
Does that mean it will leverage https://kristoff.it/blog/zig-new-relationship-llvm/#in-place-binary-patching |
Any questions regarding the zig should be handled by their community. [target.x86_64-unknown-linux-musl]
linker="zig cc --target x86_64-linux-musl"
ar="zig cc --target x86_64-linux-musl"
[target.x86_64-pc-windows-gnu]
linker="zig cc --target x86_64-windows-gnu"
ar="zig cc --target x86_64-windows-gnu" XMake does not promise to be a replacement for cargo and does not offer crates support. Although the focus of the project is C/C++. But the Zig toolchain support will allow not only access to projects written in ziglang but also C/C++ projects as an alternative to traditional compilers, although the zig compiler itself is a clang compiler fork. In the example shown by me earlier, it demonstrates that we will be able to develop different toolchain projects simultaneously through interoperability between languages. I know that many Rust programmers think this kind of project is ridiculous, but they forget that both have the same backend called LLVM and precisely because of this they are binary compatible. |
I can't create an automatic zig project that only works manually.
Command:
xmake create -l zig test
Error output
Please provide compiling and running environment information:
The text was updated successfully, but these errors were encountered: