Conversation
… in MLIR's static initializers + only register dependent dialects (not all) Signed-off-by: Bardia Mahjour <bmahjour@ca.ibm.com>
2f24ec4 to
e3afd26
Compare
Signed-off-by: Bardia Mahjour <bmahjour@ca.ibm.com>
|
@bmahjour thank you for the PR, if you dont mind can I clarify your following statement
may I check which MLIR version are you facing this error? I have built this repo on my Mac as well and I do not see this error for newer LLVM versions. If you would like, the following Visual Studio devcontainer build, uses a quite recent This devcontainer build can be found in my fork, and its quite easy to try
|
|
We are hitting this error with LLVM 22.1.0 4434dabb69916856b824f68a64b029c67175e532 on Mac with the following build compiler: |
|
@bmahjour ok i created an issue #11 to add a @mudhakar there could be a possibility (see issue here) that we would settle on a stable LLVM version, and given that there are users like @bmahjour who are building against these versions on mac, perhaps it would be good to add a CI workflow to test against. If we decide that we will go to bleeding-edge, we can deprecate this ci workflow; it is something that could be useful in the interim |
|
@bmahjour just digging abit deeper into this issue, I tried building on the same I think your problem is your apple clang compiler is too old, what I did was to rely on the |
|
The link-time optimization behavior may be different across different linkers (eg. lld vs gnu ld) and may also change from release to release for a given linker. The proposed changes in this PR ensure we get consistent behavior. |
@bmahjour thank you. Do you mind if I update the branch so that we can test against the latest CI? Maybe would be good to have #14 merged first and we can test these changes on 3 setups. I verified these changes locally in my mac on v22.1.3. |
|
@bmahjour thank you for the PR and for investigating this issue. After discussion, we'd like to share our findings and concerns with @mudhakar @raghukiran1224 @kiszk @Prasanth-Chatarasi before proceeding. The bug is not reproducible in our CIWe ran the unmodified
Both runs use the GitHub-hosted Concerns with the proposed changesEven setting aside reproducibility, we have several concerns with the changes as proposed:
RecommendationWe'd prefer not to merge this as-is, but we're open to revisiting if we can validate the changes against downstream consumers. ktir-cpu PR #24 is in the process of switching its We'd also like other maintainers to weigh in with their thoughts on this. |
|
Since there is now a new build system, this PR is outdated, but its contents are still relevant. Note that we're usually building against an MLIR DSO, which does not suffer from this issue. There's actually a second angle to this, which is downstream ODR violations. As long as this PR is only about changing the linking behavior of the tool executable, there is no problem there. However, in the case of linking on other shared artifacts, the usage of |

MLIR relies heavily on static initialization of states in global constructors. Some linkers may throw away symbols that are only referenced in static initializers since they are not part of any call chain starting from main. This causes the following error (on MacOS):
This PR
-all_loador--whole-archiveto force linkers to keep all symbols in MLIR libraries.registry.insert<>()rather thanmlir::registerAllDialects()to only register dialects that are actually needed.