Skip to content

macos-arm64: _Thread_local not implemented #86

Description

@quaesitor-scientiam

Describe the bug

The thirdparty-macos-arm64 tcc build rejects the C11 _Thread_local storage-class specifier with error: _Thread_local is not implemented, even though it's valid ISO C11 and other tcc targets (and every other C compiler V supports) accept it.

This currently breaks v self on Apple Silicon macOS in the main V repo, since V's -prealloc allocator emits a _Thread_local global — see vlang/v#28023 and the fix in vlang/v#28024 (which works around it on the V side by avoiding tcc whenever _Thread_local would be emitted, but the underlying tcc limitation remains).

Reproduction Steps

// repro.c
_Thread_local int g_x;

int main(void) {
    g_x = 1;
    return g_x - 1;
}
$ ./tcc.exe -o repro repro.c
repro.c:1: error: _Thread_local is not implemented

Expected Behavior

_Thread_local (and ideally the C11 thread_local alias) compiles successfully, consistent with tcc's support for __thread on other platforms.

Current Behavior

error: _Thread_local is not implemented

Environment details

tcc version tcc version 0.9.28rc 2026-07-24 HEAD@85ba3ae8 (AArch64 Darwin)
tccbin branch/commit thirdparty-macos-arm64 @ 274abd2
built via TCC_COMMIT=85ba3ae8f1e22044255d54c28be04e5fc3e88ae0 TCC_FOLDER=thirdparty/tcc bash thirdparty/build_scripts/thirdparty-macos-arm64_tcc.sh
host OS macOS 26 (arm64)

Additional Information/Context

Given tcc already supports __thread as a GNU-style extension on other Mach-O/ELF targets, a minimal fix may be to alias _Thread_local/thread_local to the same codegen path used for __thread on this target, rather than a full generic TLS implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions