PackageCompiler: does `precompile` store machine code?

You can pass Julia code to create_sysimage using:

  • precompile_execution_file / precompile_statements_file; and
  • script

Do I have it correct that the first option only stores type inference in the sysimage, and not generated machine code, while using script stores both?

If so, what’s the use of precompile_execution_file; why would anyone not always use script instead.

All variants compile machine code instructions.

The precompile_* are used to create a file that is executed to output the object file.
If you provide a precompile_executation_file that will actually be converted into precompile statements either way. The precompile statements are then wrapped with some Julia code.
(See here. )

The script is just some plain Julia code you can append to the executed Julia code. This way you essentially skip all the smart things PackageCompiler does. (See here.)

I am not sure what the script is for, but from the source code, it seems like one shouldn’t use it if there is no reason for it. Like it could for example add more things to the sysimage than wanted.

1 Like

Interesting, thank you.
So there is a difference in what precompile does in a normal Julia session [1] and in one with --output-o

[1] Namely only type inference, not generate machine code, as explained at (Unless I misunderstand that text).

1 Like

Yes, I think the link you shared explains the difference well. :+1: