[Mlir-commits] [mlir] [mlir][CMake] Modify the behavior of `add_mlir_aggregate ` and add `mlir_c_target_link_libraries`. (PR #141435)

Fabian Mora llvmlistbot at llvm.org
Mon May 26 10:29:17 PDT 2025


================
@@ -565,6 +580,26 @@ function(add_mlir_aggregate name)
       "    OBJECTS = ${_local_objects}\n"
       "    DEPS = ${_local_deps}\n\n")
   endforeach()
+  
+  if (MLIR_LINK_MLIR_DYLIB)
+    # This builds a regex with all the libraries contained in `libMLIR.so`.
+    # These libraries will be filtered out from the dependencies added by the
+    # EMBED_LIBS.
+    list(GET mlir_libs 0 _libs_regex)
+    list(REMOVE_AT mlir_libs 0)
+    set(_libs_regex "(${_libs_regex}")
+    foreach (lib ${mlir_libs})
+      string(APPEND _libs_regex "|${lib}")
----------------
fabianmcg wrote:

> I don't understand why? [it's very common](https://sourcegraph.com/search?q=context%3Aglobal+add_mlir_library&patternType=keyword&sm=0&__cc=1&df=%5B%22repo+topic%22%2C%22llvm%22%2C%22repo%3Ahas.topic%28llvm%29%22%5D&df=%5B%22file%22%2C%22Exclude+third+party%22%2C%22-file%3A%28%5E%7C%2F%29third%5B_%5C%5C-%5D%3Fparty%2F%22%5D).

I know, I do it too. But we should all have our infra, same thing with abusing the MLIR C++ namespace in downstream projects.

> why? that's not what the doc string says

That's because the doc string refers to upstream. If you don't set `EXCLUDE_FROM_LIBMLIR`, then the implicit contract is that the lib will be added to `libMLIR`, but that doesn't make sense for downstreams (forks of LLVM are a different story).

 > yes i'm asking if the MLIR_DIALECT_LIBS already had genexes in it (maybe $<TARGET_OBJECTS or something like that)

They do have (all in-tree targets in CMake have), but it's not what we want. As you would try to remove un-evaluated expressions and they would only work if they happen to be the same un evaluated expr.




https://github.com/llvm/llvm-project/pull/141435


More information about the Mlir-commits mailing list