https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106042

            Bug ID: 106042
           Summary: std::__once_call abi umatch for clang and gcc on
                    windows targets
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: unlvsur at live dot com
  Target Milestone: ---

Created attachment 53180
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53180&action=edit
gcc output

Consider code like this:

extern __thread void* __once_callable;
extern __thread void (*__once_call)() noexcept;

void foo() noexcept
{
    __once_call();
}

GCC:

        movq    .refptr.__emutls_v.__once_call(%rip), %rcx
        call    __emutls_get_address
        movq    (%rax), %rax
        addq    $40, %rsp
        rex.W jmp       *%rax

but clang --target=x86_64-windows-gnu:

_Z3foov:                                # @_Z3foov
        movl    _tls_index(%rip), %eax
        movq    %gs:88, %rcx
        movq    (%rcx,%rax,8), %rax
        rex64 jmpq      *__once_call@SECREL32(%rax) # TAILCALL

This means clang does not have the same behavior for thread_local storage with
GCC on windows.

It breaks clang Canadian compilation from clang with libstdc++. I think we need
some tweaks here.

ld.lld: error: undefined symbol: std::__once_call
>>> referenced by 
>>> lib/Support/CMakeFiles/LLVMSupport.dir/Parallel.cpp.obj:(std::__future_base::_State_baseV2::_M_set_result(std::function<std::unique_ptr<std::__future_base::_Result_base,
>>>  std::__future_base::_Result_base::_Deleter> ()>, bool))
>>> referenced by 
>>> lib/Support/CMakeFiles/LLVMSupport.dir/Parallel.cpp.obj:(std::__future_base::_State_baseV2::_M_set_result(std::function<std::unique_ptr<std::__future_base::_Result_base,
>>>  std::__future_base::_Result_base::_Deleter> ()>, bool))
clang-15: error: linker command failed with exit code 1 (use -v to see
invocation)
[61/4971] Building CXX object
lib/FileCheck/CMakeFiles/LLVMFileCheck.dir/FileCheck.cpp.obj
ninja: build stopped: subcommand failed.

Reply via email to