Skip to content

Add missing dep on MLIRToLLVMIRTranslationRegistration to mlir-opt. #75111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 12, 2023

Conversation

stellaraccident
Copy link
Contributor

I was not able to fully triage why this just started failing on one of our bots as it seems that the use was added 4 months ago. I would assume that it was accidentally coming in transitively in some way as the dep was definitely missing.

For context, this started failing in our byo_llvm build on a stock build of MLIR on top of an existing LLVM. We were getting:

ld.lld: error: undefined symbol: mlir::registerSPIRVDialectTranslation(mlir::DialectRegistry&)                                                        >>> referenced by mlir-opt.cpp
>>>               tools/mlir-opt/CMakeFiles/mlir-opt.dir/mlir-opt.cpp.o:(main)

I was not able to fully triage why this just started failing on one of our bots as it seems that the use was added 4 months ago. I would assume that it was accidentally coming in transitively in some way as the dep was definitely missing.

For context, this started failing in [our byo_llvm](https://github.com/openxla/iree/blob/main/build_tools/llvm/byo_llvm.sh) build on a stock build of MLIR on top of an existing LLVM. We were getting:

```
ld.lld: error: undefined symbol: mlir::registerSPIRVDialectTranslation(mlir::DialectRegistry&)                                                        >>> referenced by mlir-opt.cpp
>>>               tools/mlir-opt/CMakeFiles/mlir-opt.dir/mlir-opt.cpp.o:(main)
```
@llvmbot llvmbot added mlir:core MLIR Core Infrastructure mlir labels Dec 11, 2023
@llvmbot
Copy link
Member

llvmbot commented Dec 11, 2023

@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-mlir-core

Author: Stella Laurenzo (stellaraccident)

Changes

I was not able to fully triage why this just started failing on one of our bots as it seems that the use was added 4 months ago. I would assume that it was accidentally coming in transitively in some way as the dep was definitely missing.

For context, this started failing in our byo_llvm build on a stock build of MLIR on top of an existing LLVM. We were getting:

ld.lld: error: undefined symbol: mlir::registerSPIRVDialectTranslation(mlir::DialectRegistry&)                                                        >>> referenced by mlir-opt.cpp
>>>               tools/mlir-opt/CMakeFiles/mlir-opt.dir/mlir-opt.cpp.o:(main)

Full diff: https://github.com/llvm/llvm-project/pull/75111.diff

2 Files Affected:

  • (modified) mlir/tools/mlir-opt/CMakeLists.txt (+4)
  • (modified) mlir/tools/mlir-opt/mlir-opt.cpp (+4)
diff --git a/mlir/tools/mlir-opt/CMakeLists.txt b/mlir/tools/mlir-opt/CMakeLists.txt
index 88a0562cb6e720..4d3d9173a93662 100644
--- a/mlir/tools/mlir-opt/CMakeLists.txt
+++ b/mlir/tools/mlir-opt/CMakeLists.txt
@@ -66,6 +66,10 @@ set(LIBS
   MLIRTransformUtils
   MLIRSupport
   MLIRIR
+
+  # TODO: Remove when registerAllGPUToLLVMIRTranslations is no longer
+  # registered directly in mlir-opt.cpp.
+  MLIRToLLVMIRTranslationRegistration
   )
 
 # Exclude from libMLIR.so because this has static options intended for
diff --git a/mlir/tools/mlir-opt/mlir-opt.cpp b/mlir/tools/mlir-opt/mlir-opt.cpp
index 3e3223b4850560..bd990bbfea84d8 100644
--- a/mlir/tools/mlir-opt/mlir-opt.cpp
+++ b/mlir/tools/mlir-opt/mlir-opt.cpp
@@ -274,6 +274,10 @@ int main(int argc, char **argv) {
   DialectRegistry registry;
   registerAllDialects(registry);
   registerAllExtensions(registry);
+
+  // TODO: Remove this and the corresponding MLIRToLLVMIRTranslationRegistration
+  // cmake dependency when a safe dialect interface registration mechanism is
+  // implemented, see D157703 (and corresponding note on the declaration).
   registerAllGPUToLLVMIRTranslations(registry);
 
 #ifdef MLIR_INCLUDE_TESTS

@stellaraccident
Copy link
Contributor Author

According to our CI logs, this appears to have broken somewhere between 13da9a5 (good) and 9fa3455 (bad). But as the dep was clearly missing, I considered it a better use of time to fix it than bisect and root cause. Scanning the patches, nothing jumped out, so I assume this was just something transitive that was accidentally working.

@joker-eph
Copy link
Collaborator

I think the issue was introduced in 7fc792c ?

@stellaraccident
Copy link
Contributor Author

stellaraccident commented Dec 12, 2023

I think the issue was introduced in 7fc792c ?

I wonder how I missed this. I think I fell for the issue where my blame line was reporting patch timestamp, not commit time. I read past it since the view I had showed it as originating 4 months ago :/ (granted, I didn't try very hard to isolate it)

@stellaraccident stellaraccident merged commit 8eff570 into llvm:main Dec 12, 2023
@stellaraccident stellaraccident deleted the mlir_opt_spirv_dep branch December 13, 2023 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mlir:core MLIR Core Infrastructure mlir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants