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 strict-aliasing violations #92

Open
eli-schwartz opened this issue Mar 6, 2024 · 0 comments
Open

Build fails with strict-aliasing violations #92

eli-schwartz opened this issue Mar 6, 2024 · 0 comments

Comments

@eli-schwartz
Copy link

I tried to compile with LTO: -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing

The -Werror=* flags are important to detect cases where the compiler can try to optimize based on assuming UB cannot happen, and miscompile code that has UB in it. strict-aliasing issues are always bad but LTO can make them even worse.

I got this error:

/bin/sh ../../libtool  --tag=CC   --mode=compile x86_64-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I../..  -include ../../config.h -I ../../include  -Wall -Wextra -Wno-unused -Wno-unused-result -Wno-strict-aliasing -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 -c -o built-in/libply_la-buffer.lo `test -f 'built-in/buffer.c' || echo './'`built-in/buffer.c
libtool: compile:  x86_64-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I../.. -include ../../config.h -I ../../include -Wall -Wextra -Wno-unused -Wno-unused-result -Wno-strict-aliasing -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 -c built-in/buffer.c  -fPIC -DPIC -o built-in/.libs/libply_la-buffer.o
built-in/buffer.c: In function '__get_head':
built-in/buffer.c:83:36: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
   83 |         volatile uint64_t head = *((volatile uint64_t *)&mem->data_head);
      |                                   ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors

Downstream report: https://bugs.gentoo.org/858458
Full build log: build.log

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

1 participant