From 77869a0567f4c2e029c679525b29da53433d8d9f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 22 Jul 2016 16:20:21 +0200 Subject: Factor target CPU to VC /MACHINE option translation --- build2/cxx/link.cxx | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) (limited to 'build2/cxx/link.cxx') diff --git a/build2/cxx/link.cxx b/build2/cxx/link.cxx index 34495b0..3ce99c9 100644 --- a/build2/cxx/link.cxx +++ b/build2/cxx/link.cxx @@ -1072,6 +1072,9 @@ namespace build2 void windows_rpath_assembly (file&, timestamp, bool scratch); + const char* + msvc_machine (const string& cpu); // msvc.cxx + target_state link:: perform_update (action a, target& xt) { @@ -1252,25 +1255,6 @@ namespace build2 string soname1, soname2; strings sargs; - if (cid == "msvc") - { - // Translate the compiler target CPU to the /MACHINE option value. - // This applies to both link.exe and lib.exe. - // - const string& tcpu (cast (rs["cxx.target.cpu"])); - - const char* m (tcpu == "i386" || tcpu == "i686" ? "/MACHINE:x86" : - tcpu == "x86_64" ? "/MACHINE:x64" : - tcpu == "arm" ? "/MACHINE:ARM" : - tcpu == "arm64" ? "/MACHINE:ARM64" : - nullptr); - - if (m == nullptr) - fail << "unable to translate CPU " << tcpu << " to /MACHINE"; - - args.push_back (m); - } - if (lt == otype::a) { if (cid == "msvc") ; @@ -1488,6 +1472,11 @@ namespace build2 if (verb < 3) args.push_back ("/NOLOGO"); + // Add /MACHINE. + // + args.push_back ( + msvc_machine (cast (rs["cxx.target.cpu"]))); + out = "/OUT:" + relt.string (); args.push_back (out.c_str ()); } @@ -1513,6 +1502,11 @@ namespace build2 if (lt == otype::s) args.push_back ("/DLL"); + // Add /MACHINE. + // + args.push_back ( + msvc_machine (cast (rs["cxx.target.cpu"]))); + // Unless explicitly enabled with /INCREMENTAL, disable // incremental linking (it is implicitly enabled if /DEBUG is // specified). The reason is the .ilk file: its name cannot be -- cgit v1.1