New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to build for iOS using Xcode 9.3: thread-local storage is not supported for the current target #18356

Open
sadlerjw opened this Issue Apr 9, 2018 · 8 comments

Comments

Projects
None yet
8 participants
@sadlerjw
Contributor

sadlerjw commented Apr 9, 2018

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): no
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): macOS High Sierra 10.13.3
  • TensorFlow installed from (source or binary): source
  • TensorFlow version (use command below): 1.6.0
  • Python version: 2.7.14
  • Bazel version (if compiling from source): 0.9.0
  • GCC/Compiler version (if compiling from source): Xcode 9.3: Apple LLVM version 9.1.0 (clang-902.0.39.1)
  • CUDA/cuDNN version: n/a
  • GPU model and memory: n/a
  • Exact command to reproduce: tensorflow/contrib/makefile/build_all_ios.sh -g /path/to/model.pb

Describe the problem

As of Xcode 9.3 (was working fine on 9.2), compiling TF for iOS using build_all_ios.sh fails, complaining that "thread-local storage is not supported for the current target". This is related to #12573, which introduced the thread_local attribute for iOS builds.

Source code / logs

$ tensorflow/contrib/makefile/build_all_ios.sh -g /path/to/model.pb
[...]
gcc --std=c++11 -DIS_SLIM_BUILD -fno-exceptions -DNDEBUG -O3 -DANDROID_TYPES=__ANDROID_TYPES_FULL__ -DSELECTIVE_REGISTRATION -DSUPPORT_SELECTIVE_REGISTRATION -mios-simulator-version-min=9.0 -arch i386 -mno-sse -fembed-bitcode -D__thread=thread_local -DUSE_GEMM_FOR_CONV -Wno-c++11-narrowing -DTF_LEAN_BINARY -D__ANDROID_TYPES_FULL__ -fno-exceptions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.3.sdk -MT /Users/json/everalbum/ios-sdk/submodules/tensorflow/tensorflow/contrib/makefile/gen/obj/ios_I386/tensorflow/core/common_runtime/local_device.o -MMD -MP -MF /Users/json/everalbum/ios-sdk/submodules/tensorflow/tensorflow/contrib/makefile/gen/dep/ios_I386//tensorflow/core/common_runtime/local_device.Td -I. -I/Users/json/everalbum/ios-sdk/submodules/tensorflow/tensorflow/contrib/makefile/downloads/ -I/Users/json/everalbum/ios-sdk/submodules/tensorflow/tensorflow/contrib/makefile/downloads/eigen -I/Users/json/everalbum/ios-sdk/submodules/tensorflow/tensorflow/contrib/makefile/downloads/gemmlowp -I/Users/json/everalbum/ios-sdk/submodules/tensorflow/tensorflow/contrib/makefile/downloads/nsync/public -I/Users/json/everalbum/ios-sdk/submodules/tensorflow/tensorflow/contrib/makefile/downloads/fft2d -I/Users/json/everalbum/ios-sdk/submodules/tensorflow/tensorflow/contrib/makefile/gen/proto/ -I/Users/json/everalbum/ios-sdk/submodules/tensorflow/tensorflow/contrib/makefile/gen/proto_text/ -I/Users/json/everalbum/ios-sdk/submodules/tensorflow/tensorflow/contrib/makefile/gen/protobuf-host/include -I/usr/local/include -c tensorflow/core/common_runtime/local_device.cc -o /Users/json/everalbum/ios-sdk/submodules/tensorflow/tensorflow/contrib/makefile/gen/obj/ios_I386/tensorflow/core/common_runtime/local_device.o
In file included from tensorflow/core/common_runtime/local_device.cc:18:
In file included from ./tensorflow/core/common_runtime/local_device.h:19:
In file included from ./tensorflow/core/common_runtime/device.h:35:
In file included from ./tensorflow/core/framework/allocator.h:23:
In file included from ./tensorflow/core/framework/numeric_types.h:21:
In file included from ./third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1:
In file included from /Users/json/everalbum/ios-sdk/submodules/tensorflow/tensorflow/contrib/makefile/downloads/eigen/unsupported/Eigen/CXX11/Tensor:79:
In file included from /Users/json/everalbum/ios-sdk/submodules/tensorflow/tensorflow/contrib/makefile/downloads/eigen/unsupported/Eigen/CXX11/ThreadPool:58:
/Users/json/everalbum/ios-sdk/submodules/tensorflow/tensorflow/contrib/makefile/downloads/eigen/unsupported/Eigen/CXX11/src/ThreadPool/SimpleThreadPool.h:153:5: error:
      thread-local storage is not supported for the current target
    EIGEN_THREAD_LOCAL PerThread per_thread;
    ^
/Users/json/everalbum/ios-sdk/submodules/tensorflow/tensorflow/contrib/makefile/downloads/eigen/unsupported/Eigen/CXX11/src/ThreadPool/ThreadLocal.h:15:35: note:
      expanded from macro 'EIGEN_THREAD_LOCAL'
#define EIGEN_THREAD_LOCAL static __thread
                                  ^
