sunfishcode / c-ward

An implementation of libc written in Rust
Other
183 stars 11 forks source link

`coexist-with-libc` mode has dubious value #130

Open carbotaniuman opened 2 months ago

carbotaniuman commented 2 months ago

The coexist-with-libc mode seems dubious for the vast majority of functions - anything that touches a shared header or struct (say, FILE or pthread_mutex_t) is likely to run into severe issues if it is used as a parameter in a function we do not implement.

In addition, it also seems not useful for the actual use cases this library supports - llvm-libc's version which replaces only the functions without shared structs (say FD functions or string functions) is only really useful because it's in C, Rust code likely uses its own.

sunfishcode commented 2 months ago

coexist-with-libc mode already excludes all the pthread_* functions, because as you say, that's a known incompatibility. It doesn't currently exclude FILE functions, but I agree, that's a bug.

The original reason the mode exists is that it's sometimes handy for testing and debugging. In theory it might enable LTO inlining of libc functions for someone who doesn't want to use take-charge mode. But, I don't have a clear picture at this point of who's interested in using c-scape/c-gull for what, so I don't really know.

sunfishcode commented 2 months ago

The FILE issue is fixed in https://github.com/sunfishcode/c-ward/pull/131.