Description
- Julia Version: 1.12.0-beta3+0.x64.linux.gnu (installed by juliaup)
- OS/Architecture: Linux x86_64, Ubuntu 22.04
Description
When attempting to compile a simple Julia script that uses basic standard input (readline
) and output (println
) into a standalone executable using juliac.jl --experimental --trim
in Julia 1.12.0-beta3, the compilation fails with "Verifier error: unresolved call" messages.
Compiling without --trim
succeeds, but the resulting executable fails at runtime with an ArgumentError
related to the TTY not being initialized.
Steps to Reproduce
Save the following code as TestInput.jl
:
```julia
module TestInput
using Printf
Base.@ccallable function main()::Cint
println("Input an integer: ")
num = readline(Base.stdin)
println("The number is: ", parse(Int, num))
return 0
end
end
```
With --trim
Attempt to compile the code using juliac.jl
with the --trim
flag:
julia +1.12.0-beta3 /path/juliaup/julia-1.12.0-beta3+0.x64.linux.gnu/share/julia/juliac.jl --output-exe TestInput-trimmed --experimental --trim TestInput.jl
Replace /path/
with the actual path to your Julia installation
The compilation fails and the full output is provided below:
Verifier error #1: unresolved call from statement TestInput.readline(Base.getglobal(TestInput.Base, :stdin)::IO)::String
Stacktrace:
[1] main()
@ TestInput /media/Big/test/compile-trim-beta3/TestInput.jl:7
Verifier error #2: unresolved call from statement Base.print(Base.stdout::IO, x1::String, x2::Int64, "\n")::Nothing
Stacktrace:
[1] println(x1::String, x2::Int64)
@ Base coreio.jl:6
[2] main()
@ TestInput /media/Big/test/compile-trim-beta3/TestInput.jl:8
Verifier error #3: unresolved call from statement Base.print(Base.stdout::IO, x::Any, "\n")::Nothing
Stacktrace:
[1] println(x::String)
@ Base coreio.jl:5
[2] main()
@ TestInput /media/Big/test/compile-trim-beta3/TestInput.jl:6
Verifier error #4: unresolved call from statement TestInput.readline(Base.getglobal(TestInput.Base, :stdin)::IO)::String
Stacktrace:
[1] main()
@ TestInput /media/Big/test/compile-trim-beta3/TestInput.jl:7
Verifier error #5: unresolved call from statement Base.print(Base.stdout::IO, x1::String, x2::Int64, "\n")::Nothing
Stacktrace:
[1] println(x1::String, x2::Int64)
@ Base coreio.jl:6
[2] main()
@ TestInput /media/Big/test/compile-trim-beta3/TestInput.jl:8
Verifier error #6: unresolved call from statement Base.print(Base.stdout::IO, x::Any, "\n")::Nothing
Stacktrace:
[1] println(x::String)
@ Base coreio.jl:5
[2] main()
@ TestInput /media/Big/test/compile-trim-beta3/TestInput.jl:6
Trim verify finished with 6 errors, 0 warnings.
Failed to compile TestInput.jl
Without --trim
For context, compiling without --trim
succeeds:
julia +1.12.0-beta3 /path/juliaup/julia-1.12.0-beta3+0.x64.linux.gnu/share/julia/juliac.jl --output-exe TestInput --experimental TestInput.jl
However the resulting executable fails at runtime (run by execute ./TestInput
) and the full output is provided below:
Input an integer:
fatal: error thrown and no exception handler available.
ArgumentError(msg="TTY(RawFD(-1) invalid status, 0 bytes waiting) is not initialized")
isopen at ./stream.jl:381 [inlined]
#copyuntil#650 at ./stream.jl:1035
copyuntil at ./stream.jl:1029 [inlined]
#copyline#395 at ./iobuffer.jl:942
copyline at ./iobuffer.jl:918 [inlined]
#readline#355 at ./io.jl:619
readline at ./io.jl:619
unknown function (ip: 0x7f2f300f52b7) at (unknown file)
main at /media/Big/test/compile-trim-beta3/TestInput.jl:7
main at ./TestInput (unknown line)
unknown function (ip: 0x7f2f3fe29d8f) at /lib/x86_64-linux-gnu/libc.so.6
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
_start at ./TestInput (unknown line)