-
Notifications
You must be signed in to change notification settings - Fork 7.3k
WIP: src: make build pass with GCC < 4.5 #9098
Conversation
This is a first draft, as there are different ways to solve this problem and I'm looking to gather your feedback. The fix for the "stric-aliasing" warnings in Another way to fix the warnings would of course be to pass the This change also doesn't take care of the queue implementation in libuv, but it would also need to be fixed. Regarding the changes that work around GCC's bug with injected class name of a template base class as a type name, it makes the code less maintainable as it duplicates the template parameter. There are various ways to mitigate that:
@tjfontaine @trevnorris @bnoordhuis @chrisdickinson @cjihrig I'm looking forward to reading your comments. |
The fundamentals of the fix LGTM. Though @bnoordhuis would be the best person for this review. |
The original is essentially untyped. The macros evaluate to a If you want to fix up queue.h, you can do better than this. Compare QUEUE_DATA() with ContainerOf(): the former is an untyped C macro, the latter is a strongly typed C++ template function. You can do a similar thing for the QUEUE data structure. For background, I copied queue.h from libuv because I wanted a quick tailq implementation. It stuck because most people working on the C++ bits were familiar with it. |
Thank you @bnoordhuis for the info! I took another approach with misterdjules@a541b92. Basically, making my changes to Instead, I propose to pass I ran benchmarks (bench-http, bench-fs and bench-tls, not bench-net as it was hanging and I wanted to get some results quickly) on a CentOS 6.6 VM with 4GB of RAM and 4 CPUs. It seems that the binary compiled with The benchmarks' output is not easy to compare with separate files. I just saw how to run benchmarks and output compared results with |
The output of |
this LGTM, thanks! |
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. Fixes nodejs#9079.
a541b92
to
b0258ae
Compare
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 nodejs#9079. PR: nodejs#9098 PR-URL: nodejs#9098 Reviewed-By: Timothy J Fontaine <[email protected]> Reviewed-By: Trevor Norris <[email protected]>
Landed in 5926526, tests pass on all platforms, and more specifically on the CentOS 5.7 agent without loading a more recent libstdc++. Thank you! |
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 fixes a lot of strict-aliasing warnings due to type
casts in the src/queue.h headers.
Fixes #9079.