<command line>:6:18: note: expanded from here
#define __thread thread_local
@jart

This comment has been minimized.

Show comment
Hide comment
@jart

jart Apr 10, 2018

Member

@petewarden here's an iOS build issue potentially related to a change you made.

Member

jart commented Apr 10, 2018

@petewarden here's an iOS build issue potentially related to a change you made.

@sadlerjw sadlerjw changed the title from Failed to build for iOS using Xcode 9: thread-local storage is not supported for the current target to Failed to build for iOS using Xcode 9.3: thread-local storage is not supported for the current target Apr 10, 2018

@sadlerjw

This comment has been minimized.

Show comment
Hide comment
@sadlerjw

sadlerjw Apr 10, 2018

Contributor

I changed -D__thread=thread_local \ to -D__thread= \ in tensorflow/contrib/makefile/Makefile (for the i386 architecture only) and that's an okay workaround for now. It (probably) re-introduces the problem that #12573 solved for that architecture, but at least for my use that's acceptable until this gets a proper solution.

Contributor

sadlerjw commented Apr 10, 2018

I changed -D__thread=thread_local \ to -D__thread= \ in tensorflow/contrib/makefile/Makefile (for the i386 architecture only) and that's an okay workaround for now. It (probably) re-introduces the problem that #12573 solved for that architecture, but at least for my use that's acceptable until this gets a proper solution.

@tomergafner

This comment has been minimized.

Show comment
Hide comment
@tomergafner

tomergafner Apr 30, 2018

Contributor

+1
Any update on this ?

Contributor

tomergafner commented Apr 30, 2018

+1
Any update on this ?

tomergafner added a commit to ButterflyNetwork/tensorflow that referenced this issue Apr 30, 2018

@japer21

This comment has been minimized.

Show comment
Hide comment
@japer21

japer21 Jul 6, 2018

@sadlerjw I am working on Mac sierra 10.13.5 (17F77) , and what I did is here:
checked out tensorflow 1.9.0-rc1
did export ANDROID_TYPES="-D__ANDROID_TYPES_FULL__"
and then launched the script tensorflow/contrib/makefile/buils_all_ios.sh .

On building stage for the arch i386 I got the error:

tensorflow/tensorflow/contrib/makefile/downloads/eigen/unsupported/Eigen/CXX11/src/ThreadPool/SimpleThreadPool.h:153:5: error: 
      thread-local storage is not supported for the current target
    EIGEN_THREAD_LOCAL PerThread per_thread;
    ^
/pj/tensorflow/tensorflow/contrib/makefile/downloads/eigen/unsupported/Eigen/CXX11/src/ThreadPool/ThreadLocal.h:15:35: note: 
      expanded from macro 'EIGEN_THREAD_LOCAL'
#define EIGEN_THREAD_LOCAL static __thread
                                  ^
<command line>:3:18: note: expanded from here
#define __thread thread_local
                 ^
In file included from tensorflow/core/common_runtime/local_device.cc:18:
In file included from ./tensorflow/core/common_runtime/local_device.h:19:
In file included from ./tensorflow/core/common_runtime/device.h:35:
In file included from ./tensorflow/core/framework/allocator.h:23:
In file included from ./tensorflow/core/framework/numeric_types.h:20:
In file included from ./third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1:
In file included from /pj/tensorflow/tensorflow/contrib/makefile/downloads/eigen/unsupported/Eigen/CXX11/Tensor:79:
In file included from /pj/tensorflow/tensorflow/contrib/makefile/downloads/eigen/unsupported/Eigen/CXX11/ThreadPool:59:
/pj/tensorflow/tensorflow/contrib/makefile/downloads/eigen/unsupported/Eigen/CXX11/src/ThreadPool/NonBlockingThreadPool.h:326:5: error: 
      thread-local storage is not supported for the current target
    EIGEN_THREAD_LOCAL PerThread per_thread_;
    ^
/pj/tensorflow/tensorflow/contrib/makefile/downloads/eigen/unsupported/Eigen/CXX11/src/ThreadPool/ThreadLocal.h:15:35: note: 
      expanded from macro 'EIGEN_THREAD_LOCAL'
#define EIGEN_THREAD_LOCAL static __thread
                                  ^
<command line>:3:18: note: expanded from here
#define __thread thread_local
                 ^
2 errors generated.
make: *** [pj/tensorflow/tensorflow/contrib/makefile/gen/obj/ios_I386/tensorflow/core/common_runtime/local_device.o] Error 1
+ '[' 2 -ne 0 ']'
+ echo 'i386 compilation failed.'
i386 compilation failed.
+ exit 1

japer21 commented Jul 6, 2018

@sadlerjw I am working on Mac sierra 10.13.5 (17F77) , and what I did is here:
checked out tensorflow 1.9.0-rc1
did export ANDROID_TYPES="-D__ANDROID_TYPES_FULL__"
and then launched the script tensorflow/contrib/makefile/buils_all_ios.sh .

On building stage for the arch i386 I got the error:

tensorflow/tensorflow/contrib/makefile/downloads/eigen/unsupported/Eigen/CXX11/src/ThreadPool/SimpleThreadPool.h:153:5: error: 
      thread-local storage is not supported for the current target
    EIGEN_THREAD_LOCAL PerThread per_thread;
    ^
/pj/tensorflow/tensorflow/contrib/makefile/downloads/eigen/unsupported/Eigen/CXX11/src/ThreadPool/ThreadLocal.h:15:35: note: 
      expanded from macro 'EIGEN_THREAD_LOCAL'
#define EIGEN_THREAD_LOCAL static __thread
                                  ^
<command line>:3:18: note: expanded from here
#define __thread thread_local
                 ^
In file included from tensorflow/core/common_runtime/local_device.cc:18:
In file included from ./tensorflow/core/common_runtime/local_device.h:19:
In file included from ./tensorflow/core/common_runtime/device.h:35:
In file included from ./tensorflow/core/framework/allocator.h:23:
In file included from ./tensorflow/core/framework/numeric_types.h:20:
In file included from ./third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1:
In file included from /pj/tensorflow/tensorflow/contrib/makefile/downloads/eigen/unsupported/Eigen/CXX11/Tensor:79:
In file included from /pj/tensorflow/tensorflow/contrib/makefile/downloads/eigen/unsupported/Eigen/CXX11/ThreadPool:59:
/pj/tensorflow/tensorflow/contrib/makefile/downloads/eigen/unsupported/Eigen/CXX11/src/ThreadPool/NonBlockingThreadPool.h:326:5: error: 
      thread-local storage is not supported for the current target
    EIGEN_THREAD_LOCAL PerThread per_thread_;
    ^
/pj/tensorflow/tensorflow/contrib/makefile/downloads/eigen/unsupported/Eigen/CXX11/src/ThreadPool/ThreadLocal.h:15:35: note: 
      expanded from macro 'EIGEN_THREAD_LOCAL'
#define EIGEN_THREAD_LOCAL static __thread
                                  ^
<command line>:3:18: note: expanded from here
#define __thread thread_local
                 ^
2 errors generated.
make: *** [pj/tensorflow/tensorflow/contrib/makefile/gen/obj/ios_I386/tensorflow/core/common_runtime/local_device.o] Error 1
+ '[' 2 -ne 0 ']'
+ echo 'i386 compilation failed.'
i386 compilation failed.
+ exit 1

@joelteply

This comment has been minimized.

Show comment
Hide comment
@joelteply

joelteply Sep 2, 2018

I'm up for sadlerjw's fix because when most people use this library i386 is more about just making sure one of the simulators compiles, but it is unnecessary for testing or production, just that it passes automated testing and whatnot.

joelteply commented Sep 2, 2018

I'm up for sadlerjw's fix because when most people use this library i386 is more about just making sure one of the simulators compiles, but it is unnecessary for testing or production, just that it passes automated testing and whatnot.

@tensorflowbutler

This comment has been minimized.

Show comment
Hide comment
@tensorflowbutler

tensorflowbutler Sep 16, 2018

Member

Nagging Assignee @jart: It has been 14 days with no activity and this issue has an assignee. Please update the label and/or status accordingly.

Member

tensorflowbutler commented Sep 16, 2018

Nagging Assignee @jart: It has been 14 days with no activity and this issue has an assignee. Please update the label and/or status accordingly.

@robinqhuang

This comment has been minimized.

Show comment
Hide comment
@robinqhuang

robinqhuang Sep 17, 2018

sadlerjw's fix does not work for tensorflow 1.10 + xcode 9.4.1. It fixed for Eigen, but there is another similar error:
tensorflow/core/util/work_sharder.cc:23:23: error: thread-local storage is not supported for the current target

robinqhuang commented Sep 17, 2018

sadlerjw's fix does not work for tensorflow 1.10 + xcode 9.4.1. It fixed for Eigen, but there is another similar error:
tensorflow/core/util/work_sharder.cc:23:23: error: thread-local storage is not supported for the current target

@eaigner

This comment has been minimized.

Show comment
Hide comment
@eaigner

eaigner Sep 18, 2018

Contributor

@sadlerjw 's fix doesn't seem to work anymore on TF 1.10. Getting the same error like @robinqhuang

Specifically it's line 23 in tensorflow/tensorflow/core/util/work_sharder.cc

/* ABSL_CONST_INIT */ thread_local int per_thread_max_parallism = 1000000;

I fixed it by replacing thread_local with __thread since it is defined as empty in @sadlerjw 's fix for i386 and that's what we want

/* ABSL_CONST_INIT */ __thread int per_thread_max_parallism = 1000000;
Contributor

eaigner commented Sep 18, 2018

@sadlerjw 's fix doesn't seem to work anymore on TF 1.10. Getting the same error like @robinqhuang

Specifically it's line 23 in tensorflow/tensorflow/core/util/work_sharder.cc

/* ABSL_CONST_INIT */ thread_local int per_thread_max_parallism = 1000000;

I fixed it by replacing thread_local with __thread since it is defined as empty in @sadlerjw 's fix for i386 and that's what we want

/* ABSL_CONST_INIT */ __thread int per_thread_max_parallism = 1000000;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment