-
Notifications
You must be signed in to change notification settings - Fork 274
Remove -latomic
from -pthread
spec
#337
Comments
-pthread
spec-latomic
from -pthread
spec
In practice, it fixes the build for a large number of packages. People love to write programs with I can understand your point, but it would create massive headaches. |
BTW, I know some people have discussed open-coding/inlining the subword atomics so that libatomic is no longer needed. We can obviously make your proposed change after that work is performed. |
Actually this workaround itself is causing headaches now. Since |
Also, we can't just force |
This confusing behavior is also upsetting our efforts to port packages to RISC-V architecture in the correct way of adding detections for |
This is no doubt the best solution. But as for now, the problem is spreading along with the popularity of glibc 2.34. Removal of this confusing behavior will be a strong support for us to convince upstream authors to accept our porting patch. |
FYI, this can be a possible example of headache: telegramdesktop/tdesktop#24275 |
Also note that CMake reverted their workaround (see: Kitware/CMake@c6da90b) on this because "the |
@XieJiSS’s example hits home. I’m not the decision-maker here, but I think changing this behavior without inlining the atomics would be the worst of both worlds: we would end up with two broken universes, instead of just one. To make forward progress, it would be best to accelerate the effort to open-code the atomics. |
I'm curious about why this line is replaced by This commit is from #12. Why someone changed the spec to only link against |
IIRC this is because pthread needs subword atomic support, and in general pthread is used in a lot of projects. This solved a large number of issues (but not all). This is probably the most annoying thing in RISC-V as this tends to break packages randomly. There is patch for GCC from Rivos Inc. (Mar 11, 2022): [PATCH v2] RISCV: Add support for inlining subword atomics See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104338 There is probably another 3-4 GCC bugzilla ticket over the last several years about this (or similar issues). |
Hi David, I also think that the reason they added I already declared Currently, I'm struggling to find a piece of test code which uses only pthread functions, without making any progress. I also reviewed some projects in which I used to fix the David, do you have further information on this (like the code that made the gcc guys believe libatomic is necessary for libpthread)? This will help a lot, as we might be able to use that to persuade upstream util/toolchain projects like CMake to update their pthread detection code. Thanks! |
This is definitely one of the best news I've heard about in this year :-D |
We may still need some workaround for existed projects since the patches are not released yet 🤔 Also, the patch was sent too late, glibc 2.34+ is already causing problems. |
This is really good and exciting, the rest will be left to time. |
Oh, I just realized that maybe they should change values of related macros like I'll send a email to the mailing list regarding this, but I think it might be better to leave a comment here for reference. |
All of these are lock-free, both under the current regime and the proposed new one. They’re all LR/SC-based, regardless, and such sequences don’t constitute locking. |
Yes, I agree that both implementation are lock-free, but according to #15:
So it is returning |
Note that the patch has support for atomic fetch only so far. Atomic store and exchange are still missing, without them it doesn't actually solve the libatomic problem yet. |
I think linking against libatomic as needed by default for all situation is quite a reasonable option. It was the workaround for #12, but I just couldn't understand why someone limited this behavior to |
Also, the spec change is a lot simpler than opem-coding, which is more likely to be released earlier. I think we can change the spec while waiting for the development of the patch. |
FYI It's too late to make such change to GCC 12 (which probably will be release within weeks). Thus the most likely candidate would be the next GCC version in 2023. |
This is best talked about on the GCC mailing lists and bugzilla. There's some ABI fallout from changing the defaults we need to sort out, it should all be mentioned in the bugs already. |
https://github.com/riscv-collab/riscv-gcc/blob/ca312387ab141060c20c388d83d6fc4b2099af1d/gcc/config/riscv/linux.h#L43
Is it really necessary to link against
libatomic
for pthread to function correctly? Is there any direct relation like a symbol reference?I doubt it because since glibc 2.34, libpthread is removed as a separate library and I found that a program which only utilize
pthread_*()
orstd::thread
actually works without-pthread
, i.e. it works withoutlibatomic
.Also, according to gcc/libstdc++/using concurrency, the use of
atomic
should be checked if it needs to be linked againstlibatomic
. If there is no direct relation between the two libs, we'd better not link againstlibatomic
when-pthread
is present. The checks and link operations should be done/generated by user at build system level on user's discretion.The text was updated successfully, but these errors were encountered: