Bring `configure` into alignment with `ghc-toolchain`, ensuring that the ld-override logic will only take effect on Linux and Windows. Fixes #25501. (cherry picked from commit 99225996)