Skip to content

Commit 351641b

Browse files
committed
Yet more work to reject old libstdc++
Sadly there isn't any standard way to detect this, but hopeully these hacks should suffice
1 parent adf1092 commit 351641b

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

timsort.hpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,37 @@
6262
# if defined(__cplusplus) && __cplusplus < 201103L
6363
# undef GFX_TIMSORT_USE_CXX11
6464
# endif
65-
# ifdef __GLIBCXX__
65+
# ifdef _GLIBCXX_RELEASE
66+
// This setting only got added in gcc 7.1, so its presence always
67+
// indicates a C++11-ready STL
68+
# elif defined(__GLIBCXX__)
69+
// Before 7.1, the only way to test the version of libstdc++ is the
70+
// __GLIBCXX__ date macro. However, it's not monotonically increasing
71+
// releases kepy being made from older branches. The best we can do is
72+
// to disallow any version that is definitely before gcc 5.1 (the first
73+
// version that had enough C++11 support for us) and then blacklist
74+
// dates that are known to correspond with non-working versions.
75+
//
76+
// Note this really only is a problem when mixing compilers and STL (i.e.
77+
// compiling using clang but using gcc's libstdc++) Otherwise we'll
78+
// correctly reject the gcc compiler if its too old later.
6679
# if __GLIBCXX__ < 20150422
6780
# undef GFX_TIMSORT_USE_CXX11
6881
# endif
82+
# if __GLIBCXX__ == 20150426
83+
# undef GFX_TIMSORT_USE_CXX11 // gcc 4.8.4+patches shipped with Ubuntu LTS 14.04
84+
# endif
85+
# if __GLIBCXX__ == 20150623
86+
# undef GFX_TIMSORT_USE_CXX11 // gcc 4.8.5
87+
# endif
88+
# if __GLIBCXX__ == 20150626
89+
# undef GFX_TIMSORT_USE_CXX11 // gcc 4.9.3
90+
# endif
91+
# if __GLIBCXX__ == 20160803
92+
# undef GFX_TIMSORT_USE_CXX11 // gcc 4.9.5
93+
# endif
94+
# elif defined(__GLIBCPP__) // *really* old version of libstdc++
95+
# undef GFX_TIMSORT_USE_CXX11
6996
# endif
7097
# ifdef _LIBCPP_VERSION
7198
# if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) || defined(_LIBCPP_CXX03_LANG)

0 commit comments

Comments
 (0)