]> git.tdb.fi Git - builder.git/commitdiff
Let the tools deal with cross-compiling flags
authorMikko Rasa <tdb@tdb.fi>
Sat, 21 Apr 2012 18:19:48 +0000 (21:19 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 8 Jul 2012 21:08:49 +0000 (00:08 +0300)
source/architecture.cpp
source/architecture.h
source/gnucompiler.cpp
source/gnulinker.cpp
source/sourcepackage.cpp

index 3a9f5549df5f7a2add49547dbf05c22d122117e3..e0b69667952c64c1ad2e70229e5c4e951a128d7f 100644 (file)
@@ -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())
index f60381f9905ddb6573c304470b0be7304aed6a9d..1f643dc325b4a1512170d95b50b22871b84de5bd 100644 (file)
@@ -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 &);
index 62a7e32dcd1c879be0d55bb25075a2b04f676189..026ec8c8a015c08b40ef8e8b74edc37a8c12ed36 100644 (file)
@@ -1,5 +1,6 @@
 #include <msp/fs/dir.h>
 #include <msp/fs/utils.h>
+#include <msp/strings/format.h>
 #include "builder.h"
 #include "component.h"
 #include "externaltask.h"
@@ -50,6 +51,15 @@ Task *GnuCompiler::run(const Target &target) const
        for(list<string>::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();
index c59251efabe9dc8a1baa4caba18d36a08938c971..a14dd0bd984f096af2831ce2d6677d0e60b2436d 100644 (file)
@@ -2,6 +2,7 @@
 #include <vector>
 #include <msp/fs/dir.h>
 #include <msp/fs/utils.h>
+#include <msp/strings/format.h>
 #include "builder.h"
 #include "component.h"
 #include "executable.h"
@@ -82,6 +83,11 @@ Task *GnuLinker::run(const Target &target) const
        for(list<string>::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");
index f59b353d74d0c3edd5dc6e52409e61c9083fab64..754a314a49835997f48f170f73b113a7beeb7087 100644 (file)
@@ -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());