+ compiler.prepare();
+ FileTarget *compiler_exe = compiler.get_executable();
+ if(compiler_exe)
+ {
+ ExternalTask::Arguments argv;
+ argv.push_back(compiler_exe->get_path().str());
+ argv.push_back("-Wl,--verbose");
+ argv.push_back("-nostdlib");
+ if(!sysroot.empty())
+ argv.push_back("--sysroot="+sysroot.str());
+
+ builder.get_logger().log("auxcommands", format("Running %s", join(argv.begin(), argv.end())));
+ try
+ {
+ string output = ExternalTask::run_and_capture_output(argv, FS::Path(), true);
+ string::size_type start = 0;
+ while(start<output.size())
+ {
+ string::size_type search_dir = output.find("SEARCH_DIR(\"", start);
+ if(search_dir==string::npos)
+ break;
+
+ search_dir += 12;
+ string::size_type end = output.find("\");", search_dir);
+ if(end==string::npos)
+ break;
+
+ FS::Path path;
+ if(!output.compare(search_dir, 2, "=/"))
+ {
+ search_dir += 2;
+ if(sysroot.empty())
+ path = "/";
+ else
+ path = sysroot;
+ }
+
+ path /= output.substr(search_dir, end-search_dir);
+ builder.get_logger().log("tools", format("Got %s system path: %s", tag, path));
+ system_path.push_back(path);
+ path_found = true;
+
+ start = end+3;
+ }
+ }
+ catch(...)
+ { }
+ }
+ }
+
+ 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");
+ }
+ }