about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-05-11 14:47:04 -0700
committerAlex Crichton <alex@alexcrichton.com>2015-05-19 10:53:06 -0700
commitd97b4af15353c488ddd48a7e208906f84f7654c5 (patch)
treed48033a7db95c4cb107492795da379dc364ea2a3
parentaf56e2efde5cd82564e32598889d25d798c02722 (diff)
mklldeps: Don't link stdc++/c++ on MSVC
These libraries don't exist! The linker for MSVC is highly likely to not pass
`/NODEFAULTLIB` in which case the right standard library will automatically be
selected.
-rw-r--r--src/etc/mklldeps.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/etc/mklldeps.py b/src/etc/mklldeps.py
index fe9feb3538d..7a925fa3f33 100644
--- a/src/etc/mklldeps.py
+++ b/src/etc/mklldeps.py
@@ -80,10 +80,13 @@ if enable_static == '1':
     assert('stdlib=libc++' not in out)
     f.write("#[link(name = \"stdc++\", kind = \"static\")]\n")
 else:
+    # Note that we use `cfg_attr` here because on MSVC the C++ standard library
+    # is not c++ or stdc++, but rather the linker takes care of linking the
+    # right standard library.
     if 'stdlib=libc++' in out:
-        f.write("#[link(name = \"c++\")]\n")
+        f.write("#[cfg_attr(not(target_env = \"msvc\"), link(name = \"c++\"))]\n")
     else:
-        f.write("#[link(name = \"stdc++\")]\n")
+        f.write("#[cfg_attr(not(target_env = \"msvc\"), link(name = \"stdc++\"))]\n")
 
 # Attach everything to an extern block
 f.write("extern {}\n")