Militants linked to Islamic State killed 37 people and abducted six others in an attack on a school in western Uganda near the border with the Democratic Republic of Congo, the military said on Saturday.