+ }
+
+ if(!path_found)
+ {
+ builder.get_logger().log("tools", format("No %s system path found, using defaults", tag));
+ if(!sysroot.empty())
+ system_path.push_back(sysroot/"usr/lib");
+ else if(architecture->is_native())
+ {
+ system_path.push_back("/lib");
+ system_path.push_back("/usr/lib");
+ if(architecture->match_name("pc-32-linux"))
+ {
+ system_path.push_back("/lib/i386-linux-gnu");
+ system_path.push_back("/usr/lib/i386-linux-gnu");
+ }
+ else if(architecture->match_name("pc-64-linux"))
+ {
+ system_path.push_back("/lib/x86_64-linux-gnu");
+ system_path.push_back("/usr/lib/x86_64-linux-gnu");
+ }
+ }
+ else
+ system_path.push_back("/usr/"+architecture->get_cross_prefix()+"/lib");
+ }
+}
+
+Task *GnuLinker::run(const Target &) const
+{
+ throw logic_error("GnuLinker should not be run directly");
+}
+
+
+GnuLinker::Linker::Linker(GnuLinker &p, const string &ct):
+ SubTool(p),
+ compiler_tag(ct)
+{
+ if(compiler_tag=="CC")
+ set_command("gcc", true);
+ else if(compiler_tag=="CXX")
+ set_command("g++", true);
+ else
+ throw invalid_argument("GnuLinker::Linker::Linker");
+}
+
+string GnuLinker::Linker::create_build_signature(const BuildInfo &binfo) const
+{
+ string result = FS::basename(executable->get_path());
+ result += ',';
+ if(binfo.libmode<=BuildInfo::STATIC)
+ result += 't';
+ else
+ result += 'd';
+ if(binfo.strip)
+ result += 's';
+ if(!binfo.libs.empty())
+ {
+ result += ",l";
+ result += join(binfo.libs.begin(), binfo.libs.end(), ",l");
+ }
+ return result;
+}
+
+void GnuLinker::Linker::do_prepare()
+{
+ parent.prepare();
+ build_info = parent.get_build_info();
+ system_path = parent.get_system_path();
+
+ Tool &compiler = builder.get_toolchain().get_tool(compiler_tag);
+ if(dynamic_cast<GnuCompiler *>(&compiler))
+ {
+ compiler.prepare();
+ executable = compiler.get_executable();
+ }
+}
+
+Task *GnuLinker::Linker::run(const Target &target) const
+{
+ const Binary &bin = dynamic_cast<const Binary &>(target);