domenkozar · 63 points · 22 comments · 17 ชั่วโมงที่ผ่านมา · Open original
Comments
5 preview comments · loading full thread
Log in to use comments
Log in to h4cker, then connect Hacker News to publish comments.
HEhechang199716 นาทีที่ผ่านมา
Check this out: https://github.com/IntegralPilot/rustc_codegen_jvm
While this cannot compile C/C++, it can serve as a fil-C alternative for unsafe pure rust code.
https://news.ycombinator.com/item?id=49284966
PAPanzerschrek6 ชั่วโมงที่ผ่านมา
Extern "fil-C" can't be compatible with Rust code or something similar. It requires a metadata block attached to each allocation. So, if a memory block has been allocated in Rust and a pointer to it is passed to a fil-C function, it can't access it correctly. The only way to allow such cross-langauge-and-abi calls is to compile Rust code itself like fil-C, which requires doubled memory consumption, expensive runtime checks and GC overhead.
ANandai9 ชั่วโมงที่ผ่านมา
Why isn't fil-C ABI compatible with C?
https://fil-c.org/runtime
Apparently this was done intentionally. The rationale given is that we don't want to allow non-safe C to be used in fil-C programs. Fair enough.
But why should we prevent fil-C programs to be used from Rust (or C, for that matter)?
I don't understand much about compilers, but I guess allowing one would also allow the other? i.e. it's not possible to make fil-C ABI compatible with C (so that it can be more easily called), while also not letting you use call C from it?
POpornel9 ชั่วโมงที่ผ่านมา
There is a solution that Mozilla uses in prod for legacy C codecs:
https://rlbox.dev/
It's not a replacement for Fil-C's role as a precise ASAN/Valgrind, but it works great if you want to call a C library without letting it freely spray caller's memory.
KAKateLawson7 ชั่วโมงที่ผ่านมา
Any reason why you don't use clang's `-fbounds-safety`? It offers ABI compatibility and incremental adoption. The author of Fil-C worked on it also :-)
https://clang.llvm.org/docs/BoundsSafety.html#overview
Comments
5 preview comments · loading full threadLog in to h4cker, then connect Hacker News to publish comments.
Check this out: https://github.com/IntegralPilot/rustc_codegen_jvm While this cannot compile C/C++, it can serve as a fil-C alternative for unsafe pure rust code. https://news.ycombinator.com/item?id=49284966
Extern "fil-C" can't be compatible with Rust code or something similar. It requires a metadata block attached to each allocation. So, if a memory block has been allocated in Rust and a pointer to it is passed to a fil-C function, it can't access it correctly. The only way to allow such cross-langauge-and-abi calls is to compile Rust code itself like fil-C, which requires doubled memory consumption, expensive runtime checks and GC overhead.
Why isn't fil-C ABI compatible with C? https://fil-c.org/runtime Apparently this was done intentionally. The rationale given is that we don't want to allow non-safe C to be used in fil-C programs. Fair enough. But why should we prevent fil-C programs to be used from Rust (or C, for that matter)? I don't understand much about compilers, but I guess allowing one would also allow the other? i.e. it's not possible to make fil-C ABI compatible with C (so that it can be more easily called), while also not letting you use call C from it?
There is a solution that Mozilla uses in prod for legacy C codecs: https://rlbox.dev/ It's not a replacement for Fil-C's role as a precise ASAN/Valgrind, but it works great if you want to call a C library without letting it freely spray caller's memory.
Any reason why you don't use clang's `-fbounds-safety`? It offers ABI compatibility and incremental adoption. The author of Fil-C worked on it also :-) https://clang.llvm.org/docs/BoundsSafety.html#overview