SVM

Compiler macros

Select code at compile time with SVM_COMPILED.

Macro support in the hosted compiler has not been verified. This reference describes the current Secure Luau language feature; it does not guarantee support in every compiler release.

SVM_COMPILED

SVM_COMPILED is a compile-time boolean that is true when Secure Luau compiles the source:

if SVM_COMPILED then
    print("compiled with svm")
else
    print("not compiled with svm")
end

The compiler parses the macro as the literal true, without looking up a global variable. Constant if branches are selected before bytecode generation, including at optimization level 0. Code and nested functions in the discarded branch are not emitted.

In an ordinary Luau environment where no global named SVM_COMPILED is defined, the example selects the else branch.

Restrictions

  • SVM_COMPILED is reserved: you cannot declare it, assign to it or shadow it with a local variable or parameter.
  • Text inside strings and comments is unchanged.
  • This is a compile-time feature, not a runtime check for program membership or permission to call an API.

See function attributes for controls that apply to individual functions.

Back to SVM workspace