Open band-a-prend opened 1 year ago
Workaround: compile files without the offending options.
Workaround: compile files without the offending options.
Already temporary workarounded (https://bugs.gentoo.org/858338) but several distributives currently prefer to build packages with LTO enabled by default or planning to do this.
It seems that https://github.com/albertodemichelis/squirrel/pull/257 fixes one of error for sqcompiler.cpp
LTO necessarily implies no-strict-aliasing?
To reproduce issue the -fno-strict-aliasing
is disabled and -Werror=strict-aliasing
is enabled.
I'm not sure but if this error shows that to avoid UB the proper/more accurate type casting should be used?
Sorry, my knowledge of C++ are too superficial and I easily could be mislead of the compiler option interpretation.
It's incorrect to compile Squirrel without -fno-strict-aliasing
, the compiler might perform incorrect optimisations. If Squirrel is embedded in another project which you want to compile without -fno-strict-aliasing
, then use different compiler arguments for Squirrel. Note that -fstrict-aliasing
just enables some optimisations, it's not important.
Squirrel compiles fine (except the static library which produces ar: plugin needed to handle lto object
) with -flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing
added to the existing flags without removing -fno-strict-aliasing
, I just tried it. So don't remove that.
@rversteegen Thank you for clarifications. As a maintainer of the affected package I was needed to report the observed issue. How to handle it is up to the upstream developers decision as they know the prehistory of project and it's specificity.
Some changes to the code could be made to avoid breaking the strict aliasing rules, by using unions in SQInstruction
, not the ugly solution used in #257. I might do that soon.
It would be a good idea to do so, to avoid depending on compiler flags, which can get lost when embedded in another project.
When trying to build squirrel 3.1 or 3.2 with
-flto -Werror=strict-aliasing
enabled (without passing-fno-strict-aliasing
) the multiple errorsdereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
occur (example for quirrel 3.2 with other warnings):This results in compilation errors where squirrel is used as subproject (see Code::Blocks issue: https://sourceforge.net/p/codeblocks/tickets/1303/).
Steps to reproduce:
CmakeLists.txt
(example for squirrel 3.2) to provide-flto -Werror=strict-aliasing
flags and remove-fno-strict-aliasing
: