Skip to content

use @main for juliac executable entry point #57588

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JeffBezanson
Copy link
Member

@JeffBezanson JeffBezanson commented Feb 28, 2025

juliac clearly should use the at-main mechanism for executables. That also allows us to call julia_init from C main instead of using __attribute__((constructor)). I also added support for passing in the command line arguments (kind of useful!)

I changed Core.ARGS from a Vector{Any} to a Vector{String}. I don't know why we didn't do that years ago. Surely this is ok?

The biggest problem is looking up julia main from C main. For now I put in a hack to keep the binding around, but it's not very satisfying. Maybe we should insert a ccallable with some known name like juliac_exe_main? Any other ideas on how to handle this? Edit: done.

@JeffBezanson JeffBezanson force-pushed the jb/juliacatmain branch 3 times, most recently from 069533d to 4a7e6d6 Compare March 28, 2025 19:43
@fingolfin fingolfin requested review from aviatesk and topolarity May 7, 2025 23:33
Copy link
Member

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds sensible to me... any suggestions for someone else who would be better-suited than me for reviewing this?

@JeffBezanson
Copy link
Member Author

Thanks.

I have an idea to improve this. We should detect whether you've written your own ccallable main and in that case use it, otherwise we inject a C main that calls the julia at-main.

@JeffBezanson JeffBezanson force-pushed the jb/juliacatmain branch 2 times, most recently from ac988cb to 2633905 Compare May 16, 2025 21:50
@JeffBezanson JeffBezanson added the backport 1.12 Change should be backported to release-1.12 label May 21, 2025
add support for command line arguments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 1.12 Change should be backported to release-1.12 juliac
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants