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

Maksim Levental llvmlistbot at llvm.org
Mon May 26 10:00:13 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}")
----------------
makslevental wrote:

> I would discourage that, but yes it's possible.

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).

> they all should add `EXCLUDE_FROM_LIBMLIR`

why? that's not what the doc string says 

```
# EXCLUDE_FROM_LIBMLIR
#   Don't include this library in libMLIR.so.  This option should be used
#   for test libraries, executable-specific libraries, or rarely used libraries
#   with large dependencies... 
```

and it's also a fairly reasonable use-case (downstream project wants to build an aggregate that also includes their downstream code)

> Nope, as soon as you have genex you need genex to do any manipulation.

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

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


More information about the Mlir-commits mailing list