From 59265264d56cfb7ced87f9b3666ec570152c5f47 Mon Sep 17 00:00:00 2001 From: Julien Gilli Date: Sun, 25 Jan 2015 23:57:22 -0800 Subject: [PATCH] src: make build pass with GCC < 4.5 Building node with GCC > 4.4 on CentOS makes the node binary depend on a more recent version of the C/C++ runtime that is not installed by default on these older CentOS platforms, and probably on other platforms as well. Building node with the default gcc and g++ compilers that come with these older versions of CentOS allows to ship a node binary that runs out of the box on these setups with older C/C++ runtimes. This change works around a bug that was fixed in GCC 4.5. Versions of GCC < 4.5 would not support using the injected-class-name of a template base class as a type name. This change also disables aliasing optimizations for toolchains using GCC <= 4.4 as they're not able to deal with the aliasing in the queue implementation used by libuv and node (see src/queue.h). Fixes #9079. PR: #9098 PR-URL: https://github.com/joyent/node/pull/9098 Reviewed-By: Timothy J Fontaine Reviewed-By: Trevor Norris --- deps/debugger-agent/debugger-agent.gyp | 8 ++++++++ deps/uv/uv.gyp | 6 ++++++ node.gyp | 6 ++++++ src/cares_wrap.cc | 8 ++++++-- src/node_file.cc | 2 +- src/pipe_wrap.cc | 2 +- src/stream_wrap.h | 6 ++++-- src/tcp_wrap.cc | 2 +- src/udp_wrap.cc | 2 +- 9 files changed, 34 insertions(+), 8 deletions(-) diff --git a/deps/debugger-agent/debugger-agent.gyp b/deps/debugger-agent/debugger-agent.gyp index e98206849ab..3d012ac0d59 100644 --- a/deps/debugger-agent/debugger-agent.gyp +++ b/deps/debugger-agent/debugger-agent.gyp @@ -17,6 +17,14 @@ "include", ], }, + 'conditions': [ + [ 'gcc_version<=44', { + # GCC versions <= 4.4 do not handle the aliasing in the queue + # implementation, so disable aliasing on these platforms + # to avoid subtle bugs + 'cflags': [ '-fno-strict-aliasing' ], + }], + ], "sources": [ "src/agent.cc", ], diff --git a/deps/uv/uv.gyp b/deps/uv/uv.gyp index a5ba14c315a..880c641f18e 100644 --- a/deps/uv/uv.gyp +++ b/deps/uv/uv.gyp @@ -84,6 +84,12 @@ 'src/version.c' ], 'conditions': [ + [ 'gcc_version<=44', { + # GCC versions <= 4.4 do not handle the aliasing in the queue + # implementation, so disable aliasing on these platforms + # to avoid subtle bugs + 'cflags': [ '-fno-strict-aliasing' ], + }], [ 'OS=="win"', { 'defines': [ '_WIN32_WINNT=0x0600', diff --git a/node.gyp b/node.gyp index b59474ee0ac..f60b294627f 100644 --- a/node.gyp +++ b/node.gyp @@ -168,6 +168,12 @@ ], 'conditions': [ + [ 'gcc_version<=44', { + # GCC versions <= 4.4 do not handle the aliasing in the queue + # implementation, so disable aliasing on these platforms + # to avoid subtle bugs + 'cflags': [ '-fno-strict-aliasing' ], + }], [ 'v8_enable_i18n_support==1', { 'defines': [ 'NODE_HAVE_I18N_SUPPORT=1' ], 'dependencies': [ diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index 39c88001563..1764374c121 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -73,7 +73,9 @@ class GetAddrInfoReqWrap : public ReqWrap { GetAddrInfoReqWrap::GetAddrInfoReqWrap(Environment* env, Local req_wrap_obj) - : ReqWrap(env, req_wrap_obj, AsyncWrap::PROVIDER_GETADDRINFOREQWRAP) { + : ReqWrap(env, + req_wrap_obj, + AsyncWrap::PROVIDER_GETADDRINFOREQWRAP) { Wrap(req_wrap_obj, this); } @@ -90,7 +92,9 @@ class GetNameInfoReqWrap : public ReqWrap { GetNameInfoReqWrap::GetNameInfoReqWrap(Environment* env, Local req_wrap_obj) - : ReqWrap(env, req_wrap_obj, AsyncWrap::PROVIDER_GETNAMEINFOREQWRAP) { + : ReqWrap(env, + req_wrap_obj, + AsyncWrap::PROVIDER_GETNAMEINFOREQWRAP) { Wrap(req_wrap_obj, this); } diff --git a/src/node_file.cc b/src/node_file.cc index 8a00b5d9eb5..e04c4c2ddde 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -75,7 +75,7 @@ class FSReqWrap: public ReqWrap { Local req, const char* syscall, char* data = NULL) - : ReqWrap(env, req, AsyncWrap::PROVIDER_FSREQWRAP), + : ReqWrap(env, req, AsyncWrap::PROVIDER_FSREQWRAP), syscall_(syscall), data_(data), dest_len_(0) { diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc index 69cdfcdff3c..2d491997579 100644 --- a/src/pipe_wrap.cc +++ b/src/pipe_wrap.cc @@ -61,7 +61,7 @@ class PipeConnectWrap : public ReqWrap { PipeConnectWrap::PipeConnectWrap(Environment* env, Local req_wrap_obj) - : ReqWrap(env, req_wrap_obj, AsyncWrap::PROVIDER_PIPEWRAP) { + : ReqWrap(env, req_wrap_obj, AsyncWrap::PROVIDER_PIPEWRAP) { Wrap(req_wrap_obj, this); } diff --git a/src/stream_wrap.h b/src/stream_wrap.h index 38e5d484225..d993663b19c 100644 --- a/src/stream_wrap.h +++ b/src/stream_wrap.h @@ -36,7 +36,9 @@ class StreamWrap; class ShutdownWrap : public ReqWrap { public: ShutdownWrap(Environment* env, v8::Local req_wrap_obj) - : ReqWrap(env, req_wrap_obj, AsyncWrap::PROVIDER_SHUTDOWNWRAP) { + : ReqWrap(env, + req_wrap_obj, + AsyncWrap::PROVIDER_SHUTDOWNWRAP) { Wrap(req_wrap_obj, this); } @@ -50,7 +52,7 @@ class WriteWrap: public ReqWrap { // TODO(trevnorris): WrapWrap inherits from ReqWrap, which I've globbed // into the same provider. How should these be broken apart? WriteWrap(Environment* env, v8::Local obj, StreamWrap* wrap) - : ReqWrap(env, obj, AsyncWrap::PROVIDER_WRITEWRAP), + : ReqWrap(env, obj, AsyncWrap::PROVIDER_WRITEWRAP), wrap_(wrap) { Wrap(obj, this); } diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc index a5b20a6ac5a..6b2408c9890 100644 --- a/src/tcp_wrap.cc +++ b/src/tcp_wrap.cc @@ -61,7 +61,7 @@ class TCPConnectWrap : public ReqWrap { TCPConnectWrap::TCPConnectWrap(Environment* env, Local req_wrap_obj) - : ReqWrap(env, req_wrap_obj, AsyncWrap::PROVIDER_TCPWRAP) { + : ReqWrap(env, req_wrap_obj, AsyncWrap::PROVIDER_TCPWRAP) { Wrap(req_wrap_obj, this); } diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc index 614326fa1fb..923875e617c 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -64,7 +64,7 @@ class SendWrap : public ReqWrap { SendWrap::SendWrap(Environment* env, Local req_wrap_obj, bool have_callback) - : ReqWrap(env, req_wrap_obj, AsyncWrap::PROVIDER_UDPWRAP), + : ReqWrap(env, req_wrap_obj, AsyncWrap::PROVIDER_UDPWRAP), have_callback_(have_callback) { Wrap(req_wrap_obj, this); }