owi
owi copied to clipboard
Add missing functions to our stdio.c
As highlighted in #269 in sv-benchmarks/c/busybox-1.22.0/od-4.i we fail with
wasm-ld-18: error: /tmp/od-4-02ca46.o: undefined symbol: stdin
wasm-ld-18: error: /tmp/od-4-02ca46.o: undefined symbol: setbuf
wasm-ld-18: error: /tmp/od-4-02ca46.o: undefined symbol: fread
wasm-ld-18: error: /tmp/od-4-02ca46.o: undefined symbol: stdin
wasm-ld-18: error: /tmp/od-4-02ca46.o: undefined symbol: fseek
wasm-ld-18: error: /tmp/od-4-02ca46.o: undefined symbol: ferror
wasm-ld-18: error: /tmp/od-4-02ca46.o: undefined symbol: stdin
wasm-ld-18: error: /tmp/od-4-02ca46.o: undefined symbol: ferror
wasm-ld-18: error: /tmp/od-4-02ca46.o: undefined symbol: fgetc
wasm-ld-18: error: /tmp/od-4-02ca46.o: undefined symbol: fread
wasm-ld-18: error: /tmp/od-4-02ca46.o: undefined symbol: ferror
wasm-ld-18: error: /tmp/od-4-02ca46.o: undefined symbol: stdin
clang: error: linker command failed with exit code 1 (use -v to see invocation)
run ['/usr/bin/clang' '-O0' '--target=wasm32' '-m32' '-ffreestanding'
'--no-standard-libraries' '-Wno-everything' '-flto=thin'
'-Wl,--entry=main' '-Wl,--export=main' '-Wl,--lto-O0'
'-Wl,-z,stack-size=8388608' '-I'
'/home/zapashcanon/.config/opam/5.1.0/share/owi/libc' '-o' 'a.out.wasm'
'/home/zapashcanon/.config/opam/5.1.0/share/owi/binc/libc.wasm'
'owi-out/od-4.c']: exited with 1
This is because we are missing functions in our implementation of stdio.h
Actually it looks like we already have these functions. The file is actually not including stdio.h, but has stuff like:
extern struct _IO_FILE *stdin;
I'm not sure how we should deal with it. Maybe adding an option to clang not to fail on undefined symbols (I remember seeing one at some point) would be enough...