Skip to content

[lld] lld-link 21.1.0-rc3: undefined reference to _Avx2WmemEnabled #154595

@solbjorn

Description

@solbjorn

Possible related commit: bbc8346

Windows' ucrt/wchar.h contains:

    #if !defined(_M_CEE)
    #if (defined(_M_IX86) && !defined(_M_HYBRID_X86_ARM64)) || (defined(_M_X64) && !defined(_M_ARM64EC))
    extern int _Avx2WmemEnabled;
    __declspec(selectany) int _Avx2WmemEnabledWeakValue = 0;
    #if defined(_M_IX86)
    #pragma comment(linker, "/alternatename:__Avx2WmemEnabled=__Avx2WmemEnabledWeakValue")
    #else
    #pragma comment(linker, "/alternatename:_Avx2WmemEnabled=_Avx2WmemEnabledWeakValue")
    #endif
    #endif
    #endif

then later, in wmemchr():

    #if !defined(__clang__) || defined(__AVX2__)
        if (_Avx2WmemEnabled && _N >= 16)
        {
            __m256i __v2 = _mm256_broadcastw_epi16(_mm_cvtsi32_si128(_C));

When compiling with AVX2 and then linking a DLL, lld-link fails with

lld-link: undefined reference to _Avx2WmemEnabled

21.1.0-rc1 works fine.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions