The --enable-new-dtags linker flag should not be used when building non-ELF
binaries. This is related to http://bugs.python.org/issue17362
diff --git a/Lib/distutils/unixccompiler.py b/Lib/distutils/unixccompiler.py
index 69045f8..7ed0a5f 100644
--- a/Lib/distutils/unixccompiler.py
+++ b/Lib/distutils/unixccompiler.py
@@ -243,9 +243,13 @@ class UnixCCompiler(CCompiler):
                 # -Wl whenever gcc was used in the past it is probably
                 # safest to keep doing so.
                 if sysconfig.get_config_var("GNULD") == "yes":
-                    # GNU ld needs an extra option to get a RUNPATH
+                    # GNU ELF ld needs an extra option to get a RUNPATH
                     # instead of just an RPATH.
-                    return "-Wl,--enable-new-dtags,-R" + dir
+                    if sys.platform in ["win32", "cygwin"] or \
+                       "mingw" in compiler:
+                        return []
+                    else:
+                        return "-Wl,--enable-new-dtags,-R" + dir
                 else:
                     return "-Wl,-R" + dir
             else:
