flang the compiler proves your program cannot hang 0.6.2 GitHub Русский

Installing

Latest release — 0.6.2 (release on GitHub).

PathWhat it installsNeeded on the machine
Homebrewflang, the library, the headers, man flangbrew, cc, make
asdfflang alongside other versionsasdf, cc, make
From sourceflang from a clonegit, cc, make
With npmflang and flang-lsp inside a Node projectNode ≥ 20, cc, make

All four give the SAME binary. Emitting to all nine targets, the checks, the proofs and the language server (flang lsp --stdio) are there on every path — pick by what the machine already has.

Homebrew

brew install digitable-lol/tap/flang

Installs flang, libcompiler_flang.a, two headers and the man flang page. Node is not needed: the release archive carries ready C99.

asdf

asdf plugin add flang https://github.com/digitable-lol/asdf-flang.git
asdf install flang 0.6.2
asdf set -u flang 0.6.2

Installs bin/flang, lib/libcompiler_flang.a and two headers into the version directory. The third line is asdf set, not asdf global: global and local were removed in asdf 0.16.0. The same plugin works with mise: mise plugin add flang https://github.com/digitable-lol/asdf-flang.git.

Does not work: the plugin is published in a separate repository and lags behind this tree, so asdf install flang 0.6.2 can end in a refusal — until it catches up, take Homebrew or the source.

From source

git clone https://github.com/digitable-lol/flang.git
cd flang
make -C bootstrap -j4
sudo make -C bootstrap install        # or PREFIX=$HOME/.local, without sudo

Lays down four files — bin/flang, lib/libcompiler_flang.a, include/flang_runtime.h, include/compiler_flang.h — and says where:

поставлено: /usr/local/bin/flang — проверьте: flang --version

The version is whatever the clone holds, not the latest release. There is no man page on this path: flang.1 ships only in the release archive.

If the machine has no make, one cc call is enough:

cd bootstrap
cc -std=c99 -Wall -Wextra -Werror -pedantic -O2 -o flang \
   flang_cli.c flang_repl.c flang_runtime.c compiler_flang.c -lm -lpthread

With npm

The path for one thing: putting flang inside a Node project next to its other tooling, and giving the editor the flang-lsp language server where it looks for it.

npm install git+https://github.com/digitable-lol/flang.git

Installs node_modules/.bin/flang and node_modules/.bin/flang-lsp. The package has no dependencies of its own, but cc and make are needed on the machine: on install it BUILDS the same binary out of the C99 it carries.

Does not work: npm install @digitable-lol/flang — nothing is published under that name on the registry, install from the git URL above.

Checking the install

Three commands. Answers like these mean flang is in place.

flang --version
flang 0.6.2

Put this in hello.flang:

module «Hello»
total function «Two»
  returns number
  2
flang check hello.flang
модуль «Hello»: функций 1, из них с доказанным завершением 1; типов 0
hello.flang: проверено — разбор, типы, завершаемость, ядро и примеры; замечаний нет

Exit code 0. A file that does not pass answers не проверено — замечаний N and exit code 1.

flang repl
flang 0.6.2 — оболочка. «.помощь» — команды, «.выход» или Ctrl-D — конец.
Объявление заканчивается пустой строкой, выражение вычисляется сразу.
» 2 plus 2
4

Ctrl-D leaves. If the shell answers вычислять нечем: не найден libcompiler_flang.a instead of 4, the binary is installed and the library is not: put libcompiler_flang.a next to the binary, or point FLANG_LIB_DIR at the directory holding it.

Removing

PathCommand
Homebrewbrew uninstall flang
asdfasdf uninstall flang 0.6.2, then asdf plugin remove flang
From sourcemake -C bootstrap uninstall — add the same PREFIX=… you installed with
npmnpm uninstall @digitable-lol/flang

make -C bootstrap uninstall removes bin/flang, the library and the man page, but LEAVES the two headers in include/ — delete them by hand if the prefix has to be empty.

Next