pull out error printing to share between compile_{top,prog}