]> git.tdb.fi Git - builder.git/commitdiff
Add support for statically linking the C++ standard library
authorMikko Rasa <tdb@tdb.fi>
Thu, 30 Aug 2018 11:06:03 +0000 (14:06 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 30 Aug 2018 11:06:03 +0000 (14:06 +0300)
It can be requested by setting the libmode for "stdc++" as STATIC.

source/gnulinker.cpp

index a132acecf5b9f0f85bb1220c2edb08098f0a4829..51da81f923cba4d649b181ee28cf68a01104b651 100644 (file)
@@ -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);
 }