Building & Installation

Instructions for building and installing the slang library and tools.

Getting the Source

All source code is hosted on GitHub

Dependencies

slang requires the following dependencies in order to build:

Quick Start

Instructions on quickly getting a build going for common platforms.

Linux

On many common systems, a modern C++ compiler is not configured as the default. This assumes you've installed GCC 9 and that it's available on your path, and that you want a release build that will be installed to /usr/local/bin.

mkdir build && cd build
cmake -DCMAKE_CXX_COMPILER=g++-9 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/bin ..
make -j8

Tests are built by default. You can run them via ctest:

ctest

Or run the unit tests directly:

bin/unittests

Installation:

make install

Windows

VisualStudio 2019 has built-in support for cmake; simply open the slang root folder and press build.

Build Options

Besides the built-in cmake options, there are slang-specific options that may be set to customize the build:

OptionDescriptionDefault
SLANG_INCLUDE_TESTSInclude tests in the buildON
SLANG_INCLUDE_DOCSInclude docs in the buildOFF
SLANG_INCLUDE_LLVMInclude LLVM in the build for generating simulation binariesOFF
BUILD_SHARED_LIBSBuild a shared library instead of staticOFF
SLANG_COVERAGEEnable Clang code coverageOFF
SLANG_SANITIZERSA list of Clang sanitizers to include in the build""
FUZZ_TARGETTurn on to enable some changes to make binaries easier to fuzz testOFF
CI_BUILDEnable additional longer-running tests for automated buildsOFF
SLANG_MSVC_W4Enable /W4 for MSVC buildsON
SLANG_MSVC_STATIC_RUNTIMEEnable linking to the MSVC static runtimeON
LLVM_DIRWhen building with LLVM, a path to where the LLVM cmake system lives""
DOXYGENPY_PATHWhen building docs, the path to the doxygen.py tool""

Build Scripts

This section documents scripts that are invoked during the build that may be of general interest or useful to know if you're modifying how the build works.

Version info

On every build, the current git revision hash is queried and included in the Version.cpp header to expose to the rest of the library. If the revision is unchanged from the last build no additional work will be done.

Syntax generation

Syntax nodes in slang are expressed in the scripts/syntax.txt file and processed during the build into generated C++ classes by the syntax_gen.py script.

Diagnostic generation

Diagnostics, similarly to syntax nodes, are expressed in the scripts/diagnostics.txt file and processed into C++ definitions by the diagnostic_gen.py script.

Building Documentation

This section contains instructions for building the documentation.

Dependencies

Steps

Run cmake with docs enabled and the path to the doxygen.py script in the m.css checkout:

cmake -DSLANG_INCLUDE_DOCS=ON -DDOXYGENPY_PATH=/path/to/m.css/documentation/doxygen.py

Run the build:

make docs

The output website is located at docs/html/