JuliaLang / PackageCompiler.jl

Compile your Julia Package
https://julialang.github.io/PackageCompiler.jl/dev/
MIT License
1.41k stars 189 forks source link

Special characters in Julia ARGS #835

Open raphasampaio opened 1 year ago

raphasampaio commented 1 year ago
  1. version info:
    Julia Version 1.9.2
    Commit e4ee485e90 (2023-07-05 09:39 UTC)
    Platform Info:
    OS: Windows (x86_64-w64-mingw32)
    CPU: 8 × 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
    WORD_SIZE: 64
    LIBM: libopenlibm
    LLVM: libLLVM-14.0.6 (ORCJIT, tigerlake)
    Threads: 1 on 8 virtual cores
    Environment:
    JULIA_192 = "D:\Program Files\Julia-1.9.2\bin\julia.exe"
  2. I downloaded the portable version and created the %JULIA_192% environment variable.
  3. To reproduce, you should compile the following program:

src/Application.jl:

module Application

function main(args)
    @show args
    return nothing
end

function julia_main()::Cint
    main(ARGS)
    return 0
end

end

main.jl:

import Pkg
Pkg.instantiate()

using Application
Application.main(ARGS)

compile/compile.jl:

using PackageCompiler 

function compile()
    package_path = dirname(@__DIR__)
    build_path = joinpath(@__DIR__, "build")

    if isdir(build_path)
        rm(build_path, force = true, recursive = true)
    end
    mkdir(build_path)

    PackageCompiler.create_app(
        package_path,
        build_path,
        executables = ["Application" => "julia_main"],
        force = true,
    )
    return nothing
end

compile()

And run the compiled application with a special character argument:

Application.exe "d:\áéíóú"
args = ["d:\\\xe1\xe9\xed\xf3\xfa"]

However, it works fine with the Julia-interpreted version:

%JULIA_192% --project main.jl "d:\áéíóú"
args = ["d:\\áéíóú"]

There may be a missing parsing step in embedding_wrapper.c for UTF8 string conversion. Ready to assist/test as needed.