Skip to content

Commit

Permalink
CMake: Do not specify LLVMSupport in LINK_LIBS. (#2575)
Browse files Browse the repository at this point in the history
This is a new take on #2573.

There, I was trying to fix CMake errors in the external build, with the
error message saying that `LINK_COMPONENTS` should be used instead of
`LINK_LIBS` for LLVM libraries. That change fixed my external build, but
broke the standalone build on CI.

Reading the `AddMLIR.cmake` code generating the error, I came across
this line:

https://github.com/llvm/llvm-project/blob/ee4dd147baff8f971f3ec5aad5a216ca9837a732/mlir/cmake/modules/AddMLIR.cmake#L287-L288

```cmake
  # MLIR libraries uniformly depend on LLVMSupport.  Just specify it once here.
  list(APPEND ARG_LINK_COMPONENTS Support)
```

This looks like hardcoding always depending on `LLVMSupport` (though I
wasn't quite sure about the nuance between `Support` and `LLVMSupport`).
If that's correct, then we never needed specifying `LLVMSupport` in the
first place. So I tried just omitting it, and that seems to work. WDYT?

---------

Signed-off-by: Benoit Jacob <jacob.benoit.1@gmail.com>
  • Loading branch information
bjacob authored Oct 3, 2024
1 parent 24a3664 commit 5f3c287
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
4 changes: 1 addition & 3 deletions stablehlo/integrations/c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ add_mlir_public_c_api_library(ChloCAPI

LINK_LIBS PUBLIC
ChloOps
LLVMSupport
)

add_mlir_public_c_api_library(StablehloCAPI
Expand All @@ -40,10 +39,9 @@ add_mlir_public_c_api_library(StablehloCAPI
StablehloTypes.cpp

LINK_LIBS PUBLIC
LLVMSupport
MLIRCAPIIR
MLIRIR
MLIRSupport
MLIRSupport # LLVMSupport is automatically added in AddLLVM.cmake.
StablehloOps
StablehloPasses
StablehloPortableApi
Expand Down
27 changes: 13 additions & 14 deletions stablehlo/reference/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ add_mlir_library(StablehloReferenceApi
MLIRIR
MLIRParser
MLIRPass
MLIRSupport
MLIRSupport # LLVMSupport is automatically added in AddLLVM.cmake.
InterpreterOps
StablehloPasses
StablehloReferenceConfiguration
Expand All @@ -40,15 +40,15 @@ add_mlir_library(StablehloReferenceAxes

LINK_LIBS PUBLIC
MLIRIR
MLIRSupport
MLIRSupport # LLVMSupport is automatically added in AddLLVM.cmake.
)

add_mlir_library(StablehloReferenceConfiguration
PARTIAL_SOURCES_INTENDED
Configuration.cpp

LINK_LIBS PUBLIC
MLIRSupport
MLIRSupport # LLVMSupport is automatically added in AddLLVM.cmake.
StablehloReferenceErrors
StablehloReferenceProcess
StablehloReferenceScope
Expand All @@ -60,7 +60,7 @@ add_mlir_library(StablehloReferenceElement

LINK_LIBS PUBLIC
MLIRIR
MLIRSupport
MLIRSupport # LLVMSupport is automatically added in AddLLVM.cmake.
StablehloReferenceTypes
)

Expand All @@ -70,7 +70,7 @@ add_mlir_library(StablehloReferenceErrors

LINK_LIBS PUBLIC
MLIRIR
MLIRSupport
MLIRSupport # LLVMSupport is automatically added in AddLLVM.cmake.
)

add_mlir_library(StablehloReferenceIndex
Expand All @@ -79,7 +79,7 @@ add_mlir_library(StablehloReferenceIndex

LINK_LIBS PUBLIC
MLIRIR
MLIRSupport
MLIRSupport # LLVMSupport is automatically added in AddLLVM.cmake.
)

set(LLVM_TARGET_DEFINITIONS InterpreterOps.td)
Expand All @@ -102,7 +102,7 @@ add_mlir_dialect_library(InterpreterOps
StablehloReferenceOps
StablehloReferenceProcessGrid
MLIRIR
MLIRSupport
MLIRSupport # LLVMSupport is automatically added in AddLLVM.cmake.
)

set(LLVM_TARGET_DEFINITIONS InterpreterPasses.td)
Expand All @@ -120,7 +120,7 @@ add_mlir_library(InterpreterPasses
InterpreterOps
MLIRIR
MLIRPass
MLIRSupport
MLIRSupport # LLVMSupport is automatically added in AddLLVM.cmake.
MLIRTransforms
MLIRTransformUtils
)
Expand Down Expand Up @@ -169,9 +169,8 @@ add_mlir_library(StablehloReferenceProcessGrid
ProcessGrid.cpp

LINK_LIBS PUBLIC
LLVMSupport
MLIRIR
MLIRSupport
MLIRSupport # LLVMSupport is automatically added in AddLLVM.cmake.
StablehloReferenceTensor
)

Expand All @@ -183,7 +182,7 @@ add_mlir_library(StablehloReferenceScope
StablehloReferenceValue
StablehloReferenceTensor
StablehloReferenceToken
MLIRSupport
MLIRSupport # LLVMSupport is automatically added in AddLLVM.cmake.
)

add_mlir_library(StablehloReferenceTensor
Expand All @@ -205,7 +204,7 @@ add_mlir_library(StablehloReferenceToken

LINK_LIBS PUBLIC
MLIRIR
MLIRSupport
MLIRSupport # LLVMSupport is automatically added in AddLLVM.cmake.
StablehloOps
)

Expand All @@ -215,7 +214,7 @@ add_mlir_library(StablehloReferenceTypes

LINK_LIBS PUBLIC
MLIRIR
MLIRSupport
MLIRSupport # LLVMSupport is automatically added in AddLLVM.cmake.
)

add_mlir_library(StablehloReferenceValue
Expand All @@ -224,7 +223,7 @@ add_mlir_library(StablehloReferenceValue

LINK_LIBS PUBLIC
MLIRIR
MLIRSupport
MLIRSupport # LLVMSupport is automatically added in AddLLVM.cmake.
StablehloReferenceTensor
StablehloReferenceToken
)

0 comments on commit 5f3c287

Please sign in to comment.