This is an archive of the discontinued LLVM Phabricator instance.

[MLIR] Fix build with make
ClosedPublic

Authored by nikic on May 5 2022, 7:04 AM.

Details

Summary

https://reviews.llvm.org/D124075 causes MLIR to no longer build when using make rather than ninja, due to a tablegen-generated header being used before it is created.

It seems that this is related to the use of LLVM_ENABLE_OBJLIB when using add_tablgen with a non-Ninja/Xcode generator. In that case an intermediate obj target is generated.

This patch fixes the issue by a) declaring dependencies in add_tablegen for mlir-pdll and b) making sure those dependencies are added to the obj target.

Diff Detail

Event Timeline

nikic created this revision.May 5 2022, 7:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 5 2022, 7:04 AM
nikic requested review of this revision.May 5 2022, 7:04 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptMay 5 2022, 7:04 AM

Looks good to me, but I'd love an extra ack from someone in the mlir project. @mehdi_amini ?

marbre added a subscriber: marbre.May 5 2022, 8:03 AM

I am currently out-of-office and don‘t have any access to my build machines. Therefore, I cannot test and confirm that the patch doesn‘t have unintended side effects. However, there is definitely a need to add a dependency to the tablgen generated header files. Sorry for missing this as part of https://reviews.llvm.org/D124851. I would suggest to take a look how this is done for MLIR dialects, where explicits deps to the generated targets are passed to add_mlir_dialect_library like in https://github.com/llvm/llvm-project/blob/04b419048955fc33718ba97e79f3558b6a27830e/mlir/lib/Dialect/EmitC/IR/CMakeLists.txt#L7-L9. It might not be necessary to touch AddLLVM and I assume the deps should rather be on the *IncGen target,

nikic added a comment.May 5 2022, 8:44 AM

I am currently out-of-office and don‘t have any access to my build machines. Therefore, I cannot test and confirm that the patch doesn‘t have unintended side effects. However, there is definitely a need to add a dependency to the tablgen generated header files. Sorry for missing this as part of https://reviews.llvm.org/D124851. I would suggest to take a look how this is done for MLIR dialects, where explicits deps to the generated targets are passed to add_mlir_dialect_library like in https://github.com/llvm/llvm-project/blob/04b419048955fc33718ba97e79f3558b6a27830e/mlir/lib/Dialect/EmitC/IR/CMakeLists.txt#L7-L9. It might not be necessary to touch AddLLVM and I assume the deps should rather be on the *IncGen target,

I did try just adding MLIRBuiltinAttributeInterfacesIncGen under DEPENDS first, but this ultimately doesn't do anything useful without the change to AddLLVM, because the the intermediate objlib target (for non-ninja generators) essentially means that mlir-pdll depends on both mlir-pdll.cpp.o and MLIRBuiltinAttributeInterfacesIncGen and these are not sequenced (what we need is for mlir-pdll.cpp.o to depend on MLIRBuiltinAttributeInterfacesIncGen).

As to depending directly on *IncGen targets, I can change it in that direction -- my thought here was that the exact dependencies of the headers are something of an implementation detail. But if other areas already hardcode these, then also doing that here makes sense to me as well.

rriddle accepted this revision.May 5 2022, 9:42 AM

This looks reasonable to me.

This revision is now accepted and ready to land.May 5 2022, 9:42 AM

I am currently out-of-office and don‘t have any access to my build machines. Therefore, I cannot test and confirm that the patch doesn‘t have unintended side effects. However, there is definitely a need to add a dependency to the tablgen generated header files. Sorry for missing this as part of https://reviews.llvm.org/D124851. I would suggest to take a look how this is done for MLIR dialects, where explicits deps to the generated targets are passed to add_mlir_dialect_library like in https://github.com/llvm/llvm-project/blob/04b419048955fc33718ba97e79f3558b6a27830e/mlir/lib/Dialect/EmitC/IR/CMakeLists.txt#L7-L9. It might not be necessary to touch AddLLVM and I assume the deps should rather be on the *IncGen target,

I did try just adding MLIRBuiltinAttributeInterfacesIncGen under DEPENDS first, but this ultimately doesn't do anything useful without the change to AddLLVM, because the the intermediate objlib target (for non-ninja generators) essentially means that mlir-pdll depends on both mlir-pdll.cpp.o and MLIRBuiltinAttributeInterfacesIncGen and these are not sequenced (what we need is for mlir-pdll.cpp.o to depend on MLIRBuiltinAttributeInterfacesIncGen).

As to depending directly on *IncGen targets, I can change it in that direction -- my thought here was that the exact dependencies of the headers are something of an implementation detail. But if other areas already hardcode these, then also doing that here makes sense to me as well.

Your thought is right here, the IncGen should already be provided via MLIRIR. Most IncGen shouldn't be depended on directly.

This revision was landed with ongoing or failed builds.May 6 2022, 5:52 AM
This revision was automatically updated to reflect the committed changes.