digitalmars.D.bugs - [Issue 23014] New: importC: static thread-locals don't work
- d-bugmail puremagic.com (94/94) Apr 14 2022 https://issues.dlang.org/show_bug.cgi?id=23014
https://issues.dlang.org/show_bug.cgi?id=23014 Issue ID: 23014 Summary: importC: static thread-locals don't work Product: D Version: D2 Hardware: All OS: Linux Status: NEW Keywords: ImportC Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: duser neet.fi CC: duser neet.fi relevant function: https://github.com/dlang/dmd/blob/0e3e0f9/src/dmd/cparse.d#L4437 static is ignored for thread-locals at top level, so the symbol isn't made static // file1.c static _Thread_local int tmp; // file2.c static _Thread_local int tmp; int main(){} compile: "dmd file1.c file2.c", gives a multiple definition error for "tmp" even though it should be static the parser does apply both static and _Thread_local when inside a function, but that doesn't seem to be supported/working: int printf(char *, ...); int main() { static _Thread_local int x = 1; printf("%p\n", &x); printf(" %d\n", x); } asserts when compiling with this output: e.Eoper: '&' el:0x562029f25560 cnt=0 cs=0 & TY* 0x562029f25500 el:0x562029f25500 cnt=0 cs=0 call TYint 0x562029f254a0 0x562029f250e0 el:0x562029f254a0 cnt=0 cs=0 var TYC func __tls_get_addr el:0x562029f250e0 cnt=0 cs=0 relconst mTYvolatile|TY* 0+& _D4test4mainUY1xi --- ERROR: This is a compiler bug. Please report it via https://issues.dlang.org/enter_bug.cgi with, preferably, a reduced, reproducible example and the information below. DustMite (https://github.com/CyberShadow/DustMite/wiki) can help with the reduction. --- DMD v2.099.1-351-g26299b627 predefs DigitalMars LittleEndian D_Version2 all D_SIMD Posix ELFv1 linux CRuntime_Glibc CppRuntime_Gcc D_InlineAsm_X86_64 X86_64 D_LP64 D_PIC assert D_PreConditions D_PostConditions D_Invariants D_ModuleInfo D_Exceptions D_TypeInfo D_HardFloat binary /home/human/work/result/bin/dmd version v2.099.1-351-g26299b627 config /home/human/work/result/bin/dmd.conf DFLAGS -I/home/human/work/result/bin/../import -L-L/home/human/work/result/bin/../lib -L--export-dynamic -fPIC --- core.exception.AssertError src/dmd/backend/cgcs.d(442): Assertion failure ---------------- ??:? onAssertError [0x7fae73628622] src/dmd/backend/cgcs.d:442 nothrow trusted void dmd.backend.cgcs.ecom(ref dmd.backend.cgcs.CGCS, ref dmd.backend.el.elem*) [0x562028c21fdb] src/dmd/backend/cgcs.d:371 nothrow trusted void dmd.backend.cgcs.ecom(ref dmd.backend.cgcs.CGCS, ref dmd.backend.el.elem*) [0x562028c21d5b] src/dmd/backend/cgcs.d:338 nothrow trusted void dmd.backend.cgcs.ecom(ref dmd.backend.cgcs.CGCS, ref dmd.backend.el.elem*) [0x562028c21cc0] src/dmd/backend/cgcs.d:127 nothrow trusted void dmd.backend.cgcs.comsubs2(dmd.backend.cc.block*, ref dmd.backend.cgcs.CGCS) [0x562028c215ff] src/dmd/backend/cgcs.d:60 _Z7comsubsv [0x562028c214c5] src/dmd/backend/blockopt.d:717 _Z8blockopti [0x562028beff57] src/dmd/backend/out.d:1409 _Z10writefunc2P6Symbol [0x562028c03a35] src/dmd/backend/out.d:1137 _Z9writefuncP6Symbol [0x562028c03154] src/dmd/glue.d:1184 _Z25FuncDeclaration_toObjFileP15FuncDeclarationb [0x562028af6d79] src/dmd/toobj.d:311 _ZN9toObjFile9ToObjFile5visitEP15FuncDeclaration [0x562028b0c698] src/dmd/func.d:2833 _ZN15FuncDeclaration6acceptEP7Visitor [0x5620288d4ba7] src/dmd/toobj.d:748 _ZN9toObjFile9ToObjFile5visitEP17AttribDeclaration [0x562028b0beef] ??:? _ZN16ParseTimeVisitorI10ASTCodegenE5visitEP15LinkDeclaration [0x562028b1cea3] src/dmd/attrib.d:433 _ZN15LinkDeclaration6acceptEP7Visitor [0x5620288d5158] src/dmd/toobj.d:1008 _Z9toObjFileP7Dsymbolb [0x5620288fe808] src/dmd/glue.d:522 _Z10genObjFileP6Moduleb [0x562028af1e3c] src/dmd/glue.d:120 void dmd.glue.generateCodeAndWrite(dmd.dmodule.Module[], const(char)*[], const(char)[], const(char)[], bool, bool, bool, bool, bool) [0x56202890cb8b] src/dmd/mars.d:574 int dmd.mars.tryMain(ulong, const(char)**, ref dmd.globals.Param) [0x56202890f602] src/dmd/mars.d:958 _Dmain [0x56202891afa6] --
Apr 14 2022