Build zig-rpc-server for i686

cargo-zigbuild is replaced with a simple zig-cc wrapper.
cargo-zigbuild still tries to use i386-linux-musl triple,
while in zig 0.11 x86-linux-musl should be used [1].

This also gives us more control over compilation flags used
and prevents changes due to cargo-zigbuild upgrades,
as its version was not pinned.

[1] Merged PR "all: rename i386 to x86 "
    <https://github.com/ziglang/zig/pull/13101>
This commit is contained in:
link2xt
2023-03-29 09:59:59 +00:00
parent 5068648960
commit 3400f5641e
3 changed files with 76 additions and 8 deletions

32
scripts/zig-cc Executable file
View File

@@ -0,0 +1,32 @@
#!/usr/bin/env python
import subprocess
import sys
import os
def flag_filter(flag: str) -> bool:
if flag == "-lc":
return False
if flag == "-Wl,-melf_i386":
return False
if "self-contained" in flag and "crt" in flag:
return False
return True
def main():
args = [flag for flag in sys.argv[1:] if flag_filter(flag)]
zig_target = os.environ["ZIG_TARGET"]
zig_cpu = os.environ.get("ZIG_CPU")
if zig_cpu:
zig_cpu_args = ["-mcpu=" + zig_cpu]
args = [x for x in args if not x.startswith("-march")]
else:
zig_cpu_args = []
subprocess.run(
["zig", "cc", "-target", zig_target, *zig_cpu_args, *args], check=True
)
main()