Skip to content
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

Open
eli-schwartz opened this issue Mar 10, 2024 · 5 comments
Open

Build fails with LTO #42

eli-schwartz opened this issue Mar 10, 2024 · 5 comments
Assignees

Comments

@eli-schwartz
Copy link

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:

/bin/sh ../../../libtool  --tag=CC   --mode=link x86_64-pc-linux-gnu-gcc  -march=native -fstack-protector-all -O2 -pipe -fdiagnostics-color=always -frecord-gcc-switches -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-clash-protection -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing  -Wformat -Werror=format-security -Werror=implicit-function-declaration -Werror=implicit-int -Werror=int-conversion -Werror=incompatible-pointer-types -pthread -Wall -Wmissing-prototypes -Wmissing-declarations -Wno-format-truncation -Wno-stringop-truncation -fno-strict-aliasing -version-info 2:0:0 -Wl,-O1 -Wl,--as-needed -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0 -o libpcp.la -rpath /usr/lib64 pcp.lo ../../utils/pool_path.lo ../../tools/fe_port.lo ../../tools/fe_memutils.lo ../../utils/strlcpy.lo ../../utils/pool_health_check_stats.lo pcp_stream.lo md5.lo json.lo  -lpam -lssl -lcrypto -lcrypt -lresolv -lnsl -lm -lpthread 
libtool: link: x86_64-pc-linux-gnu-gcc -shared  -fPIC -DPIC  .libs/pcp.o ../../utils/.libs/pool_path.o ../../tools/.libs/fe_port.o ../../tools/.libs/fe_memutils.o ../../utils/.libs/strlcpy.o ../../utils/.libs/pool_health_check_stats.o .libs/pcp_stream.o .libs/md5.o .libs/json.o   -Wl,--as-needed -lpam -lssl -lcrypto -lcrypt -lresolv -lnsl -lm -lpthread  -march=native -fstack-protector-all -O2 -fdiagnostics-color=always -frecord-gcc-switches -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Werror=format-security -Werror=implicit-function-declaration -Werror=implicit-int -Werror=int-conversion -Werror=incompatible-pointer-types -Wl,-O1 -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0   -pthread -Wl,-soname -Wl,libpcp.so.2 -o .libs/libpcp.so.2.0.0
../../../src/include/utils/elog.h:211:13: error: type of 'errstart' does not match original declaration [-Werror=lto-type-mismatch]
  211 | extern bool errstart(int elevel, const char *filename, int lineno,
      |             ^
../../tools/fe_port.c:166:1: note: return value type mismatch
  166 | errstart(int elevel, const char *filename, int lineno,
      | ^
../../tools/fe_port.c:166:1: note: type 'int' should match type 'bool'
../../tools/fe_port.c:166:1: note: 'errstart' was previously declared here
../../../src/include/utils/palloc.h:85:14: error: type of 'repalloc' does not match original declaration [-Werror=lto-type-mismatch]
   85 | extern void *repalloc(void *pointer, Size size);
      |              ^
../../tools/fe_memutils.c:128:1: note: type mismatch in parameter 2
  128 | repalloc(void *pointer, unsigned int size)
      | ^
../../tools/fe_memutils.c:128:1: note: type 'unsigned int' should match type 'Size'
../../tools/fe_memutils.c:128:1: note: 'repalloc' was previously declared here
../../tools/fe_memutils.c:128:1: note: code may be misoptimized unless '-fno-strict-aliasing' is used
../../../src/include/utils/palloc.h:83:14: error: type of 'palloc0' does not match original declaration [-Werror=lto-type-mismatch]
   83 | extern void *palloc0(Size size);
      |              ^
../../tools/fe_memutils.c:110:1: note: type mismatch in parameter 1
  110 | palloc0(unsigned int size)
      | ^
../../tools/fe_memutils.c:110:1: note: type 'unsigned int' should match type 'Size'
../../tools/fe_memutils.c:110:1: note: 'palloc0' was previously declared here
../../tools/fe_memutils.c:110:1: note: code may be misoptimized unless '-fno-strict-aliasing' is used
../../../src/include/utils/palloc.h:82:14: error: type of 'palloc' does not match original declaration [-Werror=lto-type-mismatch]
   82 | extern void *palloc(Size size);
      |              ^
../../tools/fe_memutils.c:104:1: note: type mismatch in parameter 1
  104 | palloc(unsigned int size)
      | ^
../../tools/fe_memutils.c:104:1: note: type 'unsigned int' should match type 'Size'
../../tools/fe_memutils.c:104:1: note: 'palloc' was previously declared here
../../tools/fe_memutils.c:104:1: note: code may be misoptimized unless '-fno-strict-aliasing' is used
lto1: some warnings being treated as errors
lto-wrapper: fatal error: x86_64-pc-linux-gnu-gcc returned 1 exit status
compilation terminated.
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
make[3]: *** [Makefile:464: libpcp.la] Error 1

[...]

/bin/sh ../../../libtool  --tag=CC   --mode=link x86_64-pc-linux-gnu-gcc  -march=native -fstack-protector-all -O2 -pipe -fdiagnostics-color=always -frecord-gcc-switches -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-clash-protection -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing  -Wformat -Werror=format-security -Werror=implicit-function-declaration -Werror=implicit-int -Werror=int-conversion -Werror=incompatible-pointer-types -pthread -Wall -Wmissing-prototypes -Wmissing-declarations -Wno-format-truncation -Wno-stringop-truncation -fno-strict-aliasing  -Wl,-O1 -Wl,--as-needed -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0 -o pg_md5 pg_md5.o ../fe_port.o md5.o pool_passwd.o strlcpy.o regex_array.o pool_config_variables.o pool_config.o fe_memutils.o pool_path.o  -lpam -lssl -lcrypto -lcrypt -lresolv -lnsl -lm -lpthread 
libtool: link: x86_64-pc-linux-gnu-gcc -march=native -fstack-protector-all -O2 -pipe -fdiagnostics-color=always -frecord-gcc-switches -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-clash-protection -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wformat -Werror=format-security -Werror=implicit-function-declaration -Werror=implicit-int -Werror=int-conversion -Werror=incompatible-pointer-types -Wall -Wmissing-prototypes -Wmissing-declarations -Wno-format-truncation -Wno-stringop-truncation -fno-strict-aliasing -Wl,-O1 -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0 -o pg_md5 pg_md5.o ../fe_port.o md5.o pool_passwd.o strlcpy.o regex_array.o pool_config_variables.o pool_config.o fe_memutils.o pool_path.o  -Wl,--as-needed -lpam -lssl -lcrypto -lcrypt -lresolv -lnsl -lm -lpthread -pthread
../../../src/include/utils/palloc.h:82:14: error: type of 'palloc' does not match original declaration [-Werror=lto-type-mismatch]
   82 | extern void *palloc(Size size);
      |              ^
fe_memutils.c:104:1: note: type mismatch in parameter 1
  104 | palloc(unsigned int size)
      | ^
fe_memutils.c:104:1: note: type 'unsigned int' should match type 'Size'
fe_memutils.c:104:1: note: 'palloc' was previously declared here
fe_memutils.c:104:1: note: code may be misoptimized unless '-fno-strict-aliasing' is used
../../../src/include/utils/elog.h:211:13: error: type of 'errstart' does not match original declaration [-Werror=lto-type-mismatch]
  211 | extern bool errstart(int elevel, const char *filename, int lineno,
      |             ^
../fe_port.c:166:1: note: return value type mismatch
  166 | errstart(int elevel, const char *filename, int lineno,
      | ^
../fe_port.c:166:1: note: type 'int' should match type 'bool'
../fe_port.c:166:1: note: 'errstart' was previously declared here
lto1: some warnings being treated as errors
lto-wrapper: fatal error: x86_64-pc-linux-gnu-gcc returned 1 exit status
compilation terminated.
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
make[3]: *** [Makefile:436: pg_md5] Error 1

[...]

/bin/sh ../../../libtool  --tag=CC   --mode=link x86_64-pc-linux-gnu-gcc  -march=native -fstack-protector-all -O2 -pipe -fdiagnostics-color=always -frecord-gcc-switches -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-clash-protection -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing  -Wformat -Werror=format-security -Werror=implicit-function-declaration -Werror=implicit-int -Werror=int-conversion -Werror=incompatible-pointer-types -pthread -Wall -Wmissing-prototypes -Wmissing-declarations -Wno-format-truncation -Wno-stringop-truncation -fno-strict-aliasing  -Wl,-O1 -Wl,--as-needed -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0 -o pg_enc pg_enc.o ../fe_port.o ssl_utils.o md5.o base64.o pool_passwd.o strlcpy.o regex_array.o pool_config_variables.o pool_config.o fe_memutils.o pool_path.o  -lpam -lssl -lcrypto -lcrypt -lresolv -lnsl -lm -lpthread 
libtool: link: x86_64-pc-linux-gnu-gcc -march=native -fstack-protector-all -O2 -pipe -fdiagnostics-color=always -frecord-gcc-switches -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-clash-protection -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wformat -Werror=format-security -Werror=implicit-function-declaration -Werror=implicit-int -Werror=int-conversion -Werror=incompatible-pointer-types -Wall -Wmissing-prototypes -Wmissing-declarations -Wno-format-truncation -Wno-stringop-truncation -fno-strict-aliasing -Wl,-O1 -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0 -o pg_enc pg_enc.o ../fe_port.o ssl_utils.o md5.o base64.o pool_passwd.o strlcpy.o regex_array.o pool_config_variables.o pool_config.o fe_memutils.o pool_path.o  -Wl,--as-needed -lpam -lssl -lcrypto -lcrypt -lresolv -lnsl -lm -lpthread -pthread
../../../src/include/utils/palloc.h:82:14: error: type of 'palloc' does not match original declaration [-Werror=lto-type-mismatch]
   82 | extern void *palloc(Size size);
      |              ^
fe_memutils.c:104:1: note: type mismatch in parameter 1
  104 | palloc(unsigned int size)
      | ^
fe_memutils.c:104:1: note: type 'unsigned int' should match type 'Size'
fe_memutils.c:104:1: note: 'palloc' was previously declared here
fe_memutils.c:104:1: note: code may be misoptimized unless '-fno-strict-aliasing' is used
../../../src/include/utils/elog.h:211:13: error: type of 'errstart' does not match original declaration [-Werror=lto-type-mismatch]
  211 | extern bool errstart(int elevel, const char *filename, int lineno,
      |             ^
../pgmd5/../fe_port.c:166:1: note: return value type mismatch
  166 | errstart(int elevel, const char *filename, int lineno,
      | ^
../pgmd5/../fe_port.c:166:1: note: type 'int' should match type 'bool'
../pgmd5/../fe_port.c:166:1: note: 'errstart' was previously declared here
lto1: some warnings being treated as errors
lto-wrapper: fatal error: x86_64-pc-linux-gnu-gcc returned 1 exit status
compilation terminated.
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
make[3]: *** [Makefile:439: pg_enc] Error 1

[...]

/bin/sh ../../../libtool  --tag=CC   --mode=link x86_64-pc-linux-gnu-gcc  -march=native -fstack-protector-all -O2 -pipe -fdiagnostics-color=always -frecord-gcc-switches -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-clash-protection -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing  -Wformat -Werror=format-security -Werror=implicit-function-declaration -Werror=implicit-int -Werror=int-conversion -Werror=incompatible-pointer-types -pthread -Wall -Wmissing-prototypes -Wmissing-declarations -Wno-format-truncation -Wno-stringop-truncation -fno-strict-aliasing  -Wl,-O1 -Wl,--as-needed -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0 -o wd_cli wd_cli.o ../fe_port.o ssl_utils.o wd_ipc_conn.o wd_commands.o json_writer.o json.o pool_config_variables.o pool_config.o pool_path.o fe_memutils.o stringinfo.o strlcpy.o socket_stream.o regex_array.o psprintf.o md5.o  -lpam -lssl -lcrypto -lcrypt -lresolv -lnsl -lm -lpthread 
libtool: link: x86_64-pc-linux-gnu-gcc -march=native -fstack-protector-all -O2 -pipe -fdiagnostics-color=always -frecord-gcc-switches -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-clash-protection -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wformat -Werror=format-security -Werror=implicit-function-declaration -Werror=implicit-int -Werror=int-conversion -Werror=incompatible-pointer-types -Wall -Wmissing-prototypes -Wmissing-declarations -Wno-format-truncation -Wno-stringop-truncation -fno-strict-aliasing -Wl,-O1 -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0 -o wd_cli wd_cli.o ../fe_port.o ssl_utils.o wd_ipc_conn.o wd_commands.o json_writer.o json.o pool_config_variables.o pool_config.o pool_path.o fe_memutils.o stringinfo.o strlcpy.o socket_stream.o regex_array.o psprintf.o md5.o  -Wl,--as-needed -lpam -lssl -lcrypto -lcrypt -lresolv -lnsl -lm -lpthread -pthread
../../../src/include/utils/palloc.h:85:14: error: type of 'repalloc' does not match original declaration [-Werror=lto-type-mismatch]
   85 | extern void *repalloc(void *pointer, Size size);
      |              ^
fe_memutils.c:128:1: note: type mismatch in parameter 2
  128 | repalloc(void *pointer, unsigned int size)
      | ^
fe_memutils.c:128:1: note: type 'unsigned int' should match type 'Size'
fe_memutils.c:128:1: note: 'repalloc' was previously declared here
fe_memutils.c:128:1: note: code may be misoptimized unless '-fno-strict-aliasing' is used
../../../src/include/utils/palloc.h:82:14: error: type of 'palloc' does not match original declaration [-Werror=lto-type-mismatch]
   82 | extern void *palloc(Size size);
      |              ^
fe_memutils.c:104:1: note: type mismatch in parameter 1
  104 | palloc(unsigned int size)
      | ^
fe_memutils.c:104:1: note: type 'unsigned int' should match type 'Size'
fe_memutils.c:104:1: note: 'palloc' was previously declared here
fe_memutils.c:104:1: note: code may be misoptimized unless '-fno-strict-aliasing' is used
../../../src/include/utils/elog.h:211:13: error: type of 'errstart' does not match original declaration [-Werror=lto-type-mismatch]
  211 | extern bool errstart(int elevel, const char *filename, int lineno,
      |             ^
../pgmd5/../fe_port.c:166:1: note: return value type mismatch
  166 | errstart(int elevel, const char *filename, int lineno,
      | ^
../pgmd5/../fe_port.c:166:1: note: type 'int' should match type 'bool'
../pgmd5/../fe_port.c:166:1: note: 'errstart' was previously declared here
lto1: some warnings being treated as errors
lto-wrapper: fatal error: x86_64-pc-linux-gnu-gcc returned 1 exit status
compilation terminated.
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
make[3]: *** [Makefile:477: wd_cli] Error 1

Previously reported against an older version of pgpool2 downstream: https://bugs.gentoo.org/855248
Full build log: build.log

@pengbo0328 pengbo0328 self-assigned this Mar 11, 2024
@pengbo0328
Copy link
Collaborator

@eli-schwartz Thank you for reporting this issue.
Could you share the following information?

  • OS
  • GCC version

@eli-schwartz
Copy link
Author

Gentoo Linux with GCC 13

@tatsuo-ishii
Copy link
Collaborator

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

@pengbo0328
Copy link
Collaborator

@tatsuo-ishii Thank you for your patch. I looks good to me.

@tatsuo-ishii
Copy link
Collaborator

@pengbo0328 Thank you for review. I have pushed the patch to the upstream git repository.

pengbo0328 pushed a commit that referenced this issue Mar 25, 2024
#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
pengbo0328 pushed a commit that referenced this issue Mar 25, 2024
#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
pengbo0328 pushed a commit that referenced this issue Mar 25, 2024
#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
pengbo0328 pushed a commit that referenced this issue Mar 25, 2024
#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
pengbo0328 pushed a commit that referenced this issue Mar 25, 2024
#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
pengbo0328 pushed a commit that referenced this issue Mar 25, 2024
#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants