Repository navigation
Open
Labels
Description
Description
In my project i use c++20 modules but with normal includes in the global fragment.
If i define a std::jthread anywhere in my class either it be a field or a local variable I get a final linking error.
/core.version.cppm.o C:/Users/MariusLaptop/Documents/Workspace/Proiecte/nodesforge/android/app/build/intermediates/cxx/Debug/4h1m5s3g/obj/arm64-v8a/libSDK.so C:/Users/MariusLaptop/Documents/Workspace/Proiecte/nodesforge/android/app/build/intermediates/cxx/Debug/4h1m5s3g/obj/arm64-v8a/libSDL3.so -latomic -lm && cd ."
ld.lld: error: undefined hidden symbol: std::__ndk1::__atomic_unique_lock<unsigned int, 2u>::__set_locked_bit[abi:ne210000]
>>> referenced by atomic_unique_lock.h:76 (C:/Users/MariusLaptop/AppData/Local/Android/Sdk/ndk/30.0.16248370/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/c++/v1/__stop_token/atomic_unique_lock.h:76)
>>> nodesforge_build/Core/CMakeFiles/Core.dir/src/services/job/core.services.job.cpp.o:(std::__ndk1::__atomic_unique_lock<unsigned int, 2u>::__lock[abi:ne210000]())
>>> referenced by atomic_unique_lock.h:76 (C:/Users/MariusLaptop/AppData/Local/Android/Sdk/ndk/30.0.16248370/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/c++/v1/__stop_token/atomic_unique_lock.h:76)
>>> nodesforge_build/Core/CMakeFiles/Core.dir/src/services/job/core.services.job.cpp.o:(std::__ndk1::__atomic_unique_lock<unsigned int, 2u>::__lock[abi:ne210000]())
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
This happened with my project using Emscripten too but it was magically fixed by updating to the latest version.
I tried to update the ndk too to ndkVersion = "30.0.16248370", but to no avail.
As a very quick workaround I changed the __set_locked_bit in atomic_unique_lock.h from a lambda to a normal function and the linkage error is gone. This is a very bad workaround from me but does the job since I won't deploy my app anywhere with Action.
Before:
_LIBCPP_HIDE_FROM_ABI static constexpr auto __set_locked_bit = [](_State __state) { return __state | _LockedBit; };
After:
_LIBCPP_HIDE_FROM_ABI static constexpr _State __set_locked_bit(_State __state) { return __state | _LockedBit; }
Upstream bug
No response
Commit to cherry-pick
No response
I am using a supported NDK
- I have checked and the NDK I'm using is currently supported
Affected versions
r30
Host OS
Windows
Host OS version
Windows 11
Affected ABIs
armeabi-v7a
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsMerged
Activity
Sharjeel-Khan commentedon Nov 2, 2026
This is a clang bug (llvm/llvm-project#172241). When a file includes
<thread>before importing a module that also includes<thread>in its global module fragment, clang drops that file's definition of__set_locked_bitand keeps only an undefined reference to it. Since the symbol is hidden, the link fails.The fix (llvm/llvm-project@6e1ab3a4310d) landed upstream already and it is included in r614150, which will be the compiler for r31. I tested a reproducer with r614150 and the linkage error is gone. I will try to cherrypick it back into r30's compiler (r574158) if possible. Until then, you can work around it by moving
#include <thread>after theimportstatements in files that import the module.If curious, the reproducer is below:
CMakeLists.txtCore/CMakeLists.txtCore/src/version/core.version.cppmCore/src/services/job/core.services.job.cppmCore/src/services/job/core.services.job.cppmain.cppCase 1: NDK r30 fails to link
arm64-v8afails the same way.Case 2: NDK r30 with a newer compiler
[patches] Cherry pick CLS for: Stop demote var definition as declaration
Sharjeel-Khan commentedon Dec 1, 2026
NDK r31 Beta 1 released today and includes the fix but I will not close this bug until r30b gets it also.