Move the compiler-selecting methods to ENV/shared

Closes #30210.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Use Pathname#split