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.
This commit is contained in:
Alex Crichton 2015-05-11 14:47:04 -07:00
parent af56e2efde
commit d97b4af153
1 changed files with 5 additions and 2 deletions

View File

@ -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")