Skip to content

Duplicate symbols - getGenOpMix<ONNXRoundOp> - on Windows builds #3254

@mschofie

Description

@mschofie

I'm trying to get onnx-mlir building on Windows, using Visual Studio 2022. I've worked through a few issues - see PR3253 - but this issue is something that I'd need guidance on, since I'm not familiar with the code.

getGenOpMix<> is a function template declared in src/Conversion/ONNXToKrnl/ONNXToKrnlCommon.hpp. src/Conversion/ONNXToKrnl/Quantization/QuantizeLinear.cpp calls the getGenOpMix<ONNXRoundOp> which will instantiate the template. src\Conversion\ONNXToKrnl\Math\Elementwise.cpp provides an explicit specialization of getGenOpMix<ONNXRoundOp> (here), and MSVC logs a warning:

warning LNK4006: "class llvm::SmallDenseMap<enum onnx_mlir::GenericOps,__int64,8,struct llvm::DenseMapInfo<enum onnx_mlir::GenericOps,void>,struct llvm::detail::DenseMapPair<enum onnx_mlir::GenericOps,__int64> > __cdecl onnx_mlir::getGenOpMix<class mlir::ONNXRoundOp>(class mlir::Type,class mlir::Operation *)" (??$getGenOpMix@VONNXRoundOp@mlir@@@onnx_mlir@@YA?AV?$SmallDenseMap@W4GenericOps@onnx_mlir@@_J$07U?$DenseMapInfo@W4GenericOps@onnx_mlir@@X@llvm@@U?$DenseMapPair@W4GenericOps@onnx_mlir@@_J@detail@4@@llvm@@VType@mlir@@PEAVOperation@4@@Z) already defined in QuantizeLinear.cpp.obj; second definition ignored

So MSVC is dropping one of the definitions on the floor - which one it picks is not defined. Any guidance as to whether both consumers should use the explicit specialization, or should only Elementwise.cpp use the explicit specialization?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions