Page MenuHomePhabricator

[cmake] Add a big warning about a libstdc++ issue
ClosedPublic

Authored by labath on May 26 2016, 3:11 AM.

Details

Summary

Recent increase in the usage of std::weak_ptr has caused us to rediscover an issue in libstdc++
versions prior to 4.9 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59656, which make this class
unusable without exceptions in the presence of multiple threads. It's virtualy impossible to work
around this issue without implementing our own shared_ptr/weak_ptr substitutes, which does not
seem like a good idea.

Therefore, I am adding a big CMake warning which warns you about this issue if you're attempting
a to do a build which is suceptible to this problem and suggests possible alternatives. Right
now, nothing spectacular will happen if you ignore this warning (all the crashes I have seen
occur during process shutdown), but there's no guarantee the situation will not change in the
future.

Event Timeline

labath updated this revision to Diff 58584.May 26 2016, 3:11 AM
labath retitled this revision from to [cmake] Add a big warning about a libstdc++ issue.
labath updated this object.
labath added a subscriber: lldb-commits.

I am adding everyone I think could be susceptible to this problem. It would be a good idea to check if you are still using libstdc++4.8 or older.

krytarowski edited edge metadata.May 26 2016, 4:42 AM

NetBSD is using newer libstdc++.

#include <set>
std::set<int> s = std::set<int>(std::allocator<int>());
int main() { return 0; }

Compiles (I need to specify the -std=c++11 option) and runs.

I will try it out in the context of LLDB CMake scripts.

emaste edited edge metadata.May 26 2016, 5:34 AM

FreeBSD 10.0 and later uses libc++. FreeBSD 9 has a very old libstdc++ and a very old gcc and can't build Clang 3.5 or later with the system compiler anyway. So this isn't a problem for FreeBSD.

I don't know cmake well enough to approve the change but the idea definitely sounds good to me.

tberghammer accepted this revision.May 26 2016, 7:31 AM
tberghammer edited edge metadata.

looks good

cmake/modules/LLDBConfig.cmake
432 ↗(On Diff #58584)

(nit): "be using linking to libstdc++"

This revision is now accepted and ready to land.May 26 2016, 7:31 AM

Wondering if this should go in llvm. What do you think?

Wondering if this should go in llvm. What do you think?

I don't see any uses of weak_ptr in the llvm repository, so this issue should only affect lldb, I think.

Ok, lgtm then

This revision was automatically updated to reflect the committed changes.