diff options
-rw-r--r-- | build2/c/init.cxx | 2 | ||||
-rw-r--r-- | build2/cc/common.hxx | 9 | ||||
-rw-r--r-- | build2/cc/compile.cxx | 31 | ||||
-rw-r--r-- | build2/cxx/init.cxx | 2 |
4 files changed, 37 insertions, 7 deletions
diff --git a/build2/c/init.cxx b/build2/c/init.cxx index a54060c..ebaa193 100644 --- a/build2/c/init.cxx +++ b/build2/c/init.cxx @@ -239,6 +239,8 @@ namespace build2 "c.uninstall", cast<string> (rs[cm.x_id]), + cast<uint64_t> (rs[cm.x_version_major]), + cast<uint64_t> (rs[cm.x_version_minor]), cast<target_triplet> (rs[cm.x_target]), cm.tstd, diff --git a/build2/cc/common.hxx b/build2/cc/common.hxx index 3abb086..bc52311 100644 --- a/build2/cc/common.hxx +++ b/build2/cc/common.hxx @@ -100,11 +100,14 @@ namespace build2 // Cached values for some commonly-used variables/values. // const string& cid; // x.id + uint64_t cmaj; // x.version.major + uint64_t cmin; // x.version.minor + const target_triplet& ctg; // x.target const string& tsys; // x.target.system const string& tclass; // x.target.class - const string& tstd; // Translated x_std value (can be empty). + const string& tstd; // Translated x_std value (can be empty). const process_path* pkgconfig; // pkgconfig.path (can be NULL). const dir_paths& sys_lib_dirs; // x.sys_lib_dirs @@ -142,6 +145,7 @@ namespace build2 const char* install, const char* uninstall, const string& id, + uint64_t mj, uint64_t mi, const target_triplet& tg, const string& std, const process_path* pkgc, @@ -155,7 +159,8 @@ namespace build2 x_link (link), x_install (install), x_uninstall (uninstall), - cid (id), ctg (tg), tsys (ctg.system), tclass (ctg.class_), + cid (id), cmaj (mj), cmin (mi), + ctg (tg), tsys (ctg.system), tclass (ctg.class_), tstd (std), pkgconfig (pkgc), sys_lib_dirs (sld), sys_inc_dirs (sid), x_src (src), x_hdr (hdr), x_inc (inc) {} diff --git a/build2/cc/compile.cxx b/build2/cc/compile.cxx index 35fb531..21f7ecf 100644 --- a/build2/cc/compile.cxx +++ b/build2/cc/compile.cxx @@ -952,11 +952,32 @@ namespace build2 // still performing inclusions. Also serves as a flag indicating whether // this compiler uses the separate preprocess and compile setup. // - const char* pp ( - cid == "msvc" ? "/C" : - cid == "gcc" ? "-fdirectives-only" : - cid == "clang" || cid == "clang-apple" ? "-frewrite-includes" : - nullptr); + const char* pp (nullptr); + + if (cid == "msvc") pp = "/C"; + else if (cid == "gcc") + { + // -fdirectives-only is available since GCC 4.3.0. + // + if (cmaj > 4 || (cmaj == 4 && cmin >= 3)) + pp = "-fdirectives-only"; + } + else if (cid == "clang") + { + // -frewrite-includes is available since Clang 3.2.0. + // + if (cmaj > 3 || (cmaj == 3 && cmin >= 2)) + pp = "-frewrite-includes"; + } + else if (cid == "clang-apple") + { + // Apple Clang 5.0 is based on LLVM 3.3svn so it should have this + // option (4.2 is based on 3.2svc so it may or may not have it and, + // no, we are not going to try to find out). + // + if (cmaj >= 5) + pp = "-frewrite-includes"; + } // Initialize lazily, only if required. // diff --git a/build2/cxx/init.cxx b/build2/cxx/init.cxx index 395a9f8..578e617 100644 --- a/build2/cxx/init.cxx +++ b/build2/cxx/init.cxx @@ -309,6 +309,8 @@ namespace build2 "cxx.uninstall", cast<string> (rs[cm.x_id]), + cast<uint64_t> (rs[cm.x_version_major]), + cast<uint64_t> (rs[cm.x_version_minor]), cast<target_triplet> (rs[cm.x_target]), cm.tstd, |