mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-25 07:41:36 +02:00
BUILD: add detection for unsupported compiler models
As reported in github issue #1765, some people get trapped into building haproxy and companion libraries on Windows using a compiler following the LLP64 model. This has no chance to work, and definitely causes nasty bugs everywhere when pointers are passed as longs. Let's save them time and detect this at boot time. The message and detection was factored with the existing one for -fwrapv since we need the same info and actions. This should be backported to all recent supported versions (the ones that are likely to be tried on such platforms when people don't know).
This commit is contained in:
parent
d4835a9680
commit
41afd9084e
@ -3029,14 +3029,28 @@ int main(int argc, char **argv)
|
||||
int pidfd = -1;
|
||||
int intovf = (unsigned char)argc + 1; /* let the compiler know it's strictly positive */
|
||||
|
||||
/* Catch broken toolchains */
|
||||
if (sizeof(long) != sizeof(void *) || (intovf + 0x7FFFFFFF >= intovf)) {
|
||||
const char *msg;
|
||||
|
||||
if (sizeof(long) != sizeof(void *))
|
||||
/* Apparently MingW64 was not made for us and can also break openssl */
|
||||
msg = "The compiler this program was built with uses unsupported integral type sizes.\n"
|
||||
"Most likely it follows the unsupported LLP64 model. Never try to link HAProxy\n"
|
||||
"against libraries built with that compiler either! Please only use a compiler\n"
|
||||
"producing ILP32 or LP64 programs for both programs and libraries.\n";
|
||||
else if (intovf + 0x7FFFFFFF >= intovf)
|
||||
/* Catch forced CFLAGS that miss 2-complement integer overflow */
|
||||
if (intovf + 0x7FFFFFFF >= intovf) {
|
||||
fprintf(stderr,
|
||||
"FATAL ERROR: invalid code detected -- cannot go further, please recompile!\n"
|
||||
"The source code was miscompiled by the compiler, which usually indicates that\n"
|
||||
msg = "The source code was miscompiled by the compiler, which usually indicates that\n"
|
||||
"some of the CFLAGS needed to work around overzealous compiler optimizations\n"
|
||||
"were overwritten at build time. Please do not force CFLAGS, and read Makefile\n"
|
||||
"and INSTALL files to decide on the best way to pass your local build options.\n"
|
||||
"and INSTALL files to decide on the best way to pass your local build options.\n";
|
||||
else
|
||||
msg = "Bug in the compiler bug detection code, please report it to developers!\n";
|
||||
|
||||
fprintf(stderr,
|
||||
"FATAL ERROR: invalid code detected -- cannot go further, please recompile!\n"
|
||||
"%s"
|
||||
"\nBuild options :"
|
||||
#ifdef BUILD_TARGET
|
||||
"\n TARGET = " BUILD_TARGET
|
||||
@ -3056,7 +3070,8 @@ int main(int argc, char **argv)
|
||||
#ifdef BUILD_DEBUG
|
||||
"\n DEBUG = " BUILD_DEBUG
|
||||
#endif
|
||||
"\n\n");
|
||||
"\n\n", msg);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user