X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgnulinker.cpp;h=75a1bac280609086da046f86e3c71e1cc115d5e5;hb=8f8f10fe41bbb68866e8fb05f8cbab0b325dc7da;hp=2d7438d61b547e01f137c0905c049ed7f1f7d89d;hpb=c51411c4b3ed4e6a0d8343b848db3dc736bc7857;p=builder.git diff --git a/source/gnulinker.cpp b/source/gnulinker.cpp index 2d7438d..75a1bac 100644 --- a/source/gnulinker.cpp +++ b/source/gnulinker.cpp @@ -21,13 +21,18 @@ using namespace std; using namespace Msp; -GnuLinker::GnuLinker(Builder &b, const Architecture &a): +GnuLinker::GnuLinker(Builder &b, const Architecture &a, const FS::Path &sysroot): Tool(b, a, "LINK") { input_suffixes.push_back(".o"); input_suffixes.push_back(".a"); - if(architecture->is_native()) + if(!sysroot.empty()) + { + build_info.sysroot = sysroot; + system_path.push_back(sysroot/"usr"/"lib"); + } + else if(architecture->is_native()) { system_path.push_back("/lib"); system_path.push_back("/usr/lib"); @@ -169,9 +174,7 @@ Task *GnuLinker::Linker::run(const Target &target) const vector argv; argv.push_back(executable->get_path().str()); - const Component &comp = *bin.get_component(); - - FS::Path work_dir = comp.get_package().get_source_directory(); + FS::Path work_dir = bin.get_component()->get_package().get_source_directory(); if(const SharedLibrary *shlib = dynamic_cast(&bin)) { @@ -201,6 +204,11 @@ Task *GnuLinker::Linker::run(const Target &target) const BuildInfo binfo; target.collect_build_info(binfo); + + const FS::Path &sysroot = binfo.sysroot; + if(!sysroot.empty()) + argv.push_back("--sysroot="+sysroot.str()); + for(BuildInfo::PathList::const_iterator i=binfo.libpath.begin(); i!=binfo.libpath.end(); ++i) argv.push_back("-L"+i->str()); if(binfo.strip) @@ -215,6 +223,9 @@ Task *GnuLinker::Linker::run(const Target &target) const argv.push_back("-o"); argv.push_back(relative(bin.get_path(), work_dir).str()); + for(BuildInfo::WordList::const_iterator i=binfo.keep_symbols.begin(); i!=binfo.keep_symbols.end(); ++i) + argv.push_back("-u"+*i); + bool static_link_ok = (binfo.libmode<=BuildInfo::STATIC); const Target::Dependencies &depends = target.get_dependencies();