Open eli-schwartz opened 6 months ago
@eli-schwartz Thank you for reporting this issue. Could you share the following information?
Gentoo Linux with GCC 13
I have tried this and fixed some errors. See attached patches. However still I get some errors. I suspect they are false positives. configure options are:
./configure CFLAGS="-g -O2 -Wall -Wmissing-prototypes -Wmissing-declarations -Wno-format-truncation -Wno-stringop-truncation -fno-strict-aliasing -flto=4 -Werror=odr -Werror=lto-type-mismatch" --with-openssl --with-memcached=/usr
Errors are here. This is Ubuntu 20.04 with gcc 9.4.0 fix_compiler_errors.txt
../src/include/query_cache/pool_memqcache.h:251:20: error: type of 'pool_fetch_from_memory_cache' does not match original declaration [-Werror=lto-type-mismatch]
251 | extern POOL_STATUS pool_fetch_from_memory_cache(POOL_CONNECTION * frontend,
| ^
query_cache/pool_memqcache.c:731:1: note: 'pool_fetch_from_memory_cache' was previously declared here
731 | pool_fetch_from_memory_cache(POOL_CONNECTION * frontend,
| ^
query_cache/pool_memqcache.c:731:1: note: code may be misoptimized unless '-fno-strict-aliasing' is used
../src/include/utils/palloc.h:64:22: error: type of 'CurrentMemoryContext' does not match original declaration [-Werror=lto-type-mismatch]
64 | extern MemoryContext CurrentMemoryContext;
| ^
../../src/utils/mmgr/mcxt.c:40:15: note: 'CurrentMemoryContext' was previously declared here
../../src/utils/mmgr/mcxt.c:40:15: note: code may be misoptimized unless '-fno-strict-aliasing' is used
../src/include/utils/memutils.h:55:22: error: type of 'TopMemoryContext' does not match original declaration [-Werror=lto-type-mismatch]
55 | extern MemoryContext TopMemoryContext;
| ^
../../src/utils/mmgr/mcxt.c:46:15: note: 'TopMemoryContext' was previously declared here
../../src/utils/mmgr/mcxt.c:46:15: note: code may be misoptimized unless '-fno-strict-aliasing' is used
../src/include/pool_config.h:646:22: error: type of 'pool_config' does not match original declaration [-Werror=lto-type-mismatch]
646 | extern POOL_CONFIG * pool_config;
| ^
pool_config.l:46:14: note: 'pool_config' was previously declared here
pool_config.l:46:14: note: code may be misoptimized unless '-fno-strict-aliasing' is used
lto1: some warnings being treated as errors
lto-wrapper: fatal error: gcc returned 1 exit status
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:819: pgpool] Error 1
make[1]: *** [Makefile:942: all-recursive] Error 1
make: *** [Makefile:413: all-recursive] Error 1
@tatsuo-ishii Thank you for your patch. I looks good to me.
@pengbo0328 Thank you for review. I have pushed the patch to the upstream git repository.
I tried to build with the following *FLAGS to optimize the build:
-flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing
Note the -Werror=* flags are used to help detect cases where the compiler tries to optimize by assuming UB cannot exist in the source code -- if it does exist, ordinarily the code would be miscompiled, and this says to make the miscompilation a fatal error.
I got this error:
Previously reported against an older version of pgpool2 downstream: https://bugs.gentoo.org/855248 Full build log: build.log