From bc85cc286c8a3f1055f1979a7ff8697cf1b61912 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 30 Aug 2018 14:06:03 +0300 Subject: [PATCH] Add support for statically linking the C++ standard library It can be requested by setting the libmode for "stdc++" as STATIC. --- source/gnulinker.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/source/gnulinker.cpp b/source/gnulinker.cpp index a132ace..51da81f 100644 --- a/source/gnulinker.cpp +++ b/source/gnulinker.cpp @@ -338,8 +338,18 @@ Task *GnuLinker::Linker::run(const Target &target) const if(static_link_ok) argv.push_back("-static"); - else if(architecture->get_system()=="windows") - argv.push_back("-Wl,--enable-auto-import"); + else + { + if(compiler_tag=="CXX") + { + BuildInfo::LibModeMap::const_iterator i = binfo.libmodes.find("stdc++"); + if(i!=binfo.libmodes.end() && i->second<=BuildInfo::STATIC) + argv.push_back("-static-libstdc++"); + } + + if(architecture->get_system()=="windows") + argv.push_back("-Wl,--enable-auto-import"); + } return new ExternalTask(argv, work_dir); } -- 2.45.2