From 02a29e1d3933bd17e49a455f9cccfd88e9fff54b Mon Sep 17 00:00:00 2001 From: mwilliams Date: Sat, 9 May 2015 11:50:52 -0700 Subject: [PATCH] Fix some gcc-4.9 compatibility issues Summary: Update some library requirements, and fix a few stricter checks in the code. With this, hhvm compiles, but fails to link due to some iconv issues, which I didn't try to resolve. Also, fbconfig --platform-all=gcc-4.9-glibc-2.20-fb hphp/hhvm works, but -r hphp fails, because some ocaml libs that hack depends on are not up to date, and trying to fix them turned into the usual rats nest. I'll take a look at those separately. Reviewed By: @jdelong Differential Revision: D2059660 --- hphp/runtime/base/datetime.cpp | 2 +- hphp/runtime/ext/curl/ext_curl.cpp | 18 ++++++++++++------ hphp/runtime/ext/ext_hotprofiler.cpp | 2 +- hphp/runtime/vm/debug/debug.cpp | 1 + hphp/runtime/vm/jit/refcount-opts.cpp | 10 +++++----- hphp/runtime/vm/jit/srcdb.cpp | 3 ++- hphp/runtime/vm/jit/translator.cpp | 2 +- hphp/runtime/vm/jit/vasm-copy.cpp | 2 +- hphp/util/portability.h | 8 ++++++++ hphp/util/stack-trace.cpp | 1 + 10 files changed, 33 insertions(+), 16 deletions(-) diff --git a/hphp/runtime/base/datetime.cpp b/hphp/runtime/base/datetime.cpp index b8b5917d8b4..2b373916ab7 100644 --- a/hphp/runtime/base/datetime.cpp +++ b/hphp/runtime/base/datetime.cpp @@ -592,7 +592,7 @@ String DateTime::toString(DateFormat format) const { default: assert(false); } - throw_invalid_argument("format: %d", format); + throw_invalid_argument("format: %d", static_cast(format)); return String(); } diff --git a/hphp/runtime/ext/curl/ext_curl.cpp b/hphp/runtime/ext/curl/ext_curl.cpp index 350cb3ac8cd..d2969431e6f 100644 --- a/hphp/runtime/ext/curl/ext_curl.cpp +++ b/hphp/runtime/ext/curl/ext_curl.cpp @@ -192,7 +192,7 @@ public: m_read.callback = src->m_read.callback; m_write_header.callback = src->m_write_header.callback; - reset(); + reseat(); m_to_free = src->m_to_free; m_emptyPost = src->m_emptyPost; @@ -250,30 +250,36 @@ public: return std::min(1000 * remaining, timeout); } + void reseat() { + // Note: this is the minimum set of things to point the CURL* + // to this CurlHandle + curl_easy_setopt(m_cp, CURLOPT_ERRORBUFFER, m_error_str); + curl_easy_setopt(m_cp, CURLOPT_FILE, (void*)this); + curl_easy_setopt(m_cp, CURLOPT_INFILE, (void*)this); + curl_easy_setopt(m_cp, CURLOPT_WRITEHEADER, (void*)this); + curl_easy_setopt(m_cp, CURLOPT_SSL_CTX_DATA, (void*)this); + } + void reset() { curl_easy_reset(m_cp); curl_easy_setopt(m_cp, CURLOPT_NOPROGRESS, 1); curl_easy_setopt(m_cp, CURLOPT_VERBOSE, 0); - curl_easy_setopt(m_cp, CURLOPT_ERRORBUFFER, m_error_str); curl_easy_setopt(m_cp, CURLOPT_WRITEFUNCTION, curl_write); - curl_easy_setopt(m_cp, CURLOPT_FILE, (void*)this); curl_easy_setopt(m_cp, CURLOPT_READFUNCTION, curl_read); - curl_easy_setopt(m_cp, CURLOPT_INFILE, (void*)this); curl_easy_setopt(m_cp, CURLOPT_HEADERFUNCTION, curl_write_header); - curl_easy_setopt(m_cp, CURLOPT_WRITEHEADER, (void*)this); curl_easy_setopt(m_cp, CURLOPT_DNS_USE_GLOBAL_CACHE, 0); // for thread-safe curl_easy_setopt(m_cp, CURLOPT_DNS_CACHE_TIMEOUT, 120); curl_easy_setopt(m_cp, CURLOPT_MAXREDIRS, 20); // no infinite redirects curl_easy_setopt(m_cp, CURLOPT_NOSIGNAL, 1); // for multithreading mode curl_easy_setopt(m_cp, CURLOPT_SSL_CTX_FUNCTION, CurlResource::ssl_ctx_callback); - curl_easy_setopt(m_cp, CURLOPT_SSL_CTX_DATA, (void*)this); curl_easy_setopt(m_cp, CURLOPT_TIMEOUT, minTimeout(RuntimeOption::HttpDefaultTimeout)); curl_easy_setopt(m_cp, CURLOPT_CONNECTTIMEOUT, minTimeout(RuntimeOption::HttpDefaultTimeout)); + reseat(); } Variant execute() { diff --git a/hphp/runtime/ext/ext_hotprofiler.cpp b/hphp/runtime/ext/ext_hotprofiler.cpp index 97191b27801..bae53120986 100644 --- a/hphp/runtime/ext/ext_hotprofiler.cpp +++ b/hphp/runtime/ext/ext_hotprofiler.cpp @@ -1359,7 +1359,7 @@ bool ProfilerFactory::start(ProfilerKind kind, } break; default: - throw_invalid_argument("level: %d", kind); + throw_invalid_argument("level: %d", static_cast(kind)); return false; } if (m_profiler && m_profiler->m_successful) { diff --git a/hphp/runtime/vm/debug/debug.cpp b/hphp/runtime/vm/debug/debug.cpp index 336e251c4e9..ce16974077c 100644 --- a/hphp/runtime/vm/debug/debug.cpp +++ b/hphp/runtime/vm/debug/debug.cpp @@ -28,6 +28,7 @@ #include #include #include + #include using namespace HPHP::jit; diff --git a/hphp/runtime/vm/jit/refcount-opts.cpp b/hphp/runtime/vm/jit/refcount-opts.cpp index 3a21aadbfc6..15b860a25ee 100644 --- a/hphp/runtime/vm/jit/refcount-opts.cpp +++ b/hphp/runtime/vm/jit/refcount-opts.cpp @@ -1050,7 +1050,7 @@ void populate_mrinfo(Env& env) { ////////////////////////////////////////////////////////////////////// using HPHP::jit::show; -std::string show(const boost::dynamic_bitset<>& bs) { +DEBUG_ONLY std::string show(const boost::dynamic_bitset<>& bs) { std::ostringstream out; out << bs; return out.str(); @@ -1411,7 +1411,7 @@ void find_alias_sets(Env& env) { ////////////////////////////////////////////////////////////////////// -bool check_state(const RCState& state) { +DEBUG_ONLY bool check_state(const RCState& state) { for (auto asetID = uint32_t{0}; asetID < state.asets.size(); ++asetID) { auto& set = state.asets[asetID]; @@ -2266,7 +2266,7 @@ RCAnalysis rc_analyze(Env& env) { ////////////////////////////////////////////////////////////////////// -std::string show_analysis(Env& env, const RCAnalysis& analysis) { +DEBUG_ONLY std::string show_analysis(Env& env, const RCAnalysis& analysis) { auto ret = std::string{}; for (auto asetID = uint32_t{0}; asetID < env.asets.size(); ++asetID) { @@ -2549,7 +2549,7 @@ std::string graphs_dot_string(const jit::vector& asets, return ret; } -std::string show_graphs(const jit::vector& asets, +DEBUG_ONLY std::string show_graphs(const jit::vector& asets, const jit::vector& heads) { char fileBuf[] = "/tmp/hhvmXXXXXX"; int fd = mkstemp(fileBuf); @@ -2633,7 +2633,7 @@ bool check_graph(Node* graph) { return true; } -bool check_graphs(const jit::vector& graphs) { +DEBUG_ONLY bool check_graphs(const jit::vector& graphs) { for (auto& g : graphs) always_assert(check_graph(g)); return true; } diff --git a/hphp/runtime/vm/jit/srcdb.cpp b/hphp/runtime/vm/jit/srcdb.cpp index e7d9ee40f88..4f879a78d5e 100644 --- a/hphp/runtime/vm/jit/srcdb.cpp +++ b/hphp/runtime/vm/jit/srcdb.cpp @@ -116,7 +116,8 @@ void SrcRec::chainFrom(IncomingBranch br) { m_incomingBranches.push_back(br); TRACE(1, "SrcRec(%p)::chainFrom %p -> %p (type %d); %zd incoming branches\n", this, - br.toSmash(), destAddr, br.type(), m_incomingBranches.size()); + br.toSmash(), destAddr, static_cast(br.type()), + m_incomingBranches.size()); br.patch(destAddr); } diff --git a/hphp/runtime/vm/jit/translator.cpp b/hphp/runtime/vm/jit/translator.cpp index 937a560ef1a..b9c964f82dd 100644 --- a/hphp/runtime/vm/jit/translator.cpp +++ b/hphp/runtime/vm/jit/translator.cpp @@ -1590,7 +1590,7 @@ void Translator::addTranslation(const TransRec& transRec) { transRec.src.offset()).str().c_str(), transRec.aLen, transRec.acoldLen, - transRec.kind); + static_cast(transRec.kind)); } if (!isTransDBEnabled()) return; diff --git a/hphp/runtime/vm/jit/vasm-copy.cpp b/hphp/runtime/vm/jit/vasm-copy.cpp index 2227af67760..c311a312542 100644 --- a/hphp/runtime/vm/jit/vasm-copy.cpp +++ b/hphp/runtime/vm/jit/vasm-copy.cpp @@ -213,7 +213,7 @@ void analyze_physical(Env& env) { } while (!workQ.empty()); } -std::string show_fixed_point(Env& env) { +DEBUG_ONLY std::string show_fixed_point(Env& env) { auto ret = std::string{}; for (auto& b : env.rpoBlocks) { diff --git a/hphp/util/portability.h b/hphp/util/portability.h index e91d14709e3..abd890f779d 100644 --- a/hphp/util/portability.h +++ b/hphp/util/portability.h @@ -141,4 +141,12 @@ ////////////////////////////////////////////////////////////////////// +#ifndef PACKAGE +// The value doesn't matter, but it must be defined before you include +// bfd.h +#define PACKAGE "hhvm" +#endif + +////////////////////////////////////////////////////////////////////// + #endif diff --git a/hphp/util/stack-trace.cpp b/hphp/util/stack-trace.cpp index a2402a428fd..21026965032 100644 --- a/hphp/util/stack-trace.cpp +++ b/hphp/util/stack-trace.cpp @@ -18,6 +18,7 @@ #if (!defined(__CYGWIN__) && !defined(__MINGW__) && !defined(__MSC_VER)) #include #endif + #include #include #include -- 2.11.4.GIT