Can binaries made with juliac --trim open files or read input?

That’s my question. Does anyone have a working example of a program that compiles under v1.12 using juliac --trim=safe etc. that either opens and reads from a file or reads input from the terminal?

1 Like

Next point on the TODO list:

From the presentation on JuliaCon, July 2025.

5 Likes

You can try with StaticTools.jl, although it will have caveats, if it works at all. But you can check. :slight_smile:

1 Like

This old demo does some low level reading and writing

4 Likes

I played around with wrapping liburing so that I can use io_uring to asynchronously read and write in trimmable Julia. I managed to write my own basic cp, but the API is still not ready for public consumption yet as I’m still trying to figure out how to use sum types to safely wrap C APIs without using exception

2 Likes

I made a minimalist tutorial for reading and saving binary files: comile-julia-examples. Perhaps it can be helpful to you until JuliaC can handle more IO functionalities. Quick notes:

  • Tutorial written for and tested on Julia v1.12.1 and JuliaC v0.2.2, on 64-bit Fedora Workstation 43.
  • My example did not explicitly handle endian options. Look at the docs for read, write, htol, and ltoh if you need explicit control.
  • I hardcoded this example to interpret UInt8 as Float64 to avoid type instability issues. A few of my alternative read and write routines passed code_warntype tests, but JuliaC v0.2.2 didn’t want to compile those routines.
  • Storage footprint on my machine for the build folder was around ~80 MB.
  • The compiled binary worked when I copied the build folder to my other PC that also has Fedora Workstation 43 and Julia v1.12.1 installed. I haven’t done further testing on the portability and the required dependencies for the binary.