I figured it out. perror.c was added into gl/tests/ because some self-tests used perror. However, this caused the generated stdio.h to redefine perror to rpl_perror, which caused problems. I had mistakenly assumed that the perror function would be available for use if it was in the module list during --import. Adding it explicitly solved the problem.
/Simon