Skip to content

Duplicate definition of symbol error to do with mergable comdat constant symbols on Windows/COFF #39421

@mvhooren

Description

@mvhooren
Bugzilla Link 40074
Resolution FIXED
Resolved on Jan 22, 2020 15:03
Version trunk
OS Windows NT
CC @AlexDenisov,@lhames,@vchuravy

Extended Description

It happens when the same literal is defined twice, each in a different module and after the second module has been added to the RTDyldObjectLinkingLayer.

So for example in some module:

define float @​someFunction() {
entry:
ret float 2.000000e+00
}

In some other module:
define float @​someOtherFunction() {
entry:
ret float 2.000000e+00
}

When materializing the second function, you will get this error:

JIT session error: Duplicate definition of symbol '__real@40000000'

The symbol names come from comdat symbols that are created in TargetLoweringObjectFileImpl.cpp TargetLoweringObjectFileCOFF::getSectionForConstant

For COFF, I have the OverrideObjectFlagsWithResponsibilityFlags and AutoClaimResponsibilityForObjectSymbols set to true on the RTDyldObjectLinkingLayer or my function symbols are not found at all.

The same code compiles and runs just fine on Linux/Elf, even with the COFF workarounds enabled there as well.

A workaround I found is to set HasCOFFComdatConstants to false in MCAsmInfoCOFF.cpp

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaorcjit

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions