do not link -z on cygwin

partial backport of 7fb68c06017ae817cf65c49bd5d4064dfd4b7ac5