- const BuildInfo &binfo = comp.get_build_info();
- for(BuildInfo::PathList::const_iterator i=binfo.libpath.begin(); i!=binfo.libpath.end(); ++i)
- argv.push_back("-L"+i->str());
+ BuildInfo binfo;
+ target.collect_build_info(binfo);
+
+ const FS::Path &sysroot = binfo.sysroot;
+ if(!sysroot.empty())
+ argv.push_back("--sysroot="+sysroot.str());
+
+ FS::Path lib_dir = builder.get_prefix()/"lib";
+ if(binfo.rpath_mode==BuildInfo::ABSOLUTE)
+ argv.push_back("-Wl,-rpath,"+lib_dir.str());
+ else
+ {
+ if(binfo.rpath_mode==BuildInfo::RELATIVE)
+ argv.push_back("-Wl,-rpath,$ORIGIN/../lib");
+ argv.push_back("-Wl,-rpath-link,"+lib_dir.str());
+ }
+
+ for(const FS::Path &p: binfo.libpath)
+ argv.push_back("-L"+p.str());