$ emerge -pve bash These are the packages that would be merged, in order: Calculating dependencies ..... ..... ... done! [ebuild U ] app-shells/bash-3.2_p9-r1 [3.1_p17] USE="-afs -bashlogger -nls -vanilla" 0 kB [ebuild U ] sys-libs/ncurses-5.6 [5.5-r3] USE="gpm -bootstrap -build -debug -doc -minimal -nocxx -trace -unicode" 0 kB [ebuild R ] sys-libs/gpm-1.20.1-r5 USE="(-selinux)" 0 kB Total: 3 packages (2 upgrades, 1 reinstall), Size of downloads: 0 kB whereas in 2.1.1: $ emerge -pev bash These are the packages that would be merged, in order: Calculating dependencies ... done! [ebuild N ] sys-libs/gpm-1.20.1-r5 USE="(-selinux)" 0 kB [ebuild N ] sys-libs/ncurses-5.6 USE="gpm -bootstrap -build -debug -doc -minimal -nocxx -trace -unicode" 0 kB [ebuild N ] app-shells/bash-3.2_p9-r1 USE="-afs -bashlogger -nls -vanilla" 0 kB Bash depends on ncurses, so ncurses should be emerged before bash under all circumstances. Why has this order changed in 2.1.2? I may be missing something about changes in 2.1.2 which has made this the right behavior. Please help me understand it.
This behavior is triggered by a circular dependency between gpm and ncurses. I'll see about improving the merge order calculation logic for cases like this.
Created attachment 110583 [details, diff] optimize merge order by delaying the merge of root nodes With this patch, I get the following order: [ebuild R ] sys-libs/ncurses-5.6 [ebuild R ] app-shells/bash-3.2_p9-r1 [ebuild R ] sys-libs/gpm-1.20.1-r5 Though this order is different from that produced by 2.1.1, it's just as good. The difference is due to the building of a complete dependency graph (bug #147766).
In svn r6010 I've optimized leaf node selection by ordering nodes from highest to lowest overall reference count. This leads to the following merge order: [ebuild R ] sys-libs/ncurses-5.6 [ebuild R ] sys-libs/gpm-1.20.1-r5 [ebuild R ] app-shells/bash-3.2_p9-r1
This has been released in 2.1.2-r10.