Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation issue with template trick on MSVC #152

Closed
merryhime opened this issue Jun 13, 2022 · 3 comments
Closed

Compilation issue with template trick on MSVC #152

merryhime opened this issue Jun 13, 2022 · 3 comments

Comments

@merryhime
Copy link

The template trick depends on MSVC recognising and being able to inline everything.
If MSVC isn't able to do this or if optimizations are disabled, this produces a link time error.

e.g. https://godbolt.org/z/7e83PM9MP

example.cpp
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<0,0> const Xbyak::util::Cpu::NONE" (?NONE@Cpu@util@Xbyak@@2U?$TypeT@$0A@$0A@@local@23@B) referenced in function "public: __cdecl Xbyak::util::Cpu::Cpu(void)" (??0Cpu@util@Xbyak@@QEAA@XZ)
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<1,0> const Xbyak::util::Cpu::tMMX" (?tMMX@Cpu@util@Xbyak@@2U?$TypeT@$00$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<2,0> const Xbyak::util::Cpu::tMMX2" (?tMMX2@Cpu@util@Xbyak@@2U?$TypeT@$01$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<4,0> const Xbyak::util::Cpu::tCMOV" (?tCMOV@Cpu@util@Xbyak@@2U?$TypeT@$03$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<8,0> const Xbyak::util::Cpu::tSSE" (?tSSE@Cpu@util@Xbyak@@2U?$TypeT@$07$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<16,0> const Xbyak::util::Cpu::tSSE2" (?tSSE2@Cpu@util@Xbyak@@2U?$TypeT@$0BA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<32,0> const Xbyak::util::Cpu::tSSE3" (?tSSE3@Cpu@util@Xbyak@@2U?$TypeT@$0CA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<64,0> const Xbyak::util::Cpu::tSSSE3" (?tSSSE3@Cpu@util@Xbyak@@2U?$TypeT@$0EA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<128,0> const Xbyak::util::Cpu::tSSE41" (?tSSE41@Cpu@util@Xbyak@@2U?$TypeT@$0IA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<256,0> const Xbyak::util::Cpu::tSSE42" (?tSSE42@Cpu@util@Xbyak@@2U?$TypeT@$0BAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<512,0> const Xbyak::util::Cpu::tPOPCNT" (?tPOPCNT@Cpu@util@Xbyak@@2U?$TypeT@$0CAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<1024,0> const Xbyak::util::Cpu::tAESNI" (?tAESNI@Cpu@util@Xbyak@@2U?$TypeT@$0EAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<2048,0> const Xbyak::util::Cpu::tAVX512_FP16" (?tAVX512_FP16@Cpu@util@Xbyak@@2U?$TypeT@$0IAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<4096,0> const Xbyak::util::Cpu::tOSXSAVE" (?tOSXSAVE@Cpu@util@Xbyak@@2U?$TypeT@$0BAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<8192,0> const Xbyak::util::Cpu::tPCLMULQDQ" (?tPCLMULQDQ@Cpu@util@Xbyak@@2U?$TypeT@$0CAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<16384,0> const Xbyak::util::Cpu::tAVX" (?tAVX@Cpu@util@Xbyak@@2U?$TypeT@$0EAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<32768,0> const Xbyak::util::Cpu::tFMA" (?tFMA@Cpu@util@Xbyak@@2U?$TypeT@$0IAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<65536,0> const Xbyak::util::Cpu::t3DN" (?t3DN@Cpu@util@Xbyak@@2U?$TypeT@$0BAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<131072,0> const Xbyak::util::Cpu::tE3DN" (?tE3DN@Cpu@util@Xbyak@@2U?$TypeT@$0CAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<262144,0> const Xbyak::util::Cpu::tWAITPKG" (?tWAITPKG@Cpu@util@Xbyak@@2U?$TypeT@$0EAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<524288,0> const Xbyak::util::Cpu::tRDTSCP" (?tRDTSCP@Cpu@util@Xbyak@@2U?$TypeT@$0IAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<1048576,0> const Xbyak::util::Cpu::tAVX2" (?tAVX2@Cpu@util@Xbyak@@2U?$TypeT@$0BAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<2097152,0> const Xbyak::util::Cpu::tBMI1" (?tBMI1@Cpu@util@Xbyak@@2U?$TypeT@$0CAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<4194304,0> const Xbyak::util::Cpu::tBMI2" (?tBMI2@Cpu@util@Xbyak@@2U?$TypeT@$0EAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<8388608,0> const Xbyak::util::Cpu::tLZCNT" (?tLZCNT@Cpu@util@Xbyak@@2U?$TypeT@$0IAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<16777216,0> const Xbyak::util::Cpu::tINTEL" (?tINTEL@Cpu@util@Xbyak@@2U?$TypeT@$0BAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<33554432,0> const Xbyak::util::Cpu::tAMD" (?tAMD@Cpu@util@Xbyak@@2U?$TypeT@$0CAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<67108864,0> const Xbyak::util::Cpu::tENHANCED_REP" (?tENHANCED_REP@Cpu@util@Xbyak@@2U?$TypeT@$0EAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<134217728,0> const Xbyak::util::Cpu::tRDRAND" (?tRDRAND@Cpu@util@Xbyak@@2U?$TypeT@$0IAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<268435456,0> const Xbyak::util::Cpu::tADX" (?tADX@Cpu@util@Xbyak@@2U?$TypeT@$0BAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<536870912,0> const Xbyak::util::Cpu::tRDSEED" (?tRDSEED@Cpu@util@Xbyak@@2U?$TypeT@$0CAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<1073741824,0> const Xbyak::util::Cpu::tSMAP" (?tSMAP@Cpu@util@Xbyak@@2U?$TypeT@$0EAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<2147483648,0> const Xbyak::util::Cpu::tHLE" (?tHLE@Cpu@util@Xbyak@@2U?$TypeT@$0IAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<4294967296,0> const Xbyak::util::Cpu::tRTM" (?tRTM@Cpu@util@Xbyak@@2U?$TypeT@$0BAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<8589934592,0> const Xbyak::util::Cpu::tF16C" (?tF16C@Cpu@util@Xbyak@@2U?$TypeT@$0CAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<17179869184,0> const Xbyak::util::Cpu::tMOVBE" (?tMOVBE@Cpu@util@Xbyak@@2U?$TypeT@$0EAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<34359738368,0> const Xbyak::util::Cpu::tAVX512F" (?tAVX512F@Cpu@util@Xbyak@@2U?$TypeT@$0IAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<68719476736,0> const Xbyak::util::Cpu::tAVX512DQ" (?tAVX512DQ@Cpu@util@Xbyak@@2U?$TypeT@$0BAAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<137438953472,0> const Xbyak::util::Cpu::tAVX512_IFMA" (?tAVX512_IFMA@Cpu@util@Xbyak@@2U?$TypeT@$0CAAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<137438953472,0> const Xbyak::util::Cpu::tAVX512IFMA" (?tAVX512IFMA@Cpu@util@Xbyak@@2U?$TypeT@$0CAAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<274877906944,0> const Xbyak::util::Cpu::tAVX512PF" (?tAVX512PF@Cpu@util@Xbyak@@2U?$TypeT@$0EAAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<549755813888,0> const Xbyak::util::Cpu::tAVX512ER" (?tAVX512ER@Cpu@util@Xbyak@@2U?$TypeT@$0IAAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<1099511627776,0> const Xbyak::util::Cpu::tAVX512CD" (?tAVX512CD@Cpu@util@Xbyak@@2U?$TypeT@$0BAAAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<2199023255552,0> const Xbyak::util::Cpu::tAVX512BW" (?tAVX512BW@Cpu@util@Xbyak@@2U?$TypeT@$0CAAAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<4398046511104,0> const Xbyak::util::Cpu::tAVX512VL" (?tAVX512VL@Cpu@util@Xbyak@@2U?$TypeT@$0EAAAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<8796093022208,0> const Xbyak::util::Cpu::tAVX512_VBMI" (?tAVX512_VBMI@Cpu@util@Xbyak@@2U?$TypeT@$0IAAAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<8796093022208,0> const Xbyak::util::Cpu::tAVX512VBMI" (?tAVX512VBMI@Cpu@util@Xbyak@@2U?$TypeT@$0IAAAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<17592186044416,0> const Xbyak::util::Cpu::tAVX512_4VNNIW" (?tAVX512_4VNNIW@Cpu@util@Xbyak@@2U?$TypeT@$0BAAAAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<35184372088832,0> const Xbyak::util::Cpu::tAVX512_4FMAPS" (?tAVX512_4FMAPS@Cpu@util@Xbyak@@2U?$TypeT@$0CAAAAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<70368744177664,0> const Xbyak::util::Cpu::tPREFETCHWT1" (?tPREFETCHWT1@Cpu@util@Xbyak@@2U?$TypeT@$0EAAAAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<140737488355328,0> const Xbyak::util::Cpu::tPREFETCHW" (?tPREFETCHW@Cpu@util@Xbyak@@2U?$TypeT@$0IAAAAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<281474976710656,0> const Xbyak::util::Cpu::tSHA" (?tSHA@Cpu@util@Xbyak@@2U?$TypeT@$0BAAAAAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<562949953421312,0> const Xbyak::util::Cpu::tMPX" (?tMPX@Cpu@util@Xbyak@@2U?$TypeT@$0CAAAAAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<1125899906842624,0> const Xbyak::util::Cpu::tAVX512_VBMI2" (?tAVX512_VBMI2@Cpu@util@Xbyak@@2U?$TypeT@$0EAAAAAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<2251799813685248,0> const Xbyak::util::Cpu::tGFNI" (?tGFNI@Cpu@util@Xbyak@@2U?$TypeT@$0IAAAAAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<4503599627370496,0> const Xbyak::util::Cpu::tVAES" (?tVAES@Cpu@util@Xbyak@@2U?$TypeT@$0BAAAAAAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<9007199254740992,0> const Xbyak::util::Cpu::tVPCLMULQDQ" (?tVPCLMULQDQ@Cpu@util@Xbyak@@2U?$TypeT@$0CAAAAAAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<18014398509481984,0> const Xbyak::util::Cpu::tAVX512_VNNI" (?tAVX512_VNNI@Cpu@util@Xbyak@@2U?$TypeT@$0EAAAAAAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<36028797018963968,0> const Xbyak::util::Cpu::tAVX512_BITALG" (?tAVX512_BITALG@Cpu@util@Xbyak@@2U?$TypeT@$0IAAAAAAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<72057594037927936,0> const Xbyak::util::Cpu::tAVX512_VPOPCNTDQ" (?tAVX512_VPOPCNTDQ@Cpu@util@Xbyak@@2U?$TypeT@$0BAAAAAAAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<144115188075855872,0> const Xbyak::util::Cpu::tAVX512_BF16" (?tAVX512_BF16@Cpu@util@Xbyak@@2U?$TypeT@$0CAAAAAAAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<288230376151711744,0> const Xbyak::util::Cpu::tAVX512_VP2INTERSECT" (?tAVX512_VP2INTERSECT@Cpu@util@Xbyak@@2U?$TypeT@$0EAAAAAAAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<576460752303423488,0> const Xbyak::util::Cpu::tAMX_TILE" (?tAMX_TILE@Cpu@util@Xbyak@@2U?$TypeT@$0IAAAAAAAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<1152921504606846976,0> const Xbyak::util::Cpu::tAMX_INT8" (?tAMX_INT8@Cpu@util@Xbyak@@2U?$TypeT@$0BAAAAAAAAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<2305843009213693952,0> const Xbyak::util::Cpu::tAMX_BF16" (?tAMX_BF16@Cpu@util@Xbyak@@2U?$TypeT@$0CAAAAAAAAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<4611686018427387904,0> const Xbyak::util::Cpu::tAVX_VNNI" (?tAVX_VNNI@Cpu@util@Xbyak@@2U?$TypeT@$0EAAAAAAAAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<-9223372036854775808,0> const Xbyak::util::Cpu::tCLFLUSHOPT" (?tCLFLUSHOPT@Cpu@util@Xbyak@@2U?$TypeT@$0?IAAAAAAAAAAAAAAA@$0A@@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<0,1> const Xbyak::util::Cpu::tCLDEMOTE" (?tCLDEMOTE@Cpu@util@Xbyak@@2U?$TypeT@$0A@$00@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<0,2> const Xbyak::util::Cpu::tMOVDIRI" (?tMOVDIRI@Cpu@util@Xbyak@@2U?$TypeT@$0A@$01@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<0,4> const Xbyak::util::Cpu::tMOVDIR64B" (?tMOVDIR64B@Cpu@util@Xbyak@@2U?$TypeT@$0A@$03@local@23@B) referenced in function main
output.s.obj : error LNK2019: unresolved external symbol "public: static struct Xbyak::util::local::TypeT<0,8> const Xbyak::util::Cpu::tCLZERO" (?tCLZERO@Cpu@util@Xbyak@@2U?$TypeT@$0A@$07@local@23@B) referenced in function main
@herumi
Copy link
Owner

herumi commented Jun 14, 2022

Thank you for the report.
How about this patch ?

@merryhime
Copy link
Author

That works, yes.

@herumi
Copy link
Owner

herumi commented Jun 14, 2022

I've released version 6.60.1

@herumi herumi closed this as completed Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants