Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PackageCompiler Incompatibility: InitError(mod=:Tulip, ... #131

Open
StefanPofahl opened this issue Feb 19, 2023 · 2 comments
Open

PackageCompiler Incompatibility: InitError(mod=:Tulip, ... #131

StefanPofahl opened this issue Feb 19, 2023 · 2 comments

Comments

@StefanPofahl
Copy link

I have opended an issue regarding a Tulip PackageCompiler -Incompatibility, see:
JuliaLang/PackageCompiler.jl#789

The minal example is as follows:

module MyAppHelloTulip
using Tulip
function julia_main()::Cint
    try
        if isempty(ARGS)
            real_main(string("Tulip Version: v", Tulip.__init__()))
        else
            real_main(ARGS[1])
        end
    catch
        Base.invokelatest(Base.display_error, Base.catch_stack())
        return 1
    end
return 0 # if things finished successfully
end                                                                               
  
real_main(_s::AbstractString) = println(_s)

try
    if abspath(PROGRAM_FILE) == @__FILE__
        real_main("abspath(PROGRAM_FILE) == @__FILE__")
    end
catch
    Base.invokelatest(Base.display_error, Base.catch_stack())
    return 3
end

end # module

Do you have a proposal, how to handle this issue?

@mkitti
Copy link

mkitti commented Feb 19, 2023

Try

module MyAppHelloTulip
using Tulip
function julia_main()::Cint
    try
        if isempty(ARGS)
            real_main(string("Tulip Version: v", Tulip.__init__()))
        else
            real_main(ARGS[1])
        end
    catch
        Base.invokelatest(Base.display_error, Base.catch_stack())
        return 1
    end
return 0 # if things finished successfully
end                                                                               
  
real_main(_s::AbstractString) = println(_s)

function __init__()
    try
        if abspath(PROGRAM_FILE) == @__FILE__
            real_main("abspath(PROGRAM_FILE) == @__FILE__")
        end
    catch
        Base.invokelatest(Base.display_error, Base.catch_stack())
        return 3
    end
end

end # module

Anything executed at the top level is being run at precompile time. Rather you probably want it to run when the module is loaded at runtime.

@StefanPofahl
Copy link
Author

Thanks for the advice, do you know a text, where the Julia concept of __init()__() is explained in an easy to understand manner?
Unfortunately, I still have no clue how to solve the initial issue of non relocability of Tulip.jl :-(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants