# Slang Command Line Options *Usage:* ``` slangc [options...] [--] # For help slangc -h # To generate this file slangc -help-style markdown -h ``` ## Quick Links * [General](#General) * [Target](#Target) * [Downstream](#Downstream) * [Debugging](#Debugging) * [Experimental](#Experimental) * [Internal](#Internal) * [Depreciated](#Depreciated) * [compiler](#compiler) * [language](#language) * [archive-type](#archive-type) * [line-directive-mode](#line-directive-mode) * [debug-info-format](#debug-info-format) * [fp-mode](#fp-mode) * [help-style](#help-style) * [optimization-level](#optimization-level) * [debug-level](#debug-level) * [file-system-type](#file-system-type) * [target](#target) * [stage](#stage) * [capability](#capability) * [file-extension](#file-extension) # General General options ## -D **-D<name>\[=<value>\], -D <name>\[=<value>\]** Insert a preprocessor macro. The space between - D and <name> is optional. If no <value> is specified, Slang will define the macro with an empty value. ## -depfile **-depfile <path>** Save the source file dependency list in a file. ## -entry **-entry <name>** Specify the name of an entry-point function. When compiling from a single file, this defaults to main if you specify a stage using [-stage](#stage-1). Multiple [-entry](#entry) options may be used in a single invocation. When they do, the file associated with the entry point will be the first one found when searching to the left in the command line. If no [-entry](#entry) options are given, compiler will use \[shader(...)\] attributes to detect entry points. ## -emit-ir Emit IR typically as a '.slang-module' when outputting to a container. ## -h, -help, --help **-h or -h <help-category>** Print this message, or help in specified category. ## -help-style **-help-style <[help-style](#help-style)>** Help formatting style ## -I **-I<path>, -I <path>** Add a path to be used in resolving '#include' and 'import' operations. ## -lang **-lang <[language](#language)>** Set the language for the following input files. ## -matrix-layout-column-major Set the default matrix layout to column-major. ## -matrix-layout-row-major Set the default matrix layout to row-major. ## -module-name **-module-name <name>** Set the module name to use when compiling multiple .slang source files into a single module. ## -o **-o <path>** Specify a path where generated output should be written. If no [-target](#target-1) or [-stage](#stage-1) is specified, one may be inferred from file extension (see [<file-extension>](#file-extension)). If multiple [-target](#target-1) options and a single [-entry](#entry) are present, each [-o](#o) associates with the first [-target](#target-1) to its left. Otherwise, if multiple [-entry](#entry) options are present, each [-o](#o) associates with the first [-entry](#entry) to its left, and with the [-target](#target-1) that matches the one inferred from <path>. ## -profile **-profile <profile>\[+<[capability](#capability)>...\]** Specify the shader profile for code generation. Accepted profiles are: * sm_{4_0,4_1,5_0,5_1,6_0,6_1,6_2,6_3,6_4,6_5,6_6} * glsl_{110,120,130,140,150,330,400,410,420,430,440,450,460} Additional profiles that include [-stage](#stage-1) information: * {vs,hs,ds,gs,ps}_<version> See [-capability](#capability-1) for information on [<capability>](#capability) When multiple [-target](#target-1) options are present, each [-profile](#profile) associates with the first [-target](#target-1) to its left. ## -stage **-stage <[stage](#stage)>** Specify the stage of an entry-point function. When multiple [-entry](#entry) options are present, each [-stage](#stage-1) associated with the first [-entry](#entry) to its left. May be omitted if entry-point function has a \[shader(...)\] attribute; otherwise required for each [-entry](#entry) option. ## -target **-target <[target](#target)>** Specifies the format in which code should be generated. ## -v, -version Display the build version. This is the contents of git describe --tags. It is typically only set from automated builds(such as distros available on github).A user build will by default be 'unknown'. ## -warnings-as-errors **-warnings-as-errors all or -warnings-as-errors <id>\[,<id>...\]** all - Treat all warnings as errors. <id>\[,<id>...\]: Treat specific warning ids as errors. ## -warnings-disable **-warnings-disable <id>\[,<id>...\]** Disable specific warning ids. ## -W **-W<id>** Enable a warning with the specified id. ## -Wno- **-Wno-<id>** Disable warning with <id> ## -dump-warning-diagnostics Dump to output list of warning diagnostic numeric and name ids. ## -- Treat the rest of the command line as input files. # Target Target code generation options ## -capability **-capability <[capability](#capability)>\[+<[capability](#capability)>...\]** Add optional capabilities to a code generation target. See Capabilities below. ## -default-image-format-unknown Set the format of R/W images with unspecified format to 'unknown'. Otherwise try to guess the format. ## -disable-dynamic-dispatch Disables generating dynamic dispatch code. ## -disable-specialization Disables generics and specialization pass. ## -fp-mode, -floating-point-mode **-fp-mode <[fp-mode](#fp-mode)>, -floating-point-mode <[fp-mode](#fp-mode)>** Control floating point optimizations ## -g **-g, -g<[debug-info-format](#debug-info-format)>, -g<[debug-level](#debug-level)>** Include debug information in the generated code, where possible. [<debug-level>](#debug-level) is the amount of information, 0..3, unspecified means 2 [<debug-info-format>](#debug-info-format) specifies a debugging info format It is valid to have multiple [-g](#g) options, such as a [<debug-level>](#debug-level) and a [<debug-info-format>](#debug-info-format) ## -line-directive-mode **-line-directive-mode <[line-directive-mode](#line-directive-mode)>** Sets how the `#line` directives should be produced. Available options are: If not specified, default behavior is to use C-style `#line` directives for HLSL and C/C++ output, and traditional GLSL-style `#line` directives for GLSL output. ## -O **-O<[optimization-level](#optimization-level)>** Set the optimization level. ## -obfuscate Remove all source file information from outputs. # Downstream Downstream compiler options ## -none-path, -fxc-path, -dxc-path, -glslang-path, -visualstudio-path, -clang-path, -gcc-path, -genericcpp-path, -nvrtc-path, -llvm-path **-<[compiler](#compiler)>-path <path>** Specify path to a downstream [<compiler>](#compiler) executable or library. ## -default-downstream-compiler **-default-downstream-compiler <[language](#language)> <[compiler](#compiler)>** Set a default compiler for the given language. See [-lang](#lang) for the list of languages. ## -X **-X<[compiler](#compiler)> <option> -X<[compiler](#compiler)>... <options> -X.** Pass arguments to downstream [<compiler>](#compiler). Just [-X<compiler>](#X) passes just the next argument to the downstream compiler. [-X<compiler>](#X)... options [-X](#X). will pass *all* of the options inbetween the opening [-X](#X) and [-X](#X). to the downstream compiler. ## -pass-through **-pass-through <[compiler](#compiler)>** Pass the input through mostly unmodified to the existing compiler [<compiler>](#compiler). These are intended for debugging/testing purposes, when you want to be able to see what these existing compilers do with the "same" input and options # Debugging Compiler debugging/instrumentation options ## -dump-ast Dump the AST to a .slang-ast file next to the input. ## -dump-intermediate-prefix **-dump-intermediate-prefix <prefix>** File name prefix for [-dump-intermediates](#dump-intermediates) outputs, default is 'slang-dump-' ## -dump-intermediates Dump intermediate outputs for debugging. ## -dump-ir Dump the IR for debugging. ## -dump-ir-ids Dump the IDs with [-dump-ir](#dump-ir) (debug builds only) ## -dump-repro Dump a `.slang-repro` file that can be used to reproduce a compilation on another machine. ## -dump-repro-on-error Dump `.slang-repro` file on any compilation error. ## -E, -output-preprocessor Output the preprocessing result and exit. ## -extract-repro **-extract-repro <name>** Extract the repro files into a folder. ## -load-repro-directory **-load-repro-directory <path>** Use repro along specified path ## -load-repro **-load-repro <name>** Load repro ## -no-codegen Skip the code generation step, just check the code and generate layout. ## -output-includes Print the hierarchy of the processed source files. ## -repro-file-system **-repro-file-system <name>** Use a repro as a file system ## -serial-ir Serialize the IR between front-end and back-end. ## -skip-codegen Skip the code generation phase. ## -validate-ir Validate the IR between the phases. ## -verbose-paths When displaying diagnostic output aim to display more detailed path information. In practice this is typically the complete 'canonical' path to the source file used. ## -verify-debug-serial-ir Verify IR in the front-end. # Experimental Experimental options (use at your own risk) ## -emit-spirv-directly Generate SPIR-V output directly (otherwise through GLSL and using the glslang compiler) ## -file-system **-file-system <[file-system-type](#file-system-type)>** Set the filesystem hook to use for a compile request. ## -heterogeneous Output heterogeneity-related code. ## -no-mangle Do as little mangling of names as possible. # Internal Internal-use options (use at your own risk) ## -archive-type **-archive-type <[archive-type](#archive-type)>** Set the archive type for [-save-stdlib](#save-stdlib). Default is zip. ## -compile-stdlib Compile the StdLib from embedded sources. Will return a failure if there is already a StdLib available. ## -doc Write documentation for [-compile-stdlib](#compile-stdlib) ## -ir-compression **-ir-compression <type>** Set compression for IR and AST outputs. Accepted compression types: none, lite ## -load-stdlib **-load-stdlib <filename>** Load the StdLib from file. ## -r **-r <name>** reference module <name> ## -save-stdlib **-save-stdlib <filename>** Save the StdLib modules to an archive file. ## -save-stdlib-bin-source **-save-stdlib-bin-source <filename>** Same as [-save-stdlib](#save-stdlib) but output the data as a C array. ## -track-liveness Enable liveness tracking. Places SLANG_LIVE_START, and SLANG_LIVE_END in output source to indicate value liveness. # Depreciated Deprecated options (allowed but ignored; may be removed in future) ## -parameter-blocks-use-register-spaces Parameter blocks will use register spaces # compiler Downstream Compilers (aka Pass through) * `none` : Unknown * `fxc` : FXC HLSL compiler * `dxc` : DXC HLSL compiler * `glslang` : GLSLANG GLSL compiler * `visualstudio`, `vs` : Visual Studio C/C++ compiler * `clang` : Clang C/C++ compiler * `gcc` : GCC C/C++ compiler * `genericcpp`, `c`, `cpp` : A generic C++ compiler (can be any one of visual studio, clang or gcc depending on system and availability) * `nvrtc` : NVRTC CUDA compiler * `llvm` : LLVM/Clang `slang-llvm` # language Language * `c`, `C` : C language * `cpp`, `c++`, `C++`, `cxx` : C++ language * `slang` : Slang language * `glsl` : GLSL language * `hlsl` : HLSL language * `cu`, `cuda` : CUDA # archive-type Archive Type * `riff-deflate` : Slang RIFF using deflate compression * `riff-lz4` : Slang RIFF using LZ4 compression * `zip` : Zip file * `riff` : Slang RIFF without compression # line-directive-mode Line Directive Mode * `none` : Don't emit `#line` directives at all * `source-map` : Use source map to track line associations (doen't emit #line) * `default` : Default behavior * `standard` : Emit standard C-style `#line` directives. * `glsl` : Emit GLSL-style directives with file *number* instead of name. # debug-info-format Debug Info Format * `default-format` : Use the default debugging format for the target * `c7` : CodeView C7 format (typically means debugging infomation is embedded in the binary) * `pdb` : Program database * `stabs` : STABS debug format * `coff` : COFF debug format * `dwarf` : DWARF debug format # fp-mode Floating Point Mode * `precise` : Disable optimization that could change the output of floating-point computations, including around infinities, NaNs, denormalized values, and negative zero. Prefer the most precise versions of special functions supported by the target. * `fast` : Allow optimizations that may change results of floating-point computations. Prefer the fastest version of special functions supported by the target. * `default` : Default floating point mode # help-style Help Style * `text` : Text suitable for output to a terminal * `markdown` : Markdown * `no-link-markdown` : Markdown without links # optimization-level Optimization Level * `0`, `none` : Disable all optimizations * `1`, `default` : Enable a default level of optimization.This is the default if no [-o](#o) options are used. * `2`, `high` : Enable aggressive optimizations for speed. * `3`, `maximal` : Enable further optimizations, which might have a significant impact on compile time, or involve unwanted tradeoffs in terms of code size. # debug-level Debug Level * `0`, `none` : Don't emit debug information at all. * `1`, `minimal` : Emit as little debug information as possible, while still supporting stack traces. * `2`, `standard` : Emit whatever is the standard level of debug information for each target. * `3`, `maximal` : Emit as much debug information as possible for each target. # file-system-type File System Type * `default` : Default fike system. * `load-file` : Just implements loadFile interface, so will be wrapped with CacheFileSystem internally. * `os` : Use the OS based file system directly (without file system caching) # target Target * `unknown` * `none` * `hlsl` : HLSL source code * `dxbc` : DirectX shader bytecode binary * `dxbc-asm`, `dxbc-assembly` : DirectX shader bytecode assembly * `dxil` : DirectX Intermediate Language binary * `dxil-asm`, `dxil-assembly` : DirectX Intermediate Language assembly * `glsl` : GLSL source code * `glsl-vulkan` : GLSL Vulkan source code * `glsl-vulkan-one-desc` : GLSL Vulkan source code * `spirv` : SPIR-V binary * `spirv-asm`, `spirv-assembly` : SPIR-V assembly * `c` : C source code * `cpp`, `c++`, `cxx` : C++ source code * `torch`, `torch-binding`, `torch-cpp`, `torch-cpp-binding` : C++ for pytorch binding * `host-cpp`, `host-c++`, `host-cxx` : C++ source for host execution * `exe`, `executable` : Executable binary * `sharedlib`, `sharedlibrary`, `dll` : Shared library/Dll * `cuda`, `cu` : CUDA source code * `ptx` : PTX assembly * `cuobj`, `cubin` : CUDA binary * `host-callable`, `callable` : Host callable * `object-code` : Object code * `host-host-callable` : Host callable for host execution # stage Stage * `vertex` * `hull` * `domain` * `geometry` * `pixel`, `fragment` * `compute` * `raygeneration` * `intersection` * `anyhit` * `closesthit` * `miss` * `callable` * `mesh` * `amplification` # capability A capability describes an optional feature that a target may or may not support. When a [-capability](#capability-1) is specified, the compiler may assume that the target supports that capability, and generate code accordingly. * `spirv_1_{ 0`, `1`, `2`, `3`, `4`, `5 }` : minimum supported SPIR - V version * `invalid` * `hlsl` * `glsl` * `c` * `cpp` * `cuda` * `spirv_direct` * `GL_NV_ray_tracing` : enables the GL_NV_ray_tracing extension * `GL_EXT_ray_tracing` : enables the GL_EXT_ray_tracing extension * `GL_NV_fragment_shader_barycentric` : enables the GL_NV_fragment_shader_barycentric extension * `GL_EXT_fragment_shader_barycentric` : enables the GL_EXT_fragment_shader_barycentric extension # file-extension A [<language>](#language), <format>, and/or [<stage>](#stage) may be inferred from the extension of an input or [-o](#o) path * `hlsl`, `fx` : hlsl * `dxbc` * `dxbc-asm` : dxbc-assembly * `dxil` * `dxil-asm` : dxil-assembly * `glsl` * `vert` : glsl (vertex) * `frag` : glsl (fragment) * `geom` : glsl (geoemtry) * `tesc` : glsl (hull) * `tese` : glsl (domain) * `comp` : glsl (compute) * `slang` * `spv` : SPIR-V * `spv-asm` : SPIR-V assembly * `c` * `cpp`, `c++`, `cxx` : C++ * `exe` : executable * `dll`, `so` : sharedlibrary/dll * `cu` : CUDA * `ptx` : PTX * `obj`, `o` : object-code * `zip` : container * `slang-module`, `slang-library` : Slang Module/Library * `dir` : Container as a directory