-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build fails with LTO #42
Comments
@eli-schwartz Thank you for reporting this issue.
|
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.
Errors are here. This is Ubuntu 20.04 with gcc 9.4.0
|
@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. |
#42 reported that with CFLAGS -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing gcc emits errors. Some of them are mistakes when their sources were brought in from PostgreSQL. This commit fixes them. Note that I was not able to suppress some errors at least with my gcc (9.4.0). This may be because gcc bug (false positives) or just a bug with the old gcc, I don't know at this point. Maybe someday revisit this. Discussion: [pgpool-hackers: 4442] Fixing GitHub issue 42 https://www.pgpool.net/pipermail/pgpool-hackers/2024-March/004443.html ../src/include/query_cache/pool_memqcache.h:251:20: warning: type of 'pool_fetch_from_memory_cache' does not match original declaration [-Wlto-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: warning: type of 'CurrentMemoryContext' does not match original declaration [-Wlto-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: warning: type of 'TopMemoryContext' does not match original declaration [-Wlto-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: warning: type of 'pool_config' does not match original declaration [-Wlto-type-mismatch] 646 | extern POOL_CONFIG * pool_config; | ^ config/pool_config.l:46:14: note: 'pool_config' was previously declared here 46 | POOL_CONFIG *pool_config = &g_pool_config; /* for legacy reason pointer to the above struct */ | ^ config/pool_config.l:46:14: note: code may be misoptimized unless '-fno-strict-aliasing' is used
#42 reported that with CFLAGS -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing gcc emits errors. Some of them are mistakes when their sources were brought in from PostgreSQL. This commit fixes them. Note that I was not able to suppress some errors at least with my gcc (9.4.0). This may be because gcc bug (false positives) or just a bug with the old gcc, I don't know at this point. Maybe someday revisit this. Discussion: [pgpool-hackers: 4442] Fixing GitHub issue 42 https://www.pgpool.net/pipermail/pgpool-hackers/2024-March/004443.html ../src/include/query_cache/pool_memqcache.h:251:20: warning: type of 'pool_fetch_from_memory_cache' does not match original declaration [-Wlto-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: warning: type of 'CurrentMemoryContext' does not match original declaration [-Wlto-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: warning: type of 'TopMemoryContext' does not match original declaration [-Wlto-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: warning: type of 'pool_config' does not match original declaration [-Wlto-type-mismatch] 646 | extern POOL_CONFIG * pool_config; | ^ config/pool_config.l:46:14: note: 'pool_config' was previously declared here 46 | POOL_CONFIG *pool_config = &g_pool_config; /* for legacy reason pointer to the above struct */ | ^ config/pool_config.l:46:14: note: code may be misoptimized unless '-fno-strict-aliasing' is used
#42 reported that with CFLAGS -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing gcc emits errors. Some of them are mistakes when their sources were brought in from PostgreSQL. This commit fixes them. Note that I was not able to suppress some errors at least with my gcc (9.4.0). This may be because gcc bug (false positives) or just a bug with the old gcc, I don't know at this point. Maybe someday revisit this. Discussion: [pgpool-hackers: 4442] Fixing GitHub issue 42 https://www.pgpool.net/pipermail/pgpool-hackers/2024-March/004443.html ../src/include/query_cache/pool_memqcache.h:251:20: warning: type of 'pool_fetch_from_memory_cache' does not match original declaration [-Wlto-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: warning: type of 'CurrentMemoryContext' does not match original declaration [-Wlto-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: warning: type of 'TopMemoryContext' does not match original declaration [-Wlto-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: warning: type of 'pool_config' does not match original declaration [-Wlto-type-mismatch] 646 | extern POOL_CONFIG * pool_config; | ^ config/pool_config.l:46:14: note: 'pool_config' was previously declared here 46 | POOL_CONFIG *pool_config = &g_pool_config; /* for legacy reason pointer to the above struct */ | ^ config/pool_config.l:46:14: note: code may be misoptimized unless '-fno-strict-aliasing' is used
#42 reported that with CFLAGS -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing gcc emits errors. Some of them are mistakes when their sources were brought in from PostgreSQL. This commit fixes them. Note that I was not able to suppress some errors at least with my gcc (9.4.0). This may be because gcc bug (false positives) or just a bug with the old gcc, I don't know at this point. Maybe someday revisit this. Discussion: [pgpool-hackers: 4442] Fixing GitHub issue 42 https://www.pgpool.net/pipermail/pgpool-hackers/2024-March/004443.html ../src/include/query_cache/pool_memqcache.h:251:20: warning: type of 'pool_fetch_from_memory_cache' does not match original declaration [-Wlto-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: warning: type of 'CurrentMemoryContext' does not match original declaration [-Wlto-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: warning: type of 'TopMemoryContext' does not match original declaration [-Wlto-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: warning: type of 'pool_config' does not match original declaration [-Wlto-type-mismatch] 646 | extern POOL_CONFIG * pool_config; | ^ config/pool_config.l:46:14: note: 'pool_config' was previously declared here 46 | POOL_CONFIG *pool_config = &g_pool_config; /* for legacy reason pointer to the above struct */ | ^ config/pool_config.l:46:14: note: code may be misoptimized unless '-fno-strict-aliasing' is used
#42 reported that with CFLAGS -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing gcc emits errors. Some of them are mistakes when their sources were brought in from PostgreSQL. This commit fixes them. Note that I was not able to suppress some errors at least with my gcc (9.4.0). This may be because gcc bug (false positives) or just a bug with the old gcc, I don't know at this point. Maybe someday revisit this. Discussion: [pgpool-hackers: 4442] Fixing GitHub issue 42 https://www.pgpool.net/pipermail/pgpool-hackers/2024-March/004443.html ../src/include/query_cache/pool_memqcache.h:251:20: warning: type of 'pool_fetch_from_memory_cache' does not match original declaration [-Wlto-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: warning: type of 'CurrentMemoryContext' does not match original declaration [-Wlto-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: warning: type of 'TopMemoryContext' does not match original declaration [-Wlto-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: warning: type of 'pool_config' does not match original declaration [-Wlto-type-mismatch] 646 | extern POOL_CONFIG * pool_config; | ^ config/pool_config.l:46:14: note: 'pool_config' was previously declared here 46 | POOL_CONFIG *pool_config = &g_pool_config; /* for legacy reason pointer to the above struct */ | ^ config/pool_config.l:46:14: note: code may be misoptimized unless '-fno-strict-aliasing' is used
#42 reported that with CFLAGS -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing gcc emits errors. Some of them are mistakes when their sources were brought in from PostgreSQL. This commit fixes them. Note that I was not able to suppress some errors at least with my gcc (9.4.0). This may be because gcc bug (false positives) or just a bug with the old gcc, I don't know at this point. Maybe someday revisit this. Discussion: [pgpool-hackers: 4442] Fixing GitHub issue 42 https://www.pgpool.net/pipermail/pgpool-hackers/2024-March/004443.html ../src/include/query_cache/pool_memqcache.h:251:20: warning: type of 'pool_fetch_from_memory_cache' does not match original declaration [-Wlto-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: warning: type of 'CurrentMemoryContext' does not match original declaration [-Wlto-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: warning: type of 'TopMemoryContext' does not match original declaration [-Wlto-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: warning: type of 'pool_config' does not match original declaration [-Wlto-type-mismatch] 646 | extern POOL_CONFIG * pool_config; | ^ config/pool_config.l:46:14: note: 'pool_config' was previously declared here 46 | POOL_CONFIG *pool_config = &g_pool_config; /* for legacy reason pointer to the above struct */ | ^ config/pool_config.l:46:14: note: code may be misoptimized unless '-fno-strict-aliasing' is used
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
The text was updated successfully, but these errors were encountered: