X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgnucompiler.cpp;h=816a9a31eaf196e461e9ea3ca2423bd4804f2a38;hb=921e8234ff65bd23c0b94ed568ec1fb68e47655b;hp=1b05a5cb6e99b459ff9f4f3ea3a63f3a8378295f;hpb=1c80c1c33af10e8e325808906a95969ee57676b6;p=builder.git diff --git a/source/gnucompiler.cpp b/source/gnucompiler.cpp index 1b05a5c..816a9a3 100644 --- a/source/gnucompiler.cpp +++ b/source/gnucompiler.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -14,6 +15,17 @@ using namespace std; using namespace Msp; +namespace { + +const char *cpus[] = +{ + "athlonxp", "athlon-xp", + "armv7a", "armv7-a", + 0 +}; + +} + GnuCompiler::GnuCompiler(Builder &b, const Architecture &a, const string &t, const FS::Path &sysroot): Tool(b, a, t) { @@ -80,7 +92,6 @@ void GnuCompiler::do_prepare() Task *GnuCompiler::run(const Target &target) const { const ObjectFile &object = dynamic_cast(target); - const Component &comp = *object.get_component(); ExternalTask::Arguments argv; argv.push_back(executable->get_path().str()); @@ -89,6 +100,12 @@ Task *GnuCompiler::run(const Target &target) const BuildInfo binfo; target.collect_build_info(binfo); + string tag_for_std = (tag=="OBJC" ? "CC" : tag); + if(binfo.standards.count(tag_for_std)) + argv.push_back("-std="+get_item(binfo.standards, tag_for_std)); + if(tag=="OBJC" && binfo.standards.count(tag)) + argv.push_back("-fobjc-std="+get_item(binfo.standards, tag)); + if(binfo.warning_level>=1) { argv.push_back("-Wall"); @@ -118,7 +135,10 @@ Task *GnuCompiler::run(const Target &target) const argv.push_back("-Winline"); } if(binfo.fatal_warnings) + { argv.push_back("-Werror"); + argv.push_back("-Wno-error=deprecated-declarations"); + } } const FS::Path &sysroot = binfo.sysroot; @@ -151,20 +171,43 @@ Task *GnuCompiler::run(const Target &target) const } if(binfo.threads && architecture->get_system()!="windows" && architecture->get_system()!="darwin") argv.push_back("-pthread"); - if((comp.get_type()==Component::LIBRARY || comp.get_type()==Component::MODULE) && architecture->get_system()!="windows") + if(object.is_used_in_shared_library() && architecture->get_system()!="windows") argv.push_back("-fPIC"); const Architecture &native_arch = builder.get_native_arch(); if(architecture->is_native() && architecture->get_bits()!=native_arch.get_bits()) argv.push_back(format("-m%d", architecture->get_bits())); - const string &cpu = architecture->get_cpu(); + string cpu = architecture->get_cpu(); if(!cpu.empty()) + { + for(unsigned i=0; cpus[i]; i+=2) + if(cpu==cpus[i]) + { + cpu = cpus[i+1]; + break; + } argv.push_back("-march="+cpu); + } + + if(!architecture->get_fpu().empty()) + { + if(architecture->get_type()=="x86") + { + argv.push_back("-mfpmath="+architecture->get_fpu()); + if(architecture->get_fpu()=="sse") + argv.push_back("-msse2"); + } + else if(architecture->get_type()=="arm") + { + argv.push_back("-mfpu="+architecture->get_fpu()); + argv.push_back("-mfloat-abi=softfp"); + } + } FS::Path obj_path = object.get_path(); FS::Path src_path = object.get_source().get_path(); - FS::Path work_dir = comp.get_package().get_source_directory(); + FS::Path work_dir = object.get_component()->get_package().get_source_directory(); argv.push_back("-o"); argv.push_back(relative(obj_path, work_dir).str());