]> git.tdb.fi Git - builder.git/blobdiff - source/gnucompiler.cpp
Use GnuCompiler's build info to link libstdc++
[builder.git] / source / gnucompiler.cpp
index a96f5a34d214faa47caa47936c25d17cd2727af8..0c5f2f8611db9eb588b8649fe3867f313153c5fc 100644 (file)
@@ -104,8 +104,12 @@ string GnuCompiler::create_build_signature(const BuildInfo &binfo) const
 
 void GnuCompiler::do_prepare(ToolData &tool) const
 {
+       tool.extra_data = 0U;
        prepare_syspath(tool);
        prepare_version(tool);
+
+       if(tag=="CXX")
+               tool.build_info.libs.push_back("stdc++");
 }
 
 void GnuCompiler::prepare_syspath(ToolData &tool) const
@@ -178,7 +182,11 @@ void GnuCompiler::prepare_version(ToolData &tool) const
        string exe_path = exe->get_path().str();
        unsigned version = query_version(exe_path, "-dumpversion");
        if(version>=0x70000)
-               version = query_version(exe_path, "-dumpfullversion");
+       {
+               unsigned v = query_version(exe_path, "-dumpfullversion");
+               if(v)
+                       version = v;
+       }
        tool.extra_data = version;
        builder.get_logger().log("tools", "%s version is %d.%d.%d", FS::basename(exe->get_path()), version>>16, (version>>8)&0xFF, version&0xFF);
 }
@@ -190,20 +198,19 @@ unsigned GnuCompiler::query_version(const string &exe_path, const string &arg) c
        argv.push_back(arg);
 
        builder.get_logger().log("auxcommands", "Running %s", join(argv.begin(), argv.end()));
+       unsigned ver = 0;
        try
        {
                string version_str = strip(ExternalTask::run_and_capture_output(argv));
 
                vector<string> version_parts = split(version_str, '.');
-               unsigned ver = 0;
                for(unsigned i=0; (i<3 && i<version_parts.size()); ++i)
                        ver |= lexical_cast<unsigned>(version_parts[i])<<(16-8*i);
-               return ver;
        }
        catch(const runtime_error &)
        { }
 
-       return 0;
+       return ver;
 }
 
 Task *GnuCompiler::_run(const ObjectFile &object)