autoconf: Move libraries later to ensure that all symbols are found

This fixes llvm.org/PR19540