Bug 20667 – fatal error LNK1179 on windows-x86_64-dmd with MSVC

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2020-03-11T13:31:32Z
Last change time
2024-12-13T19:07:32Z
Assigned to
No Owner
Creator
SHOO
Moved to GitHub: dmd#19675 →

Comments

Comment #0 by zan77137 — 2020-03-11T13:31:32Z
This code causes a link error(LNK1179): foo/bar.d ------------- import std.algorithm; ------------- foo/main.d ------------- module foo.main; import std.path; void foo(string file) { file.relativePath; } ------------- hoge.d ------------- import foo.main; void main() { } ------------- Compile with follows: ------------- dmd -m64 -lib -offoo.lib -cov foo\bar.d foo\main.d dmd -m64 -cov hoge.d foo.lib foo.lib(main.obj) : fatal error LNK1179: ファイルが無効か、または壊れています: COMDAT '__bzeroBytes' を複製します。(Maybe, in English: invalid or corrupt file: duplicate COMDAT '__bzeroBytes') Error: linker exited with status 1179 ------------- Conditions: On Windows, x86_64(-m64), coverage(-cov) is enabled, and the installed MSVC(vs_buildtools 2019) environment. It does not reproduce on other OS, MinGW(MSVC is not installed), x86, or without -cov. And if removing unnecessary import statements or unnecessary files, the situation will not be reproduced. Below is a similar link error but the situation seemed different. https://issues.dlang.org/show_bug.cgi?id=20565
Comment #1 by kntroh — 2021-04-29T06:38:04Z
I got a similar error. However, the error code was LNK2005: source/test.d: --- import b; void main() { } --- sub/a.d: --- import std.algorithm; --- sub/b.d: --- module b; import std; class C { void c() { f(); } } struct S { double a = 0; string b; S[] c; @disable this (); } S f() { int[] arr; array(map!(a => f())(arr)); assert (0); } --- dub.json: --- { "name": "test", "targetType": "executable", "application": "test.d", "dependencies": { ":sub": "*" }, "subPackages": [{ "name": "sub", "targetType": "library", "sourcePaths": [ "sub" ], "importPaths": [ "sub" ] }] } --- When I prepare these files and build it by dub on Windows, I got an error that "__bzeroBytes already defined". I have confirmed the reproduction with dmd 2.096.1 on Windows 8.1 and Windows 10 (20H2). $ dub Performing "debug" build using ***\dmd2\windows\bin\dmd.exe for x86_64. test:sub ~master: target for configuration "library" is up to date. test ~master: building configuration "application"... Linking... test_sub.lib(b_33_53.obj) : error LNK2005: __bzeroBytes は既に test_sub.lib(b_40_9af.obj) で定義されています。(__bzeroBytes already defined in test_sub.lib(h_48_8a7.obj)) .dub\build\application-debug-windows-x86_64-dmd_v2.096.1-dirty-4872E8CFA9A99F10C9963544DB0FC94E\test.exe : fatal error LNK1169: 1 つ以上の複数回定義されているシンボルが見つかりました。(found one or more symbols with multiple definitions) Error: linker exited with status 1169 ***\dmd2\windows\bin\dmd.exe failed with exit code 1. $ I tried to see if I could make the reproduction code smaller, but it was impossible. For example, just replace `double a = 0;` with `double a = 1;` and it will not reproduce.
Comment #2 by robert.schadek — 2024-12-13T19:07:32Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19675 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB