[MacPorts] #52585: libcxxabi -- attempts to add thread-local-storage (TLS) to <10.9
MacPorts
noreply at macports.org
Sat Feb 17 05:35:05 UTC 2018
#52585: libcxxabi -- attempts to add thread-local-storage (TLS) to <10.9
------------------------------------+--------------------------------
Reporter: ken-cunningham-webuse | Owner: macports-tickets@…
Type: defect | Status: new
Priority: Normal | Milestone:
Component: ports | Version: 2.3.4
Resolution: | Keywords:
Port: libcxxabi |
------------------------------------+--------------------------------
Comment (by kencu):
I think we have this fixed now. Some modifications to clang-5.0 appear to
have done the trick, and the thread_local stuff looks like it's working on
10.6.8 now (should also work on 10.4 and 10.5):
{{{
$ clang++ --version
clang version 5.0.1 (tags/RELEASE_501/final)
Target: x86_64-apple-darwin10.8.0
Thread model: posix
InstalledDir: /opt/local/libexec/llvm-5.0/bin
}}}
{{{
$ cat thread.cpp
#include <iostream>
#include <string>
#include <thread>
#include <mutex>
thread_local unsigned int rage = 1;
std::mutex cout_mutex;
void increase_rage(const std::string& thread_name)
{
++rage; // modifying outside a lock is okay; this is a thread-local
variable
std::lock_guard<std::mutex> lock(cout_mutex);
std::cout << "Rage counter for " << thread_name << ": " << rage <<
'\n';
}
int main()
{
std::thread a(increase_rage, "a"), b(increase_rage, "b");
{
std::lock_guard<std::mutex> lock(cout_mutex);
std::cout << "Rage counter for main: " << rage << '\n';
}
a.join();
b.join();
}
}}}
{{{
$ clang++ -std=c++11 -o thread thread.cpp
}}}
{{{
$ ./thread
Rage counter for main: 1
Rage counter for a: 2
Rage counter for b: 2
}}}
--
Ticket URL: <https://trac.macports.org/ticket/52585#comment:6>
MacPorts <https://www.macports.org/>
Ports system for macOS
More information about the macports-tickets
mailing list