Detect during configuration whether the linker accepts --no-as-needed

Detect during configuration whether the linker accepts `--no-as-needed`, and add it to the link flags if it's supported.