({{, (RefLink[FunctionCompileExport, paclet:ref/FunctionCompileExport])["file.ext",func]
exports a compiled version of func in the format specified by the file extension ext.}, {, (RefLink[FunctionCompileExport, paclet:ref/FunctionCompileExport])[path,func,"format"]
exports in the specified format.}})

OpenersNotesSection(Spacer1)Details and Options

By default, (RefLink[FunctionCompileExport, paclet:ref/FunctionCompileExport]) exports object or assembler code suitable for the machine architecture on which it is being run.

The following file extensions and export formats are supported:

The following options can be given:

(RefLink[FunctionCompileExport, paclet:ref/FunctionCompileExport]) returns the name of the file that it created.

In (RefLink[FunctionCompileExport, paclet:ref/FunctionCompileExport])[path,func,…], func can be a (RefLink[CompiledCodeFunction, paclet:ref/CompiledCodeFunction]) object.

OpenersPrimaryExamplesSection(Spacer1)Examples  (2)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Export a compiled version of a function into a file:

FunctionCompileExport["file.o",Function[Typed[arg,"MachineInteger"],arg+1]]

The export format can be determined from the file name:

FunctionCompileExport["file.s",Function[Typed[arg,"MachineInteger"],arg+1]];
FilePrint["file.s"]

The export format can be given explicitly:

FunctionCompileExport["file.s",Function[Typed[arg,"MachineInteger"],arg+1], "Assembler"];
FilePrint["file.s"]

LLVM IR can be generated:

FunctionCompileExport["file.ll",Function[Typed[arg,"MachineInteger"],arg+1], "LLVM"];
FilePrint["file.ll"]

OpenersExampleSection1(Spacer1)Options  (1)

OpenersExampleSubsection0(Spacer1)TargetSystem  (1)

The default setting of (RefLink[Automatic, paclet:ref/Automatic]) generates code for the machine architecture on which it is being run:

FunctionCompileExport["file.s",Function[Typed[arg,"MachineInteger"],arg+1]];
FilePrint["file.s"]

(RefLink[TargetSystem, paclet:ref/TargetSystem]) can be set to the (RefLink[$SystemID, paclet:ref/$SystemID]) of the desired platform:

FunctionCompileExport["file.s",Function[Typed[arg,"MachineInteger"],arg+1],TargetSystem->"Linux-ARM"];
FilePrint["file.s"]

(RefLink[TargetSystem, paclet:ref/TargetSystem]) can be set for architectures for which the Wolfram Engine does not exist:

FunctionCompileExport["file.s",Function[Typed[arg,"MachineInteger"],arg+1],TargetSystem->"WebAssembly"];
FilePrint["file.s"]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[FunctionCompile, paclet:ref/FunctionCompile])  ▪  (RefLink[FunctionCompileExportString, paclet:ref/FunctionCompileExportString])  ▪  (RefLink[FunctionCompileExportByteArray, paclet:ref/FunctionCompileExportByteArray])  ▪  (RefLink[FunctionCompileExportLibrary, paclet:ref/FunctionCompileExportLibrary])  ▪  (RefLink[TargetSystem, paclet:ref/TargetSystem])  ▪  (RefLink[Export, paclet:ref/Export])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Code Compilation, paclet:guide/CodeCompilation])}})}})