Skip to content

Commit a541b92

Browse files
author
Julien Gilli
committed
build: use -fno-strict-aliasing for GCC <= 4.4
Revert the previous change to the queue implementation, and instead disable aliasing optimizations for toolchains using GCC <= 4.4.
1 parent ae15b94 commit a541b92

4 files changed

Lines changed: 27 additions & 7 deletions

File tree

deps/debugger-agent/debugger-agent.gyp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@
1717
"include",
1818
],
1919
},
20+
'conditions': [
21+
[ 'gcc_version<=44', {
22+
# GCC versions <= 4.4 do not handle the aliasing in the queue
23+
# implementation, so disable aliasing on these platforms
24+
# to avoid subtle bugs
25+
'cflags': [ '-fno-strict-aliasing' ],
26+
}],
27+
],
2028
"sources": [
2129
"src/agent.cc",
2230
],

deps/uv/uv.gyp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@
8484
'src/version.c'
8585
],
8686
'conditions': [
87+
[ 'gcc_version<=44', {
88+
# GCC versions <= 4.4 do not handle the aliasing in the queue
89+
# implementation, so disable aliasing on these platforms
90+
# to avoid subtle bugs
91+
'cflags': [ '-fno-strict-aliasing' ],
92+
}],
8793
[ 'OS=="win"', {
8894
'defines': [
8995
'_WIN32_WINNT=0x0600',

node.gyp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,12 @@
168168
],
169169

170170
'conditions': [
171+
[ 'gcc_version<=44', {
172+
# GCC versions <= 4.4 do not handle the aliasing in the queue
173+
# implementation, so disable aliasing on these platforms
174+
# to avoid subtle bugs
175+
'cflags': [ '-fno-strict-aliasing' ],
176+
}],
171177
[ 'v8_enable_i18n_support==1', {
172178
'defines': [ 'NODE_HAVE_I18N_SUPPORT=1' ],
173179
'dependencies': [

src/queue.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,23 @@
1919
typedef void *QUEUE[2];
2020

2121
/* Private macros. */
22-
#define QUEUE_NEXT(q) ((*(q))[0])
23-
#define QUEUE_PREV(q) ((*(q))[1])
24-
#define QUEUE_PREV_NEXT(q) (QUEUE_NEXT((QUEUE *)QUEUE_PREV(q)))
25-
#define QUEUE_NEXT_PREV(q) (QUEUE_PREV((QUEUE *)QUEUE_NEXT(q)))
22+
#define QUEUE_NEXT(q) (*(QUEUE **) &((*(q))[0]))
23+
#define QUEUE_PREV(q) (*(QUEUE **) &((*(q))[1]))
24+
#define QUEUE_PREV_NEXT(q) (QUEUE_NEXT(QUEUE_PREV(q)))
25+
#define QUEUE_NEXT_PREV(q) (QUEUE_PREV(QUEUE_NEXT(q)))
2626

2727
/* Public macros. */
2828
#define QUEUE_DATA(ptr, type, field) \
2929
((type *) ((char *) (ptr) - ((char *) &((type *) 0)->field)))
3030

3131
#define QUEUE_FOREACH(q, h) \
32-
for ((q) = (QUEUE *) QUEUE_NEXT(h); (q) != (h); (q) = (QUEUE *) QUEUE_NEXT(q))
32+
for ((q) = QUEUE_NEXT(h); (q) != (h); (q) = QUEUE_NEXT(q))
3333

3434
#define QUEUE_EMPTY(q) \
35-
((q) == QUEUE_NEXT(q))
35+
((const QUEUE *) (q) == (const QUEUE *) QUEUE_NEXT(q))
3636

3737
#define QUEUE_HEAD(q) \
38-
((QUEUE*)QUEUE_NEXT(q))
38+
(QUEUE_NEXT(q))
3939

4040
#define QUEUE_INIT(q) \
4141
do { \

0 commit comments

Comments
 (0)