User:Gso321/Zig
Zig is a general-purpose programming language and toolchain for maintaining robust, optimal and reusable software. Zig aims to replace C as the better language while being able to compile both C and C++.
dev-lang/zig and dev-lang/zig-bin are Zig's packages. dev-lang/zig is complied from source while dev-lang/zig-bin is a binary (no compiling). The rest of this article assumes the user is using dev-lang/zig (dev-lang/zig-bin may be replaced with dev-lang/zig-bin if the user uses it instead).
Installation
Kernel
Zig supports at least Linux kernel 3.16+.[2]
USE flags
USE flags for dev-lang/zig A robust, optimal, and maintainable programming language
USE flags for dev-lang/zig-bin A robust, optimal, and maintainable programming language
Emerge
Zig is currently unstable. To learn why unstable is bad experience, see this.
When compiling, Zig may use around 9.6 GiB RAM prior to 0.11.0.[3]
Change dev-lang/zig ACCEPT_KEYWORDS:
root #
echo "dev-lang/zig ~amd64" >> /etc/portage/package.accept_keywords
Then compile the package:
root #
emerge --ask -q dev-lang/zig
Configuration
Compiling most packages with Zig results in build errors or runtime errors!!!
Setting custom-cflags useflag is NOT supported by upstream.
zig cc and zig c++ uses clang for now.
The system may be configured to compile selected packages other than gcc, clang, or other C/C++ compilers using zig. Some packages, like sys-devel/gcc requires setting custom-cflags:
/etc/portage/profile/package.use.force
sys-devel/gcc custom-cflags
Basic example
/etc/portage/env/complier-zig
CC="zig cc" CXX="zig c++" AR="zig ar" # zig nm doesn't exist RANLIB="zig ranlib" COMMON_FLAGS="-O2 -march=native -pipe" CFLAGS="${COMMON_FLAGS}" CXXFLAGS="${COMMON_FLAGS}"
Then modify the file to the system's needs:
/etc/portage/package.env
Using the Zig compiler for app-foo/bar and app-bar/bazapp-foo/bar compiler-zig app-bar/baz compiler-zig
Usage
zig cc and zig c++ are Zig's C and C++ compiler respectively.
References
- ↑ Zig's license, retrieved on January 27, 2023
- ↑ Linux Kernel Version Support, retrieved on January 26, 2023.
- ↑ 0.10.0 Release Notes, retrieved on January 26, 2023.