From: Mikko Rasa Date: Sat, 21 Apr 2012 18:19:48 +0000 (+0300) Subject: Let the tools deal with cross-compiling flags X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=4240871c17854e2afccdcc37ce8f3464f8091a3f;p=builder.git Let the tools deal with cross-compiling flags --- diff --git a/source/architecture.cpp b/source/architecture.cpp index 3a9f554..e0b6966 100644 --- a/source/architecture.cpp +++ b/source/architecture.cpp @@ -98,16 +98,8 @@ Architecture::Architecture(Builder &b, const string &spec): if(type!=native_arch.type || system!=native_arch.system) cross_prefix = format("%s-%s", type, system); - else if(bits!=native_arch.bits) - { - build_info.cflags.push_back(format("-m%d", bits)); - build_info.ldflags.push_back(format("-m%d", bits)); - } - else + else if(bits==native_arch.bits) native = true; - - if(!cpu.empty()) - build_info.cflags.push_back(format("-march=%s", cpu)); } name = type; if(!cpu.empty()) diff --git a/source/architecture.h b/source/architecture.h index f60381f..1f643dc 100644 --- a/source/architecture.h +++ b/source/architecture.h @@ -33,13 +33,14 @@ private: bool native; std::string cross_prefix; StringMap tools; - BuildInfo build_info; public: Architecture(Builder &b, const std::string &spec); const std::string &get_name() const { return name; } const std::string &get_system() const { return system; } + unsigned get_bits() const { return bits; } + const std::string &get_cpu() const { return cpu; } bool match_name(const std::string &) const; bool is_native() const { return native; } @@ -48,8 +49,6 @@ public: std::string get_tool(const std::string &t) const; const std::string &get_cross_prefix() const { return cross_prefix; } - const BuildInfo &get_build_info() const { return build_info; } - private: std::string resolve_alias(const std::string &) const; void parse_specification(const std::string &); diff --git a/source/gnucompiler.cpp b/source/gnucompiler.cpp index 62a7e32..026ec8c 100644 --- a/source/gnucompiler.cpp +++ b/source/gnucompiler.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "builder.h" #include "component.h" #include "externaltask.h" @@ -50,6 +51,15 @@ Task *GnuCompiler::run(const Target &target) const for(list::const_iterator i=binfo.defines.begin(); i!=binfo.defines.end(); ++i) argv.push_back("-D"+*i); + const Architecture &arch = builder.get_current_arch(); + const Architecture &native_arch = builder.get_native_arch(); + if(arch.get_bits()!=native_arch.get_bits()) + argv.push_back(format("-m%d", arch.get_bits())); + + const string &cpu = arch.get_cpu(); + if(!cpu.empty()) + argv.push_back("-march="+cpu); + 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(); diff --git a/source/gnulinker.cpp b/source/gnulinker.cpp index c59251e..a14dd0b 100644 --- a/source/gnulinker.cpp +++ b/source/gnulinker.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include "builder.h" #include "component.h" #include "executable.h" @@ -82,6 +83,11 @@ Task *GnuLinker::run(const Target &target) const for(list::const_iterator i=binfo.libpath.begin(); i!=binfo.libpath.end(); ++i) argv.push_back("-L"+*i); + const Architecture &arch = builder.get_current_arch(); + const Architecture &native_arch = builder.get_native_arch(); + if(arch.get_bits()!=native_arch.get_bits()) + argv.push_back(format("-m%d", arch.get_bits())); + FS::Path work_dir = comp.get_package().get_source(); argv.push_back("-o"); diff --git a/source/sourcepackage.cpp b/source/sourcepackage.cpp index f59b353..754a314 100644 --- a/source/sourcepackage.cpp +++ b/source/sourcepackage.cpp @@ -181,8 +181,6 @@ void SourcePackage::init_config() void SourcePackage::create_build_info() { - build_info.update_from(builder.get_current_arch().get_build_info()); - // XXX Currently, a package-specific settings will override cmdline. This might or might not be desirable. const StringList &warnings = builder.get_warnings(); build_info.warnings.insert(build_info.warnings.begin(), warnings.begin(), warnings.end());