RISCV glibc has decided to use 64bit time_t from get go unlike
other 32bit architecture, therefore, aliasing NR_futex to
NR_futex_time64 helps avoid the below errors on rv32
Details
- Reviewers
asb raj.khem luismarques - Group Reviewers
Restricted Project - Commits
- rG85b9c5ccc172: [libc++] Fix libcxx build on 32bit architectures with 64bit time_t defaults e.g.
Diff Detail
Event Timeline
libcxx/src/atomic.cpp | ||
---|---|---|
18 | I'm not sure I understand -- libc++ doesn't use __NR_futex anywhere. Can you explain how this fix works? |
libcxx/src/atomic.cpp | ||
---|---|---|
18 | libc++ does use SYS_futex, which it expects from system C library, in glibc (/usr/include/bits/syscall.h defines it in terms of of NR_futex) rv32 is using 64bit time_t from get go unlike other 32bit architectures in glibc, therefore it wont have NR_futex defined but just NR_futex_time64, this aliases it to NR_futex so that SYS_futex is then defined for rv32 |
I think this makes sense, but I'll let the #libc reviewers actually review/approve this.
libcxx/src/atomic.cpp | ||
---|---|---|
18 | I suggest adding a comment here describing this situation. |
Can you clarify on the errors you are talking about? Are you building LLVM libc++with glibc?
I have been building LLVM libc++ with MUSl and I do not see a build issue.
I suppose that an alternative to this implementation might be to tweak the place of use of __NR_futex, like is done in [1]. Arguably that's cleaner. Or, in the place where you're currently checking for riscv32, check for the case where __NR_futex_ isn't defined but __NR_futex_time64 is, and #define the former in terms of the latter.
[1]: https://sourceware.org/legacy-ml/libc-alpha/2020-01/msg00686.html
I don't understand why this has its place in libc++. Shouldn't this be in glibc instead?
SYS_futex is not a universal syscall name for all architectures as explained in the comment, and libc++ is assuming that incorrectly. hope that helps
LGTM.
I think the current target-independent implementation of the patch really is the way to go, so this now looks even better. Thanks!
I'm not sure I understand -- libc++ doesn't use __NR_futex anywhere. Can you explain how this fix works?