libsys: avoid depending on libc _once() Use the atomics and _umtx_op(2) directly. libsys: link internal copies of fls*(3), str*(3), and mem*(3) functions used by libsys To avoid undef symbols which get resolved from libc. libsys: this is libsys, not libc libsys: do not link in csu, and compile as freestanding This is a library below implementation of the C runtime. It should not (and really cannot) use any of that. In particular, libsys no longer has undef __cxa_finalize.
Details
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Skipped - Unit
Tests Skipped
Event Timeline
I generally like these changes, but have a small worry about memcpy. I can fix that up as part of upstreaming if needed.
| lib/libsys/memcpy.c | ||
|---|---|---|
| 5 | I think this is ok for now given the two explicit uses of memcpy today, but there's a risk of confusing bugs on CHERI targets if memcpy doesn't copy pointer sized and aligned blocks of data using intptr_t. In libsys, it's probably sufficient to only support copying via intptr_t when all arguments are at least sizeof(intptr_t) aligned. | |
I don't think I understand what's wrong with the plain C versions of the string functions in libc?
Otherwise this looks ok, thanks for taking this up. I'll defer landing my libsys_private.h patch until after this series (and drop the remaining use of libc_private.h in it).
I do not want to recreate the libc compilation environment, in particular, to handle set of preprocessor symbols needed for e.g. memcpy etc to actually provide memcpy. It is simpler to make libsys self-contained and not add a dependency.
I admit that I was lazy and several functions that are currently self-contained right now, are reused.
rtld-libc and libsa seem to not have much issue getting the plain C versions to compile in their self-contained environments. I would much rather not have yet more memcpy etc implementations in the tree.
There's also libkern's if that's more amenable to being reused.
To avoid bringing in libc implementation that fetches more that is
acceptable for libsys.
Commit message for this part of the patch is stale
| lib/libsys/Makefile | ||
|---|---|---|
| 43 | stp... sorts before str... alphabetically | |
| lib/libsys/tests/Makefile | ||
| 2 | These files aren't particularly interesting but maybe worth chucking a SPDX header on them for the avoidance of any doubt? | |
| 13 | Does a plain -lsys not work for some reason? | |
Handle reviewer's comments.
Add flsll unconditionally, used on 32bit platforms.
This passes tinderbox.