On Wed, Aug 2, 2017 at 12:24 PM Marcus Calhoun-Lopez <mcalh...@macports.org> wrote: > > The file > ${prefix}/include/gcc6/c++/${build_arch}-apple-darwin${os.major}/bits/c++config.h > has different values for _GLIBCXX_HAVE_TLS on different platforms. > For ${os.major} < 15, _GLIBCXX_HAVE_TLS is defined as 1. > For ${os.major} >= 15, _GLIBCXX_HAVE_TLS is undefined. > I am not sure why the availability of thread-local storage changed, > but for consistency, should --disable-tls be added to the GCC > configure script (see https://gcc.gnu.org/install/configure.html)? > > The reason I bring this up is that the following code works macOS > Sierra and OS X El Capitan: > ------------------------------------------------------------------------------------------------------------------------------ > clang++-mp-4.0 -std=c++11 -stdlib=macports-libstdc++ future.cxx > ------------------------------------------------------------------------------------------------------------------------------ > #include <iostream> > #include <future> > > int main() > { > std::future<int> f1 = std::async([](){ return 42; }); > f1.wait(); > std::cout << "Magic number is: " << f1.get() << std::endl; > } > ------------------------------------------------------------------------------------------------------------------------------ > > It does *not* work for OS versions prior to El Capitan with the error: > ------------------------------------------------------------------------------------------------------------------------------ > Undefined symbols for architecture x86_64: > "std::__once_call", referenced from: > void std::call_once<void > (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, > std::__future_base::_Result_base::_Deleter> ()>*, bool*), > std::__future_base::_State_baseV2*, > std::function<std::unique_ptr<std::__future_base::_Result_base, > std::__future_base::_Result_base::_Deleter> ()>*, > bool*>(std::once_flag&, void > (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, > std::__future_base::_Result_base::_Deleter> ()>*, bool*), > std::__future_base::_State_baseV2*&&, > std::function<std::unique_ptr<std::__future_base::_Result_base, > std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&) in > future-b039c9.o > ------------------------------------------------------------------------------------------------------------------------------ > clang++-mp-4.0 -std=c++11 -stdlib=macports-libstdc++ -femulated-tls > future.cxx > ------------------------------------------------------------------------------------------------------------------------------ > compiles fine but experiences a segmentation fault at runtime. > > When I build GCC with --disable-tls, everything works on all platforms. > > I realize that -stdlib=macports-libstdc++ is a highly unsupported > configuration, but --disable-tls would not seem to affect newer OSs. > > Does anyone have any insight into this? > Does anyone have any objections to adding --disable-tls? > > Thanks, > Marcus
Hi, could you open a bug upstream with GCC about this? One of the upstream GCC devs is wondering why MacPorts needs this configure flag, so if they had a bug report to work with, they could probably fix whatever is requiring MacPorts to use that flag.