Don't crash on circular dependency

Previously, we would register the circular dependency error properly
with buildmessage, but then try to build the package with a circular
dependency anyway, leading to a crash.

Fixes #3280.