tezc / sc

Common libraries and data structures for C.
BSD 3-Clause "New" or "Revised" License
2.23k stars 239 forks source link

Zig CC cross-compilation support for Windows on Linux host. #128

Closed svladykin closed 8 months ago

svladykin commented 8 months ago

Was able to cross-compile everything on Linux for Windows with Zig. Some minor cleanup was needed.

It would be great to add a CI check for that. Here is the script:

export ZIG=zig-linux-x86_64-0.12.0-dev.1834+f36ac227b
rm -rf build && mkdir build && cd build
curl -o zig.tar.xz "https://ziglang.org/builds/$ZIG.tar.xz"
tar -xf zig.tar.xz
export CC="$(pwd)/$ZIG/zig cc -target x86_64-windows"
cmake -DCMAKE_SYSTEM_NAME=Windows ..
make
codecov[bot] commented 8 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (c729344) 99.81% compared to head (6d2af7e) 99.81%.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/tezc/sc/pull/128/graphs/tree.svg?width=650&height=150&src=pr&token=O8ZHQ0XZ30&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ozan+Tezcan)](https://app.codecov.io/gh/tezc/sc/pull/128?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ozan+Tezcan) ```diff @@ Coverage Diff @@ ## master #128 +/- ## ======================================= Coverage 99.81% 99.81% ======================================= Files 21 21 Lines 2195 2195 Branches 388 388 ======================================= Hits 2191 2191 Misses 1 1 Partials 3 3 ``` | [Files](https://app.codecov.io/gh/tezc/sc/pull/128?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ozan+Tezcan) | Coverage Δ | | |---|---|---| | [condition/sc\_cond.c](https://app.codecov.io/gh/tezc/sc/pull/128?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ozan+Tezcan#diff-Y29uZGl0aW9uL3NjX2NvbmQuYw==) | `100.00% <ø> (ø)` | | | [ini/sc\_ini.c](https://app.codecov.io/gh/tezc/sc/pull/128?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ozan+Tezcan#diff-aW5pL3NjX2luaS5j) | `100.00% <ø> (ø)` | | | [logger/sc\_log.c](https://app.codecov.io/gh/tezc/sc/pull/128?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ozan+Tezcan#diff-bG9nZ2VyL3NjX2xvZy5j) | `100.00% <ø> (ø)` | | | [memory-map/sc\_mmap.c](https://app.codecov.io/gh/tezc/sc/pull/128?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ozan+Tezcan#diff-bWVtb3J5LW1hcC9zY19tbWFwLmM=) | `100.00% <ø> (ø)` | | | [signal/sc\_signal.c](https://app.codecov.io/gh/tezc/sc/pull/128?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ozan+Tezcan#diff-c2lnbmFsL3NjX3NpZ25hbC5j) | `100.00% <ø> (ø)` | | | [thread/sc\_thread.c](https://app.codecov.io/gh/tezc/sc/pull/128?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ozan+Tezcan#diff-dGhyZWFkL3NjX3RocmVhZC5j) | `100.00% <ø> (ø)` | | | [uri/sc\_uri.c](https://app.codecov.io/gh/tezc/sc/pull/128?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ozan+Tezcan#diff-dXJpL3NjX3VyaS5j) | `100.00% <ø> (ø)` | | ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/tezc/sc/pull/128?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ozan+Tezcan). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ozan+Tezcan) > `Δ = absolute (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://app.codecov.io/gh/tezc/sc/pull/128?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ozan+Tezcan). Last update [c729344...6d2af7e](https://app.codecov.io/gh/tezc/sc/pull/128?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ozan+Tezcan). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Ozan+Tezcan).
tezc commented 8 months ago

To add it to CI, we should setup Linux for Windows first right? If you already know how to do it, you can add a job to windows.yml. Otherwise, let's handle it later.

svladykin commented 8 months ago

It actually can be executed on any Linux. Let me try to add it to .ubuntu.yml.

svladykin commented 8 months ago

Checked the build log for x64-ubuntu / Zig Windows, it works as expected.

tezc commented 8 months ago

thank you