I would like to distribute my package while hiding the source code. I came across PackageCompiler.jl and julia’s --strip-ir
option to help, but when I load a sysimage generated using that option, I get an error that some source code is not available. Here is an example on a simple package with detailed steps:
I have a module SimplePkg
:
module SimplePkg
export nodoc
nodoc(x) = sin(sqrt(x))
"""
Returns sin(sqrt(x))
"""
withdoc(x) = nodoc(x)
end # module
and a script “scratch.jl” that uses the package:
using SimplePkg
nodoc(100)
SimplePkg.withdoc(100)
nodoc(100.0)
I then create a sysimage using the following commands
using PackageCompiler
create_sysimage(:SimplePkg, sysimage_path="SimplePkg_StripIR.so", precompile_execution_file="scratch.jl", sysimage_build_args=`--strip-ir`)
If I open julia using julia -J SimplePkg_StripIR.so
, I get the following
source not available for activate(REPL.LineEdit.TextInterface, REPL.LineEdit.MIState, REPL.Terminals.AbstractTerminal, REPL.Terminals.TextTerminal) from activate(REPL.LineEdit.TextInterface, REPL.LineEdit.MIState, REPL.Terminals.AbstractTerminal, REPL.Terminals.TextTerminal)
source not available for (::Type{NamedTuple{(:exception, :backtrace), T} where T<:Tuple})(Tuple{ErrorException, Array{Union{Ptr{Nothing}, Base.InterpreterIP}, 1}}) from (::Type{NamedTuple{names, T} where T<:Tuple})(Tuple) where {names}
source not available for (::Type{NamedTuple{(:exception, :backtrace), T} where T<:Tuple})(Tuple{ErrorException, Array{Union{Ptr{Nothing}, Base.InterpreterIP}, 1}}) from (::Type{NamedTuple{names, T} where T<:Tuple})(Tuple) where {names}
SYSTEM: caught exception of type source not available for show(Core.CoreSTDERR, Any) from show(IO, Any)
source not available for (::REPL.var"#48#53"{REPL.REPLBackendRef})() from (::REPL.var"#48#53"{backend_ref})()
It looks to me not something related to my code. Would be great to hear from someone who has managed to make this option work. I came across this post Obfuscate Julia module and import it Python - #10 by Palli suggesting that --compile=all
should be present, but that did not work either.
Thanks!