improved code to detect initially_selected_compiler, update #1671