-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
zig c++ fails to compile for x86_64-linux-gnu: "Undefined symbol: __cxa_thread_atexit_impl" #9412
Comments
set your target to be |
I am intentionally targeting 2.17. This project builds (without zig) on CentOS 7, which has glibc 2.17. The main reason I am interested in compiling with zig in the first place is to avoid having to install a CentOS VM for building this project. |
then you have to backport the function from glibc 2.18
|
My understanding is that libcxxabi is supposed to polyfill this function for lower glibc versions, by having a backup implementation in case no actual __cxa_thread_atexit_impl function is found. But the polyfill seems to assume that the Backporting the function doesn't seem like it should be necessary if the polyfill could work as expected. |
https://bugs.chromium.org/p/chromium/issues/detail?id=749077 seems very related |
I ran into the same issue. In my case I didn't really care what version of glibc was used, I just want it to work. I was cross compiling amd64 -> arm64, so it was defaulting to glibc 2.17. When I explicitly used I realize the original issue wants to use glibc 2.17 explicitly, just noting that it can be worked around by explicitly using 2.18 (or higher, I assume?) |
I got the same issue, albeit with the musl target:
Minimal example to reproduce: #include <thread>
#include <iostream>
struct yeah { ~yeah() { std::cout << "destruct thread local\n"; } };
thread_local yeah x;
int main() { std::thread{ []() { std::cout << "hello\n"; } }.join(); } The above solution does work for glibc. However, is there also a solution for the musl target? |
I've noticed that the build of libcxxabi on my system always reports |
I'm attempting to build a .NET NativeAOT project using
zig c++ -target x86_linux-gnu
as the system compiler/linker, so that it can build with a low glibc (2.17) instead of my Linux machine's actual libc. So far it seems to be working surprisingly well, but there is one build error that I'm not sure how to properly fix:I was able to work around this by #undef'ing
HAVE___CXA_THREAD_ATEXIT_IMPL
in cxa_thread_atexit.cpp and then removing lines 115-117, but that seems like a terrible hack.I'm not sure why HAVE__CXA_THREAD_ATEXIT_IMPL is getting defined in the first place, since the targeted glibc doesn't support it. But even if it's not defined, it still tries to use the dynamic
__weak__
linkage for the function, which is (apparently?) not supported by clang, so it fails anyway.The text was updated successfully, but these errors were encountered: