use better strategy to check the need for --no-as-needed link flag.