Skip to content

Commit eb70b48

Browse files
authored
[mlir][bazel] Export more headers by a single target only. (#86637)
Ideally, header files should be used by only one target, but this is hard because CMake is less strict with headers (no layering check). But even with bazel, headers should only be exported once in the `hdrs` attribute. Other targets may use them in the `srcs` attribute to avoid circular dependencies.
1 parent 4d315ff commit eb70b48

File tree

2 files changed

+27
-25
lines changed

2 files changed

+27
-25
lines changed

mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include "mlir/Interfaces/InferTypeOpInterface.h"
3131
#include "mlir/Interfaces/SideEffectInterfaces.h"
3232
#include "mlir/Support/ThreadLocalCache.h"
33-
#include "mlir/Transforms/Mem2Reg.h"
3433
#include "llvm/ADT/PointerEmbeddedInt.h"
3534
#include "llvm/IR/DerivedTypes.h"
3635
#include "llvm/IR/LLVMContext.h"

utils/bazel/llvm-project-overlay/mlir/BUILD.bazel

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3823,9 +3823,10 @@ cc_library(
38233823
srcs = glob([
38243824
"lib/Dialect/*.cpp",
38253825
]),
3826-
hdrs = glob([
3827-
"include/mlir/Dialect/*.h",
3828-
]),
3826+
hdrs = glob(
3827+
include = ["include/mlir/Dialect/*.h"],
3828+
exclude = ["include/mlir/Dialect/CommonFolders.h"],
3829+
),
38293830
includes = ["include"],
38303831
deps = [
38313832
":IR",
@@ -4534,6 +4535,7 @@ cc_library(
45344535
":ArithDialect",
45354536
":BufferizationInterfaces",
45364537
":CastInterfaces",
4538+
":CommonFolders",
45374539
":ControlFlowInterfaces",
45384540
":Dialect",
45394541
":FuncDialect",
@@ -5336,9 +5338,7 @@ cc_library(
53365338
"include/mlir/Dialect/LLVMIR/VCIX*.h",
53375339
"include/mlir/Dialect/LLVMIR/*X86Vector*.h",
53385340
],
5339-
) + [
5340-
"include/mlir/Transforms/Mem2Reg.h",
5341-
],
5341+
),
53425342
includes = ["include"],
53435343
deps = [
53445344
":CallOpInterfaces",
@@ -8635,17 +8635,26 @@ cc_library(
86358635
],
86368636
)
86378637

8638+
cc_library(
8639+
name = "ParseUtilities",
8640+
hdrs = ["include/mlir/Tools/ParseUtilities.h"],
8641+
includes = ["include"],
8642+
deps = [
8643+
":IR",
8644+
":Parser",
8645+
],
8646+
)
8647+
86388648
cc_library(
86398649
name = "TranslateLib",
86408650
srcs = glob([
86418651
"lib/Tools/mlir-translate/*.cpp",
8642-
]) + [
8643-
"include/mlir/Tools/ParseUtilities.h",
8644-
],
8652+
]),
86458653
hdrs = glob(["include/mlir/Tools/mlir-translate/*.h"]),
86468654
includes = ["include"],
86478655
deps = [
86488656
":IR",
8657+
":ParseUtilities",
86498658
":Parser",
86508659
":Support",
86518660
"//llvm:Support",
@@ -8655,6 +8664,7 @@ cc_library(
86558664
cc_library(
86568665
name = "ToLLVMIRTranslation",
86578666
srcs = [
8667+
"lib/Target/LLVMIR/AttrKindDetail.h",
86588668
"lib/Target/LLVMIR/DebugTranslation.cpp",
86598669
"lib/Target/LLVMIR/DebugTranslation.h",
86608670
"lib/Target/LLVMIR/LoopAnnotationTranslation.cpp",
@@ -8667,7 +8677,6 @@ cc_library(
86678677
"include/mlir/Target/LLVMIR/LLVMTranslationInterface.h",
86688678
"include/mlir/Target/LLVMIR/ModuleTranslation.h",
86698679
"include/mlir/Target/LLVMIR/TypeToLLVM.h",
8670-
"lib/Target/LLVMIR/AttrKindDetail.h",
86718680
],
86728681
includes = ["include"],
86738682
deps = [
@@ -8988,9 +8997,11 @@ cc_library(
89888997
cc_library(
89898998
name = "FromLLVMIRTranslation",
89908999
srcs = [
9000+
"lib/Target/LLVMIR/AttrKindDetail.h",
89919001
"lib/Target/LLVMIR/DataLayoutImporter.cpp",
89929002
"lib/Target/LLVMIR/DataLayoutImporter.h",
89939003
"lib/Target/LLVMIR/DebugImporter.cpp",
9004+
"lib/Target/LLVMIR/DebugImporter.h",
89949005
"lib/Target/LLVMIR/LoopAnnotationImporter.cpp",
89959006
"lib/Target/LLVMIR/LoopAnnotationImporter.h",
89969007
"lib/Target/LLVMIR/ModuleImport.cpp",
@@ -9001,8 +9012,6 @@ cc_library(
90019012
"include/mlir/Target/LLVMIR/LLVMImportInterface.h",
90029013
"include/mlir/Target/LLVMIR/ModuleImport.h",
90039014
"include/mlir/Target/LLVMIR/TypeFromLLVM.h",
9004-
"lib/Target/LLVMIR/AttrKindDetail.h",
9005-
"lib/Target/LLVMIR/DebugImporter.h",
90069015
],
90079016
includes = ["include"],
90089017
deps = [
@@ -9109,10 +9118,7 @@ cc_library(
91099118

91109119
cc_library(
91119120
name = "MlirOptLib",
9112-
srcs = [
9113-
"include/mlir/Tools/ParseUtilities.h",
9114-
"lib/Tools/mlir-opt/MlirOptMain.cpp",
9115-
],
9121+
srcs = ["lib/Tools/mlir-opt/MlirOptMain.cpp"],
91169122
hdrs = ["include/mlir/Tools/mlir-opt/MlirOptMain.h"],
91179123
includes = ["include"],
91189124
deps = [
@@ -9121,6 +9127,7 @@ cc_library(
91219127
":Debug",
91229128
":IR",
91239129
":IRDLDialect",
9130+
":ParseUtilities",
91249131
":Parser",
91259132
":Pass",
91269133
":PluginsLib",
@@ -9393,10 +9400,7 @@ cc_binary(
93939400
cc_library(
93949401
name = "MlirJitRunner",
93959402
srcs = ["lib/ExecutionEngine/JitRunner.cpp"],
9396-
hdrs = [
9397-
"include/mlir/ExecutionEngine/JitRunner.h",
9398-
"include/mlir/Tools/ParseUtilities.h",
9399-
],
9403+
hdrs = ["include/mlir/ExecutionEngine/JitRunner.h"],
94009404
includes = ["include"],
94019405
deps = [
94029406
":AllPassesAndDialects",
@@ -9407,6 +9411,7 @@ cc_library(
94079411
":LLVMToLLVMIRTranslation",
94089412
":OpenACCToLLVMIRTranslation",
94099413
":OpenMPToLLVMIRTranslation",
9414+
":ParseUtilities",
94109415
":Parser",
94119416
":SCFToControlFlow",
94129417
":Support",
@@ -13786,13 +13791,11 @@ cc_library(
1378613791
cc_library(
1378713792
name = "MlirReduceLib",
1378813793
srcs = ["lib/Tools/mlir-reduce/MlirReduceMain.cpp"],
13789-
hdrs = [
13790-
"include/mlir/Tools/ParseUtilities.h",
13791-
"include/mlir/Tools/mlir-reduce/MlirReduceMain.h",
13792-
],
13794+
hdrs = ["include/mlir/Tools/mlir-reduce/MlirReduceMain.h"],
1379313795
includes = ["include"],
1379413796
deps = [
1379513797
":IR",
13798+
":ParseUtilities",
1379613799
":Parser",
1379713800
":Pass",
1379813801
":Reducer",

0 commit comments

Comments
 (0)