Thread overview
invalid or corrupt file: duplicate COMDAT / Previous Definition Different
Jan 10, 2018
Anonymouse
Jan 10, 2018
Benjamin Thaut
Jan 10, 2018
Anonymouse
Jan 12, 2018
Anonymouse
Jan 10, 2018
Jesse Phillips
January 10, 2018
I haven't been testing my project on Windows for a while, and on top of having issues with out of memory errors when unittesting I see I can't build it normally either. dmd is 2.078.0.

$ dub build -c cygwin -a x86_64
Performing "debug" build using dmd for x86_64.
kameloso 1.0.0-beta.2+commit.57.g90fdd1d: building configuration "cygwin"...
Linking...
kameloso.obj : fatal error LNK1179: invalid or corrupt file: duplicate COMDAT '_D8kameloso7plugins6common8BotRegex6__ctorMFNcxEQBuQBoQBj10NickPolicyS3std5regex8internal2ir__T5RegexTaZQjZSQEcQDwQDrQDn'
Error: linker exited with status 1179
dmd failed with exit code 1179.

$ dub build -c cygwin
Performing "debug" build using dmd for x86.
kameloso 1.0.0-beta.2+commit.57.g90fdd1d: building configuration "cygwin"...
Linking...
OPTLINK (R) for Win32  Release 8.00.17
Copyright (C) Digital Mars 1989-2013  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
.dub\build\cygwin-debug-windows-x86-dmd_2078-270D5D6B34387418CFDA6A068E7A60D9\kameloso.obj(kameloso)  Offset 7A92EH Record Type 00C3
 Error 1: Previous Definition Different : _D8kameloso7plugins6common8BotRegex6__ctorMFNcxEQBuQBoQBj10NickPolicyS3std5regex8internal2ir__T5RegexTaZQjZSQEcQDwQDrQDn
.dub\build\cygwin-debug-windows-x86-dmd_2078-270D5D6B34387418CFDA6A068E7A60D9\kameloso.obj(kameloso)  Offset 7AE18H Record Type 00C3
 Error 1: Previous Definition Different : _D8kameloso7plugins6common8BotRegex6__ctorMFNcS3std5regex8internal2ir__T5RegexTaZQjZSQDfQCzQCuQCq
Error: linker exited with status 2
dmd failed with exit code 2.

LDC 1.7.0 builds just fine.

There are similar error messages when compiling on linux, but they don't error out (linking succeeds despite them).

/usr/bin/ld: Warning: size of symbol `_D8kameloso7plugins6common8BotRegex6__ctorMFNcxEQBuQBoQBj10NickPolicyS3std5regex8internal2ir__T5RegexTaZQjZSQEcQDwQDrQDn' changed from 46 in .dub/build/posix-debug-linux.posix-x86_64-dmd_2078-8E23DC2771FEB27EF0FE1CC8F3984CAA/kameloso.o to 49 in .dub/build/posix-debug-linux.posix-x86_64-dmd_2078-8E23DC2771FEB27EF0FE1CC8F3984CAA/kameloso.o
/usr/bin/ld: Warning: size of symbol `_D8kameloso7plugins6common8BotRegex6__ctorMFNcS3std5regex8internal2ir__T5RegexTaZQjZSQDfQCzQCuQCq' changed from 40 in .dub/build/posix-debug-linux.posix-x86_64-dmd_2078-8E23DC2771FEB27EF0FE1CC8F3984CAA/kameloso.o to 43 in .dub/build/posix-debug-linux.posix-x86_64-dmd_2078-8E23DC2771FEB27EF0FE1CC8F3984CAA/kameloso.o

I don't have a reduced testcase yet. I figured I'd ask if it's something known before making the effort.
January 10, 2018
Am 10.01.2018 um 20:32 schrieb Anonymouse:
> 
> I don't have a reduced testcase yet. I figured I'd ask if it's something known before making the effort.

Are you by any chance mixing debug and release builds? Or are the -version specifiers different when compiling the various parts of your program? Check your compiler flags and ansure that they are the same over your entire build process. Especiall -debug -relase -inline -O -version

-- 
Kind Regards
Benjamin Thaut
January 10, 2018
On Wednesday, 10 January 2018 at 19:32:28 UTC, Anonymouse wrote:
> /usr/bin/ld: Warning: size of symbol

I think your case is this bug:
https://issues.dlang.org/show_bug.cgi?id=15324

Another COMDAT error is: https://issues.dlang.org/show_bug.cgi?id=16687
January 10, 2018
On Wednesday, 10 January 2018 at 20:19:50 UTC, Benjamin Thaut wrote:
> Am 10.01.2018 um 20:32 schrieb Anonymouse:
>> 
>> I don't have a reduced testcase yet. I figured I'd ask if it's something known before making the effort.
>
> Are you by any chance mixing debug and release builds? Or are the -version specifiers different when compiling the various parts of your program? Check your compiler flags and ansure that they are the same over your entire build process. Especiall -debug -relase -inline -O -version

Admittedly I am alternating between building debug and unittest builds, but I'm only using dub, no separate compilation. I have limited control of the version specifiers other than through the build configurations, so there's not a whole lot to mix.

    $ dub clean
    Cleaning package at C:\cygwin\home\zorael\src\kameloso...

    $ dub build -c cygwin -a x86_64
    Performing "debug" build using dmd for x86_64.
    kameloso 1.0.0-beta.2+commit.57.g90fdd1d: building configuration "cygwin"...
    Linking...
    kameloso.obj : fatal error LNK1179: invalid or corrupt file: duplicate COMDAT '_D8kameloso7plugins6common8BotRegex6__ctorMFNcxEQBuQBoQBj10NickPolicyS3std5regex8internal2ir__T5RegexTaZQjZSQEcQDwQDrQDn'
    Error: linker exited with status 1179
    dmd failed with exit code 1179.

None of the (version specifiers in the) build configurations I have touch upon the part of the fairly innocent code mentioned in the error message, if I'm reading it right. (https://github.com/zorael/kameloso/blob/c00ca4489e39348bd4b1678c95c1b12636df307c/source/kameloso/plugins/common.d#L424)
January 12, 2018
On Wednesday, 10 January 2018 at 20:53:24 UTC, Anonymouse wrote:
> None of the (version specifiers in the) build configurations I have touch upon the part of the fairly innocent code mentioned in the error message, if I'm reading it right. (https://github.com/zorael/kameloso/blob/c00ca4489e39348bd4b1678c95c1b12636df307c/source/kameloso/plugins/common.d#L424)

struct Foo
{
    this(Regex!char) { /* ... */ }
    this(StaticRegex!char) { /* ... */ }
}

It seems like the problem there is that StaticRegex is only an alias to Regex, so I'm overloading it twice. It rhymes well with the linked bug.

/++
    A $(D StaticRegex) is $(D Regex) object that contains D code specially
    generated at compile-time to speed up matching.
    No longer used, kept as alias to Regex for backwards compatibility.
+/
public alias StaticRegex = Regex;  // <--

Reducing it to just that doesn't reproduce the error message though. As long as Regex!char can house both ctRegex!"foo" and "foo".regex it works for me.