Clang 目标:不支持线程本地存储

Lis*_*ner 5 macos multithreading clang compiler-options thread-local-storage

关于编译器选项有几个问题。现在我使用以下内容:

-target i386-windows-gnu -mno-sse -c -O3
-target x86_64-windows-gnu -mcx16 -c -O3
-target i386-linux-gnu -mno-sse -c -O3
-target x86_64-linux-gnu -mcx16 -c -O3
-target i386-darwin-gnu -mno-sse -fomit-frame-pointer -c -O3
-target x86_64-macos-gnu -fomit-frame-pointer -c -O3
-target armv7-none-linux-androideabi -mfpu=neon -mfloat-abi=hard -mthumb -fPIC -c -O3
-target aarch64-linux-android -c -O3
-target armv7m-none-ios-gnueabi -mfpu=neon -mfloat-abi=hard -mthumb -c -O3
-target arm64-darwin-gnu -fno-stack-protector -c -O3
Run Code Online (Sandbox Code Playgroud)

仅在 Linux/Android 上没有投诉。对于其他平台,它会发出警告(https://godbolt.org/z/YhZ5uc):

clang-9: warning: argument unused during compilation: '--gcc-toolchain=/opt/compiler-explorer/gcc-9.2.0' [-Wunused-command-line-argument]
Compiler returned: 0
Run Code Online (Sandbox Code Playgroud)

ARM32平台不支持preserve_most属性(https://godbolt.org/z/SQRJB2):

<source>:2:21: warning: 'preserve_most' calling convention is not supported for this target [-Wignored-attributes]
void __attribute__((preserve_most)) proc_most(int* x);
Run Code Online (Sandbox Code Playgroud)

但最大的问题是Mac/iOS不支持TLS变量(https://godbolt.org/z/6bqjby)!

__thread int x;

int test()
{
    return x;
}


<source>:2:1: error: thread-local storage is not supported for the current target
Run Code Online (Sandbox Code Playgroud)