Skip to content

Command-line arguments differ between interpreted and juliac compiled code. #59252

@djpeaco

Description

@djpeaco

Code compiled with juliac in the latest 1.12 rc includes the executable name as the first argument, while the same code run with the normal julia interpreter (JIT) does not. For example, given the following program arg_index.jl:

function @main(args::Vector{String})::Cint
    for i in eachindex(args)
        println(Core.stdout, string(i), ") ", args[i])
    end
    return 0
end
$ julia +1.12 arg_index.jl foo
1) foo

$ julia +1.12 $HOME/.julia/juliaup/julia-1.12.0-rc1+0.x64.linux.gnu/share/julia/juliac/juliac.jl --output-exe arg_index --experimental --trim arg_index.jl
$ ./arg_index foo
1) ./arg_index
2) foo

Tested in:

Julia Version 1.12.0-rc1
Commit 228edd6610b (2025-07-12 20:11 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 6 × Intel(R) Core(TM) i5-8600 CPU @ 3.10GHz
  WORD_SIZE: 64
  LLVM: libLLVM-18.1.7 (ORCJIT, skylake)
  GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 6 virtual cores)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions