digitalmars.D.bugs - [Issue 13666] New: Undefined Symbols for __gshared data symbols in
- via Digitalmars-d-bugs (44/46) Oct 30 2014 https://issues.dlang.org/show_bug.cgi?id=13666
https://issues.dlang.org/show_bug.cgi?id=13666 Issue ID: 13666 Summary: Undefined Symbols for __gshared data symbols in templates Product: D Version: D2 Hardware: x86 OS: Windows Status: NEW Severity: major Priority: P1 Component: DMD Assignee: nobody puremagic.com Reporter: r.sagitario gmx.de Compile this module to a library: module test; template drt_envvars_enabled() { extern(C) __gshared bool drt_envvars_enabled = false; } bool foo() { return drt_envvars_enabled!(); } ///////////dmd -lib test.dThen link it with main.d: import test; int main() { return foo(); } //////////////dmd main.d test.libOPTLINK (R) for Win32 Release 8.00.15 Copyright (C) Digital Mars 1989-2013 All rights reserved. http://www.digitalmars.com/ctg/optlink.html test.lib(test) Error 42: Symbol Undefined __D4test25__T19drt_envvars_enabledZ19drt_envvars_enabledb --- errorlevel 1 According to https://github.com/D-Programming-Language/druntime/pull/986, this fails for Win32 and OS/X, but works for other platform. It also works if the variable is not "__gshared" or it is initialized to a non-zero value. It is probably caused by some bad BSS optimization. --
Oct 30 2014