From 3dadbdfd5f87401c9f0a1b8679c279a8e0a9d8a7 Mon Sep 17 00:00:00 2001 From: Edwin Smith Date: Wed, 19 Oct 2016 08:17:33 -0700 Subject: [PATCH] Change type-scan opt-out from build switch to env variable. Summary: Using an environment variable is more buck-cache friendly. Reviewed By: markw65 Differential Revision: D4037819 fbshipit-source-id: bb9aacbd531523a8a6ae59c57e10ba88402d7fbb --- hphp/runtime/base/heap-collect.cpp | 2 +- hphp/tools/type-info-gens/gen-type-scanners.cpp | 18 +++++++++++++----- hphp/util/type-scan.h | 8 -------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/hphp/runtime/base/heap-collect.cpp b/hphp/runtime/base/heap-collect.cpp index da1e1d81e71..4836671e894 100644 --- a/hphp/runtime/base/heap-collect.cpp +++ b/hphp/runtime/base/heap-collect.cpp @@ -797,7 +797,7 @@ void logCollection(const char* phase, const Marker& mkr) { } auto sample = logCommon(); sample.setStr("phase", phase); - std::string scanner(type_scan::kBuildScanners ? "typescan" : "ts-cons"); + std::string scanner(type_scan::hasNonConservative() ? "typescan" : "ts-cons"); sample.setStr("scanner", !debug ? scanner : scanner + "-debug"); sample.setInt("gc_num", t_gc_num); // timers of gc-sub phases diff --git a/hphp/tools/type-info-gens/gen-type-scanners.cpp b/hphp/tools/type-info-gens/gen-type-scanners.cpp index 9e2abbe07ee..a00f5fff230 100644 --- a/hphp/tools/type-info-gens/gen-type-scanners.cpp +++ b/hphp/tools/type-info-gens/gen-type-scanners.cpp @@ -217,7 +217,7 @@ struct Generator { public: // Parse out all the debug information out of the specified file and do the // analysis generating the layouts. - explicit Generator(const std::string&); + explicit Generator(const std::string&, bool skip); // Turn the layouts into C++ code, writing to the specified ostream. void operator()(std::ostream&) const; @@ -592,13 +592,13 @@ struct Generator::IndexedType { folly::Optional errors; }; -Generator::Generator(const std::string& filename) { +Generator::Generator(const std::string& filename, bool skip) { // Either this platform has no support for parsing debug information, or the // preprocessor symbol to enable actually building scanner isn't // enabled. Either way, just bail out. Everything will get a conservative // scanner by default if someone actually tries to use the scanners at // runtime. - if (!HPHP::type_scan::kBuildScanners) return; + if (skip) return; m_parser = TypeParser::make(filename); @@ -3170,7 +3170,8 @@ int main(int argc, char** argv) { "filename to read debug-info from") ("output_file", po::value()->required(), - "filename of generated scanners"); + "filename of generated scanners") + ("skip", "do not scan dwarf, generate conservative scanners"); try { po::variables_map vm; @@ -3182,6 +3183,13 @@ int main(int argc, char** argv) { return 1; } +#ifdef __clang__ + /* Doesn't work with Clang at the moment. t10336705 */ + auto skip = true; +#else + auto skip = vm.count("skip") || getenv("HHVM_DISABLE_TYPE_SCANNERS"); +#endif + po::notify(vm); const auto output_filename = @@ -3196,7 +3204,7 @@ int main(int argc, char** argv) { try { const auto source_executable = vm["source_file"].as(); - Generator generator{source_executable}; + Generator generator{source_executable, skip}; std::ofstream output_file{output_filename}; generator(output_file); } catch (const debug_parser::Exception& exn) { diff --git a/hphp/util/type-scan.h b/hphp/util/type-scan.h index 60ce45dadc9..2122b37f408 100644 --- a/hphp/util/type-scan.h +++ b/hphp/util/type-scan.h @@ -303,14 +303,6 @@ struct Scanner { std::vector> m_conservative; }; -constexpr bool kBuildScanners = - /* Doesn't work with Clang at the moment. t10336705 */ -#if !defined(HHVM_DISABLE_TYPE_SCANNERS) && !defined(__clang__) - true; -#else - false; -#endif - /* * Type annotations to change generated function behavior: * -- 2.11.4.GIT