Ninja: Revert accidental LINK_WHAT_YOU_USE impl for static libraries
In !6263 (merged), we fixed usage of -Wl,--no-as-needed to override
-Wl,--as-needed from LDFLAGS. However, that change also passes
-Wl,--no-as-needed to ar, which is incorrect flag for ar.
Let's check the target type before passing down the flags.
Fixes: #22487 (closed)
Backport: release:HEAD^2
Edited by Brad King