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
You can try with StaticTools.jl, although it will have caveats, if it works at all. But you can check. ![]()
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.1and JuliaCv0.2.2, on 64-bit Fedora Workstation 43. - My example did not explicitly handle endian options. Look at the docs for
read,write,htol, andltohif you need explicit control. - I hardcoded this example to interpret
UInt8asFloat64to avoid type instability issues. A few of my alternative read and write routines passedcode_warntypetests, butJuliaC v0.2.2didn’t want to compile those routines. - Storage footprint on my machine for the
buildfolder was around ~80 MB. - The compiled binary worked when I copied the
buildfolder to my other PC that also has Fedora Workstation 43 and Juliav1.12.1installed. I haven’t done further testing on the portability and the required dependencies for the binary.
