This is an archive of the discontinued LLVM Phabricator instance.

Don't define //mlir:MLIRBindingsPythonCore in terms of the NoCAPI and CAPIDeps targets.
ClosedPublic

Authored by phawkins on Nov 12 2021, 7:11 AM.

Details

Summary

We noticed that the library structure causes link ordering problems in Google's internal build. However, we don't think the problem is specific to Google's build, it probably can be reproduced anywhere with the right library structure.

In general splitting the Python bindings from their dependencies (the C API targets) creates the possibility that the two libraries might end up in the wrong order on the linker command line. We can avoid this problem happening by reverting the structure of the MLIRBindingsPythonCore to represent its dependencies in the usual way, rather than composing an incomplete MLIRBindingsPythonCoreNoCAPI target and their CAPI dependencies. It was probably a mistake to rewrite this particular cc_library() rule in terms of the two, since nothing guarantees that the two will be correctly ordered by the linker when both are being linked into the same binary, and it was only an incidental "cleanup" done in passing.

Otherwise the previous PR (D113565) is fine, since that was about the case where both are being built into two separate shared libraries. It just shouldn't have made this (unrelated) change.

Diff Detail

Event Timeline

phawkins created this revision.Nov 12 2021, 7:11 AM
phawkins requested review of this revision.Nov 12 2021, 7:11 AM
GMNGeoffrey accepted this revision.Nov 12 2021, 10:42 AM

Is there something special about Google's internal version of Bazel that would make this different? Or just that's where you noticed it and it's a potential problem in OSS as well? I want to make sure we're making the decisions that make the most sense for Bazel users (the differences between Bazel and Blaze are on Google(rs) to figure out IMO)

This revision is now accepted and ready to land.Nov 12 2021, 10:42 AM
phawkins edited the summary of this revision. (Show Details)Nov 12 2021, 11:55 AM

Updated the PR description to clarify that this problem might be seen generally. Please take a look!

Updated the PR description to clarify that this problem might be seen generally. Please take a look!

Thanks for adding the extra detail :-) I'll land now