Static linkage against libstdc++ and lpthread leads to segmentation fault #13413
Unanswered
mitchgrout
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I've got a build setup which statically links against all dependencies, including
stdc++
andpthread
. I understand that this isn't exactly a good idea, but it's what I need. A minimal setup is:main.cxx:
meson.build:
meson setup build && ninja -C build
passes without issue, but running the resultingbuild/segfault
triggers a segmentation fault. The offending instruction is found inlibstdc++
code:Replacing
-pthread
with-Wl,--whole-archive -lpthread -Wl,--no-whole-archive
appears to fix this. My guess is that while-static-libstdc++
gives you a statically-linked libstdc++, that library is still dynamically linked withpthread
. However, in mymeson.build
I specifieddependency('threads', static: true)
, so presumably we should have a statically linkedpthread
too. Looking at thebuild.ninja
though, I have:...which means that
dependency('threads', static: true)
just translates to a plain-pthread
. Since this is for a niche project I can fix it by manipulating the link args, but I have to wonder whether there's anything that can be done in meson to help resolve this type of static linkage issue?Beta Was this translation helpful? Give feedback.
All reactions