Zig/ja

Zig は、Article description::堅牢で、最適化された、再利用可能なソフトウェアを保守するための、汎用プログラミング言語およびツールチェーンです. Zig は より良い言語として C を置き換えることを目的としており、C の関数を FFI 無しで利用したりエクスポートすることができ 、C および C++ で書かれたコードを libclang を使用してコンパイルすることもできます. 上流は、libclang 無しでこれらの関数を利用できるように、独自の C コンパイラにも取り組んでいます.

前提条件
Zig supports at least Linux kernel 3.16+. If building from source, it must be built with same compiler as LLVM/Clang, or the user will get in trouble (see relevant section in below).

emerge
Packages are currently not stabilized on any arch and keyworded as testing on a small subset of arches, so the user need to testing (, replace with the system's arch) keyword for the latter:

そして、パッケージを emerge してください:

ZIG_MCPU と ZIG_TARGET
To adjust for which target and CPU will be built for, there are variables ZIG_MCPU and ZIG_TARGET (that will be passed as   and   arguments to :

デフォルトスロットを設定する
The command can be used to manipulate a /usr/bin/zig symlink.

環境変数
Command args have higher precedence over the following environment variables:


 * ZIG_GLOBAL_CACHE_DIR - path to the directory where things that are shared between different compilations are cached
 * ZIG_LOCAL_CACHE_DIR - path to the directory where the current compilation is cached, by default next to build.zig
 * ZIG_LIB_DIR - path to Zig standard library

一般的な使い方
Most commands grouped together, like ast-check to translate-c, have the same command options.

In the second group, it is highly recommended to use -fstrip to reduce the executable size except for debugging purposes.

Build modes
Zig has 4 "build modes" (or "optimize modes" in recent versions):

LSP サポート
Unofficial language server is available as  in. For installing follow guide to enable GURU repository,  and run:

テキストエディタサポート
See this list of tools from upstream. Currently none of them are packaged.

フリースタンディング
User might want to take a look at posts Using Zig to build a bare metal RISCV32 binary and Build an IoT App with Zig and LoRaWAN.

emerge 中の "undefined reference to ..."
The most possible reason is that the LLVM and Clang packages were built with other C++ compiler than Zig. Ensure that the user set the same compiler and emerge again.

warning: Encountered error: UnexpectedEndOfFile, falling back to default ABI and dynamic linker.
Zig compiler relies on the presence of for choosing  when targeting host machine. It checks whether contains actual ELF file or is a symlink/shebang to another executable, and retries this operation recursively until found. Then, it tries to extract information about libc from this ELF file. If this message occurs, it means that Zig failed to detect it properly, and will choose default libc and ABI instead (e.g. musl on Linux). The workaround is by using the following args to the command:

または:

Where  is the desired target, such as   or. For more information about target format see section.

外部資料

 * Official list of the community spaces
 * Official list of community projects and awesome-zig list
 * Ziglings — learn Zig by fixing tiny broken programs, inspired by Rustlings
 * Differences between and