BUILD: compiler: workaround a glibc madness around __attribute__()
authorWilly Tarreau <w@1wt.eu>
Thu, 10 Sep 2020 07:26:50 +0000 (09:26 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 10 Sep 2020 07:26:50 +0000 (09:26 +0200)
commitf6afda6539cc074c8703c0a6e342bd9c9203245a
treebbaeba1ef6eb598d9ca6f27bcef6e07e6c1cab7c
parentd9537f6082b4ddacbfb0604b291c83c5256d223d
BUILD: compiler: workaround a glibc madness around __attribute__()

For whatever reason, glibc decided that the __attribute__ keyword is
the exclusive property of gcc, and redefines it to an empty macro on
other compilers. Some non-gcc compilers also support it (possibly
partially), tinycc is one of them. By doing this, glibc silently
broke all constructors, resulting in code that arrives in main() with
uninitialized variables.

The solution we use here consists in undefining the macro on non-gcc
compilers, and redefining it to itself in order to cause a conflict in
the event the redefinition would happen afterwards. This visibly solved
the problem.
include/haproxy/compiler.h