llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.14k stars 12.02k forks source link

Cross-compiling to mac-arm failed to support threa_local storage #116562

Open addsoa opened 2 hours ago

addsoa commented 2 hours ago

Try to compile

unsigned int test() {
        static _Thread_local unsigned int tl_tid;
        unsigned int tid = 4;

        if (tl_tid) return tl_tid;
        else return tid;
}

int main() {
        unsigned int rc = test();
        return 0;
}

Output:

$ clang --target=arm64-apple-darwin-mach --sysroot=$SYSROOTPATH ./testthreadlocal.c
./testthreadlocal.c:2:9: error: thread-local storage is not supported for the current target
    2 |         static _Thread_local unsigned int tl_tid;
      |                ^
1 error generated.

clang:

clang --version
Ubuntu clang version 17.0.6 (++20231209124227+6009708b4367-1~exp1~20231209124336.77)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-17/bin

clang16, clang18 generated the same error.

EugeneZelenko commented 1 hour ago

Could you please try 19 or main branch?