-
Notifications
You must be signed in to change notification settings - Fork 30.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build: Allow to use atomic builtins from compiler-rt instead of libatomic #54306
base: main
Are you sure you want to change the base?
Conversation
Review requested:
|
This has broken the GitHub actions Linux workflows, which use clang. |
Error is 2024-08-11T07:08:51.3573153Z node.cc:(.text+0x2bed): undefined reference to
__atomic_is_lock_free'`
e5b90cd
to
fe84924
Compare
I see. I can't reproduce this error locally, perhaps it's either:
I will get back to you once I figure out. |
Any progress on this PR? |
It seems unlikely. We found recently that newer V8 versions require it for |
I do keep trying to explain this to people on our end. You can't be sure that the compiler won't emit a libcall that We removed it a few times and had reports for some, but not all, users of the Clang case, and the GCC case is obvious. So yes, the status quo is correct (or more correct than dropping it). |
What could be accepted more easily is a new |
microsoft/mimalloc#898 |
I could build latest nodejs(98788da) with llvm-18.1.8 successfully. |
Anyway, LLVM has implemented __atomic_compare_exchange years ago. |
Does gyp have ability to find optional dependencies like CMake's check_linker_flag? |
First of all, I'm sorry for the late follow-up.
Just for clarity The reason why the CI is red and what I overlooked when submitting the PR is the fact that clang on the most of Linux distros is going to pick up libgcc_s as a runtime library, unless you suppress that with What would have a chance of working would be not requiring
...I'm happy to hear that and I totally agree that would be the best approach! I will do it in this PR. Would you be also open to having a CI job checking the clang+compiler-rt configuration (which would disable latomic), just to make sure things don't regress? I could try to use the docker.io/gentoo/stage3:musl-llvm image to add a job similar to this one: node/.github/workflows/test-linux.yml Lines 35 to 56 in accb239
Are you referring to https://bugs.gentoo.org/870919? |
There's https://bugs.gentoo.org/869992#c4 and so on too. All of the reports are with Clang versions later than the one which added support. I think someone who cares about such setups needs to investigate it, but the explanation being offered isn't sufficient at least. |
OK, coming back to this, I think it'd work to have such a check if it's possible in gyp. |
I assume the problem reported on Gentoo is caused by the user's environment setup, not nodejs. |
I don't think that concurs with @vadorovsky's analysis at https://bugs.gentoo.org/911340#c5. |
9b66338
to
8f333e4
Compare
-latomic
for clang…omic compiler-rt, when it's built with the `COMPILER_RT_EXCLUDE_ATOMIC_BUILTIN` option disabled, provides all atomic builtins and serves as a full replacement for libatomic. By default, that option is enabled[0], meaning that default builds of compiler-rt, followed by the most of Linux distributions (Fedora, openSUSE, Ubuntu), do **not** provide all necessary atomics. However, FreeBSD[1] and Gentoo (with LLVM-based profiles)[2] disable it, therefore providing compiler-rt with atomic builtins. That difference can be detected by checking the symbol table of compiler-rt: ``` nm $(clang -print-libgcc-file-name) | grep __atomic ``` No matching symbols indicate lack of atomic builtins and necessity of linking libatomic. Matching symbols indicate a possibility to not link libatomic. Given that difference, provide the `--use-compiler-rt-atomics` option in `configure.py`. When enabled, the configure script checks whether compiler-rt provides atomics and, if yes, does not link libatomic. By default, without that option enabled, a build with clang links libatomic. For more context, see the discussion on Gentoo bugzilla[3]. [0] https://github.com/llvm/llvm-project/blob/llvmorg-19.1.6/compiler-rt/lib/builtins/CMakeLists.txt#L227-L229 [1] https://cgit.freebsd.org/src/commit/?id=7b67d47c70cca47f65fbbc9d8607b7516c2a82ee [2] gentoo/gentoo@63b4ae7 [3] https://bugs.gentoo.org/911340
8f333e4
to
8d11b22
Compare
@targos @thesamesam First of all, sorry for very late follow up! I went ahead with adding a configure option, which also performs a check whether compiler-rt really supports atomics. I also added more context and linked to the Gentoo bug, where we were figuring out how and under what circumstances compiler-rt doesn't need libatomic and came up with the solution proposed her. I'm still thinking how to test that in CI. I was considering using the docker.io/gentoo/stage3:musl-llvm container image. If you agree with that solution, I can do that. |
compiler-rt, when it's built with the
COMPILER_RT_EXCLUDE_ATOMIC_BUILTIN
option disabled, provides all atomic builtins and serves as a full replacement for libatomic.By default, that option is enabled[0], meaning that default builds of compiler-rt, followed by the most of Linux distributions (Fedora, openSUSE, Ubuntu), do not provide all necessary atomics.
However, FreeBSD[1] and Gentoo (with LLVM-based profiles)[2] disable it, therefore providing compiler-rt with atomic builtins.
That difference can be detected by checking the symbol table of compiler-rt:
No matching symbols indicate lack of atomic builtins and necessity of linking libatomic. Matching symbols indicate a possibility to not link libatomic.
Given that difference, provide the
--use-compiler-rt-atomics
option inconfigure.py
. When enabled, the configure script checks whether compiler-rt provides atomics and, if yes, does not link libatomic. By default, without that option enabled, a build with clang links libatomic.For more context, see the discussion on Gentoo bugzilla[3].
[0] https://github.com/llvm/llvm-project/blob/llvmorg-19.1.6/compiler-rt/lib/builtins/CMakeLists.txt#L227-L229
[1] https://cgit.freebsd.org/src/commit/?id=7b67d47c70cca47f65fbbc9d8607b7516c2a82ee
[2] gentoo/gentoo@63b4ae7
[3] https://bugs.gentoo.org/911340