configure: check for --as-needed support early

This moves the check for --as-needed linker support before all
library tests, ensuring consistent behaviour between the checks
and the actual link step.

Signed-off-by: Mans Rullgard <mans@mansr.com>
