turns out this doesn't repro in official automake versions because it requires a Gentoo-specific patch -- the one sent for #38043 to fix Python 3.5+ compilation. the issue is that lib/am/python.am chops up the list of files before the globs are expanded instead of after.
## This is somewhat tricky, because for newer pythons we have to take PEP-3147 ## into account. Avoid exceeding the command-line length limit. dir='$(DESTDIR)$(%NDIR%dir)'; \ > echo "$$py_files" | $(am__pep3147_tweak) | $(am__base_list) | \ while read files; do \ $(am__uninstall_files_from_dir) || st=$$?; \ done || exit $$?; \ exit $$st the > line above will turn the list of files we installed into a bunch of globs (e.g. py_files="npython1.py" turns into "__pycache__/npython1.*.pyc __pycache__/npython1.*.pyo"), and then those globs (before they're expanded) run through $(am__base_list) to chop them up into sets of 40, but then we have 40 globs that expand into a lot more files. before #38043, we have 1-to-2 increase, but now we have 1-to-3, and so the command line is exceeded. so we have to expand the globs between $(am__pep3147_tweak) and $(am__base_list). -mike