Skip to content

Conversation

@RobotLeopard86
Copy link

Note

This is my first time submitting a PR to Meson, so I hope I did everything right. I just followed the Contributing page on the website.

I recently started having an issue configuring one of my projects on Windows. Meson would get through configuration and just never finish and spit out a build.ninja. I looked into it, and the problem seemed to be that in get_all_link_deps (build.py), the high numbers of interconnected static libraries from LLVM were causing the stack to get stuck in an infinite loop of adding the same libraries over and over, so it never emptied.

I fixed this by adding a second set of "nonresults": targets that are not results, but we have seen and thus already know to ignore for this calculation. Any potential target to be added to the stack must not be in the nonresults list. It's possible that this check incurs a slight performance penalty due to iterating over the targets and adding them one by one instead of in one huge batch. However, it does allow everything to successfully configure and have a Ninja file actually be generated.

I know that feature freeze is in 2 days, so this is a bit of a rushed, quick patch, but I hope I did everything correctly and this can get in for Meson 1.10.0.

I'm not the best with Python or Meson's internals (I'm a C++ guy), so I hope I did everything right. This shouldn't affect anything that relies on get_all_link_deps since it doesn't change the return value.

@RobotLeopard86
Copy link
Author

RobotLeopard86 commented Nov 24, 2025

Update: I rebased the changes from upstream into my fork via the GitHub interface. I made sure the button said "Rebase and merge". If I have done something incorrectly, please let me know.

@jpakkane Can you or someone else that is on the team please take a look at this?

@bonzini
Copy link
Collaborator

bonzini commented Nov 24, 2025

Nope, unfortunately it didn't do the right thing. To rebase just use git rebase origin/master from the command lines, then force-push the branch with git push -f.

@bonzini
Copy link
Collaborator

bonzini commented Nov 24, 2025

Also, please use git rebase -i origin/master and change the "fix" patch from pick to f, so that you get a single patch. Thanks in advance!

at link time, see get_dependencies() for that.
"""
result: OrderedSet[BuildTargetTypes] = OrderedSet()
nonresults: OrderedSet[BuildTargetTypes] = OrderedSet()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be a regular set:

nonresults: T.Set[BuildTargetTypes] = set()

which is faster than the ordered one.

@RobotLeopard86
Copy link
Author

Will do, thanks! I don't typically rebase, so not an area of Git I'm great with. Will try to resolve when I can.

@RobotLeopard86 RobotLeopard86 force-pushed the build-dedup-fix branch 2 times, most recently from b70f9f5 to a002714 Compare November 24, 2025 20:10
@RobotLeopard86
Copy link
Author

Okay, changes made and rebase (hopefully) corrected! Let me know if anything else needs to be tweaked.

@bonzini
Copy link
Collaborator

bonzini commented Nov 24, 2025

Thanks, it's an improvement but there are changes to make:

  1. the rebase didn't remove the new upstream commit. Not knowing your exact configuration, git pull --rebase https://GitHub.com/mesonbuild/meson will do.

  2. it's T.Set not Set

  3. this has a problem:

                for t2 in t.link_targets:
                    if t2 not in nonresults:
                        stack.appendleft(t2)

It will add t.link_targets to the stack in opposite order compared to the incoming list. You can achieve what the original code does with the following:

stack.expandleft((t2 for t2 in t.link_targets if t2 not in nonresults))
stack.expandleft((t2 for t2 in t.link_whole_targets if t2 not in nonresults))

@RobotLeopard86
Copy link
Author

Okay, hopefully that fixed it. I ran the rebase command you provided, and I think it worked since I don't see "RobotLeopard86 committed" all over the commits anymore. Sorry for having issues with the system; like I mentioned, I don't use rebase typically, so I'm bad with managing that.

Hopefully this can be merged now if everything is good.

@bonzini
Copy link
Collaborator

bonzini commented Nov 24, 2025

It does look good to me!

@RobotLeopard86
Copy link
Author

All right, all checks passed. Is this ok to merge then?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants