Comments (4)
Just for the record, I tried to reproduce this with https://webassembly.sh:
File uploaded successfully to /tmp
→ /tmp/log.c
$ cat /tmp/log.c
int main(void) { extern double log(double); printf("%f ---> %f\n", 7.4225, log(7.4225)); return 0; }
$ clang -cc1 -triple wasm32-unkown-wasi -isysroot /sys -internal-isystem /sys/include -emit-obj -o ./log.o /tmp/log.c
/tmp/log.c:1:45: warning: implicitly declaring library function 'printf' with type 'int (const char *, ...)'
int main(void) { extern double log(double); printf("%f ---> %f\n", 7.4225, log(7.4225)); return 0; }
^
/tmp/log.c:1:45: note: include the header <stdio.h> or explicitly provide a declaration for 'printf'
1 warning generated.
$ wasm-ld -L/sys/lib/wasm32-wasi /sys/lib/wasm32-wasi/crt1.o ./log.o -lc -o ./log.wasm
$ wasmer log.wasm
7.422500 ---> 2.004516
And there it produces the correct result.
from wasi-libc.
I don't have a nix
machine handy, but at a quick try with the latest clang and wasi-libc, the testcase produces the correct result for me. Would it be possible to upload the wasm file somwhere?
from wasi-libc.
Compiled as
clang-10 --compile -fpic -fvisibility=hidden --std=c11 --target=wasm32-emscripten -fvisibility=hidden -fno-builtin -ffreestanding --optimize=3 -isystem /nix/store/n2zmrqyhm1avzwz9jf8kliz4ws29pph1-source/libc-top-half/musl/arch/wasm32 -isystem /nix/store/n2zmrqyhm1avzwz9jf8kliz4ws29pph1-source/libc-top-half/musl/src/include -isystem /nix/store/n2zmrqyhm1avzwz9jf8kliz4ws29pph1-source/libc-top-half/musl/src/internal -isystem /nix/store/mz8fajfb2sq5v9czy4rn70v7fz409l8n-musl-wasi-sysroot/include -I /nix/store/n2zmrqyhm1avzwz9jf8kliz4ws29pph1-source/libc-top-half/musl/../headers/private -D_ERRNO_H -DEOVERFLOW=75 -DEINVAL=22 -Derrno='(*({ static int bla = 0; &bla; }))' -DNL_ARGMAX=9 -D'TOKENPASTE0(x, y)=x ## y' -D'TOKENPASTE(x, y)=TOKENPASTE0(x, y)' -D'__fwritex=TOKENPASTE(__fwritex_,__COUNTER__)' -D'__fwritex_2(s, l, f)=(f->write((f), (s), (l)))' -D'__towrite=TOKENPASTE(__towrite_,__COUNTER__)' -D'__towrite_3(f)=(0)' -D__wasilibc_printscan_no_long_double -D__wasilibc_printscan_full_support_option='""' -D__wasi__ -D__NEED_va_list -D__NEED_off_t -Dsqrt=__builtin_sqrt -Dfabs=__builtin_fabs /nix/store/n2zmrqyhm1avzwz9jf8kliz4ws29pph1-source/libc-top-half/musl/src/math/log.c --output _build/wasm/musl_log.o
(Yes, I know about --target=wasm32-emscripten
, that is needed in my setup for technical reasons (i.e. dynamic linking), but I'd be surprised if that turned out to be the problem).
musl_log.o.zip
from wasi-libc.
Oops, I found my error. The file log_data.c
was not linked into my library. Sorry for the noise!
from wasi-libc.
Related Issues (20)
- Adding `IFTODT` for more compatibility HOT 1
- A few packaging nits, coming from Nixpkgs/NixOS HOT 6
- Confusion around SIGCHLD value? HOT 2
- WASI signal numbers out of sync with wasi-libc signal numbers HOT 15
- Latest SIMD patch HOT 2
- fd_set implementation is inefficient HOT 5
- Support for `accept{,4}` HOT 3
- Implement the new preopen scheme in wasi-libc HOT 1
- __wasm_call_ctors broken previously wokring rust wasm reactors HOT 2
- getpagesize() HOT 4
- README seems to be wrong wrt minimal LLVM version HOT 4
- Provide socket option definitions HOT 3
- Missing __WASI_RIFLAGS_RECV_DATA_TRUNCATED for MSG_TRUNC HOT 1
- help how to disable feature for example( bulk memory)? HOT 1
- Humble request from distro packagers to start releasing versions HOT 6
- poll() with timeout fails with "timer subscriptions only support monotonic timer" HOT 1
- dlmalloc has license incompatible with Fedora policies HOT 12
- Migrate build system to CMake HOT 4
- How to distribute `THREAD_MODEL=posix` builds? HOT 46
- Is it safe to have mixed sbrk and malloc calls? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wasi-libc.