-
Notifications
You must be signed in to change notification settings - Fork 40
Closed
Labels
Description
Description
When I try to read from a file:
// repro.effekt
import io
import io/error
import io/files
def main() = eventloop(box {
with on[IOError].panic;
with filesystem;
val contents = do readFile("repro.effekt")
println(contents)
})I get the following error:
bash-5.2$ effekt --backend=llvm repro.effekt
opt: ./out/repro.ll:1114:17: error: use of undefined value '@writeFile'
call void @writeFile(i32 %fd_int, %Pos %buffer, i64 noundef %offset, ptr %onSuccess_ptr, ptr %onFailure_ptr) #0
^
Exception in thread "main" java.lang.RuntimeException: Nonzero exit value: 1
[...]Investigation 🔍
Upon taking a closer look at ./out/repro.ll, I can see that writeFile is truly neither defined nor declared there.
This happens even when I try to first build, then run.
If I had to guess, then the real name we're looking for is c_file_read in llvm/io.c
Line 476 in cd741e8
| void c_file_read(int32_t fd, struct Pos buffer, int64_t offset, struct Neg* success, struct Neg* failure) { |
which got renamed at the end of #469.
When investigating this, I also noticed that the LLVM definition corresponds to the C definition only with the ARM64 calling convention:
Line 13 in cd741e8
| declare void @c_file_read([2 x i64], [2 x i64], i64, [2 x i64], [2 x i64]) |
I think it should be something like declare void @c_file_write(i32, %Pos, i64, %Neg*, %Neg*) instead? (or ptr, ptr for the last two, not sure)