From d97b4af15353c488ddd48a7e208906f84f7654c5 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 11 May 2015 14:47:04 -0700 Subject: [PATCH] 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. --- src/etc/mklldeps.py | 7 +++++-- 1 file 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")