This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Bazel] Avoid __attribute__((weak)) for MSVC.
ClosedPublic

Authored by akuegel on Mar 20 2023, 12:29 AM.

Diff Detail

Event Timeline

akuegel created this revision.Mar 20 2023, 12:29 AM
akuegel requested review of this revision.Mar 20 2023, 12:29 AM
csigg added a comment.Mar 20 2023, 1:46 AM

It seems this would result in duplicate definitions of mlir::registerGpuSerializeToCubinPass() on Windows.

Maybe we could use /alternatename?
I'm not sure how to handle mangled names though.

Alternatively, the above article also links to this approach, but getting bazel (and CMake) to link in a specific way might be tricky.

akuegel added a comment.EditedMar 20 2023, 1:49 AM

It seems this would result in duplicate definitions of mlir::registerGpuSerializeToCubinPass() on Windows.

Maybe we could use /alternatename?
I'm not sure how to handle mangled names though.

Alternatively, the above article also links to this approach, but getting bazel (and CMake) to link in a specific way might be tricky.

Yes, there would be duplicate definitions. MSVC would just pick one of them. But at least it would not result in a compilation error. Currently Tensorflow is broken because of this, although it does not even care about running the MLIR tests, so which definition is picked is not important in that use case.

csigg accepted this revision.Mar 20 2023, 2:02 AM

Ok, but it would be good to add a comment that this might not work on Windows.

This revision is now accepted and ready to land.Mar 20 2023, 2:02 AM
akuegel updated this revision to Diff 506502.Mar 20 2023, 2:09 AM

Add comment to explain that it might not work correctly.

akuegel updated this revision to Diff 506503.Mar 20 2023, 2:10 AM

Fix comment.

This revision was automatically updated to reflect the committed changes.