GCC-12 fails to inline XXX_FORCED_INLINE functions, XXH3_accumulate_512_sse2(), and XXH3_scrambleAcc_sse2() with -Og flag. #800
Labels
No labels
announcement
bug
build
CI
dependencies
documentation
duplicate
enhancement
experience feedback
feature request
github_actions
help wanted
install
invalid
Long-term
optimization
portability
question
target-specific
test issue
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-Cyan4973/xxHash#800
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi, I tried compiling Thunderbird mail client using GCC-12.
Well, with -Og flag, it fails to inline the following two functions and compilation aborts.
XXH3_accumulate_512_sse2()
XXH3_scrambleAcc_sse2()
Without -Og, the compilation succeeds.
Mozilla bugzilla is here.
https://bugzilla.mozilla.org/show_bug.cgi?id=1817565
I was advised to post a bug report at this github repository.
I think we may need to enable/disable XXX_FORCED_INLINE attribute for these two functions depending on the GCC version and
whether -Og is used. But according to gcc bugzilla, there is currently no such macro that is defined when -Og is used on the command line.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107931
Come to think of it, macro is a preprocessor feature and so whether -Og is used or not is no concern to the preprocessor.
So it figures.
I need to settle on a certain macro such as __GCC_12_FAILS_ALWAYS_INLINE_WITH_DEBUG_OPT
and wrap the XXX_FORCED_INLINE attribute for the two functions as follows.
#if ! defined(__GCC_12_FAILS_ALWAYS_INLINE_WITH_DEBUG_OPT)
XXX_FORCED_INLINE
#endif
And then when I use -Og, I will define -D__GCC_12FAILS_ALWAYS_INLINE_WITH_DEBUG_OPT
and unless this macro is defined, all is well. The functions would be inlined. (At least GCC will not complain.)
It seems to be a compiler-specific and version-specific problem (GCC-10, GCC-11 did not report the errors. B now I am not quite convinced whether they really inlined the functions or not. According the gcc bugzilla, sometimes errors were/are not reported.)
So there is not much we can do. I just wanted to let you know the issue exists.
BUT if some measures are taken here, I don't have to modify my local Mozilla source code which imports xxhash source tree, and everybody who would compile xxHash with gcc-12 and -Og will be happier about it. :-)
Thank you for making a very fast hash library available to the general programming community.
Indeed, there are known issues when compiling
libxxhashwith the-Ogflag on moderngccversion : https://github.com/Cyan4973/xxHash/pull/720Unfortunately, there is no "generic" solution yet,
partially because
-Ogdoesn't provide any indication that it is being employed to the preprocessor, so it can't adjust the source code.It's unclear if there will be a solution to this problem, or if it's something that can only be fixed on the compiler side.
A manual work around involves combining this flag with an appropriate xxhash build macro, such as
XXH_NO_INLINE_HINTS, though it obviously impacts performance.I believe the solution is to not mark the functions that are turned into pointers force inline, as
-Ogtries to guarantee that pointers are not optimized out.Well, this is what
XXH_NO_INLINE_HINTSachieves.So there is a work around.
I presume the issue is that this build macro is not automatically triggered when compiling with
-Og.And it's unclear if this can be done, since
-Ogdoesn't expose any standard macro for detection.I think I will define
__NO_INLINE__manually when I compile thunderbird mail client with GCC-12 and -Og flag.
That seems to take care of the issue.
Indeed, I could compile the code with -Og using gcc-12 after -D__NO_INLINE__ is added.
https://github.com/Cyan4973/xxHash/pull/720#issuecomment-1414481935
-DXXH_NO_INLINE_HINTS=1functionally does the same thing without modifying reserved macros. xxHash selects these things when these macros are defined but they all can be defined manually.I think #804 fixes this issue. If you can merge it, please let us know what happens in your project.
We can close this issue, since #802, #804 and #810 have resolved/ensured it. Ping @Cyan4973