resibots/limbo

errors during compile Limbo " error: thread-local storage is not supported for the current target"

langongjin opened this issue · 10 comments

hi, I am compiling the Limbo following http://www.resibots.eu/limbo/tutorials/quick_start.html

./waf configure is successful with "'configure' finished successfully (0.323s)"
-------messages--------
./waf configure
WARNING: simplejson not found some function may not work
WARNING: brewer2mpl (colors) not found
YELLOW: Could not import plot_bo_benchmarks! Will not plot anything!
WARNING: simplejson not found some function may not work
Setting top to : /Users/lan/projects/bayesian/limbo-master
Setting out to : /Users/lan/projects/bayesian/limbo-master/build
Checking for 'clang++' (C++ compiler) : /usr/bin/clang++
Checking for 'clang' (C compiler) : /usr/bin/clang
Checking for compiler flags "-march=native" : yes
Checking boost includes : 1_65_1
Checking boost libs : ok
Checking for Eigen : /usr/local/include/eigen3
Checking Intel TBB includes (optional) : /usr/local/include
Checking Intel TBB libs (optional) : /usr/local/lib
Checking for compiler option to support OpenMP : Not supported
Checking Intel MKL includes (optional) : Not found
Checking for NLOpt C++ includes (optional) : /usr/local/include
Checking for NLOpt C++ libs (optional) : /usr/local/lib
Checking for libcmaes includes (optional) : /usr/local/include
Checking for libcmaes libs (optional) : /usr/local/lib
CXXFLAGS: ['-Wall', '-std=c++11', '-fdiagnostics-color', '-O3', '-g', '-march=native']

but, when I run ./waf build

I got these errors:
"/Users/lan/projects/bayesian/limbo-master/src/limbo/tools/random_generator.hpp:109:20: error: thread-local storage is not supported for the current target
static thread_local rgen_double_t rgen(0.0, 1.0);
^
/Users/lan/projects/bayesian/limbo-master/src/limbo/tools/random_generator.hpp:123:20: error: thread-local storage is not supported for the current target
static thread_local rgen_gauss_t rgen(0.0, 10.0);
^
/Users/lan/projects/bayesian/limbo-master/src/limbo/tools/random_generator.hpp:160:20: error: thread-local storage is not supported for the current target
static thread_local std::mt19937 rgen(randutils::auto_seed_128{}.base());"
How can I fix them. note that I use Mac OSX 10.10.5.
Thanks!

It looks like you are using an outdated version of clang that does not support C++11.

You could try to replace the '-std=c++11' in the wscript with -std=c++0x

If it does not work, you need to update your command-line-tools / xcode to a more recent version.

My version of clang is probably much more recent:

➜  ~ clang++ --version
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin17.4.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

@jbmouret perfect, Thanks! I am updating my xcode.

@jbmouret it is slow to update xcode, so I replace the '-std=c++11' with '-std=c++0x' in the wscript like :

if conf.env.CXX_NAME in ["icc", "icpc"]:
common_flags = "-Wall -std=c++0x"
#common_flags = "-Wall -std=c++11"
opt_flags = " -O3 -xHost -g"
native_flags = "-mtune=native -unroll -fma"
else:
if conf.env.CXX_NAME in ["gcc", "g++"] and int(conf.env['CC_VERSION'][0]+conf.env['CC_VERSION'][1]) < 47:
common_flags = "-Wall -std=c++0x"
else:
common_flags = "-Wall -std=c++0x"
#common_flags = "-Wall -std=c++11"

but the same problem is still there when I run ./waf build.
How can I do?

Thanks!

~ clang++ --version
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin14.5.0
Thread model: posix

@jbmouret hi, I think the problem is not the complier version. because I found my previous c++ program is working in c++ that set by "set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")" in the CMakeLists.txt. I try to make Limbo working in CMAKE, and it also have this problem in the CMAKE (I used Clion) project. Can you give me a hand? Thanks!

Hi, I already got this issue.

I solved it by installing a never version of Clang++ and forcing Cmake to use the right compiler.
(I found more info about updating clang here : WebAssembly/binaryen#1035)

To force Cmake to use the right compiler, simply add SET(CMAKE_CXX_COMPILER /usr/local/opt/llvm/bin/clang++) in your CmakeList (see my Cmakelist in your other issue).

Best,

@jbmouret @costashatz Maybe we should add this in our FAQ or something.

Let's first test your compiler. Can you copy-paste the following code into a file (e.g. test.cc):

#include <iostream>

int main() {
    thread_local int x = 42;
    std::cout << "hello world:" << x << std::endl;
}

Then compile using (in terminal):

clang++ -std=c++11 ./test.cc

If it does not work, then your compiler is too old. If not, then the problem is somewhere else.

Thanks all, it solved by updated my Mac system and Xcode. My clang++ was working for c++11, but maybe not good incompatible for "thread-local". I think the only thing need to do is update xcode (if there are some problem for update xcode, we have to update the Mac system first) if somebody have the same issue. Thanks all again!

Closing the issue.. @langongjin if you encounter something similar, feel free to re-open...