Compilation tends to benefit heavily from bigger caches & faster memory, yes. It's an area that Zen 2 & 3 have been absolutely fantastic at thanks to their huge caches as well.
The iMac Pro's relatively slow 2666MHz RAM can't be saved by the also relatively small (these days) cache in the Xeon-W it uses.
Xeon W is 7 years old at this point, and the Apple M1 is a pretty darn good modern chip.
Today's desktops are as good as servers from 5 years ago. Today's laptops are as good as desktops 5 years ago. Today's phones are as good as laptops 5 years ago.
---------
The Apple M1 makes a leap with a huge L1 cache, very wide execution, at a very low clock rate (2.8 GHz for power-efficiency).
But when you pair such a leap with a 7-year technology jump, yeah, things look quite silly.