-
Notifications
You must be signed in to change notification settings - Fork 987
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
Add inline with SNAPPY_ATTRIBUTE_ALWAYS_INLINE #128
Conversation
Add inline with SNAPPY_ATTRIBUTE_ALWAYS_INLINE on AdvanceToNextTag to fix the following compilation errors and a warning with GCC: [ 2%] Building CXX object CMakeFiles/snappy.dir/snappy.cc.o /usr/bin/c++ -DHAVE_CONFIG_H -Dsnappy_EXPORTS -I/tmp/snappy-1.1.9/build -I/tmp/snappy-1.1.9 -O3 -march=i586 -mtune=i686 -Wall -Wextra -fno-exceptions -fno-rtti -O3 -DNDEBUG -fPIC -std=c++11 -o CMakeFiles/snappy.dir/snappy.cc.o -c /tmp/snappy-1.1.9/snappy.cc /tmp/snappy-1.1.9/snappy.cc:1017:8: warning: always_inline function might not be inlinable [-Wattributes] size_t AdvanceToNextTag(const uint8_t** ip_p, size_t* tag) { ^ /tmp/snappy-1.1.9/snappy.cc: In function 'std::pair<const unsigned char*, int> snappy::DecompressBranchless(const uint8_t*, const uint8_t*, ptrdiff_t, T, ptrdiff_t) [with T = char*; uint8_t = unsigned char; ptrdiff_t = int]': /tmp/snappy-1.1.9/snappy.cc:1017:8: error: inlining failed in call to always_inline 'size_t snappy::AdvanceToNextTag(const uint8_t**, size_t*)': function body can be overwritten at link time /tmp/snappy-1.1.9/snappy.cc:1097:53: error: called from here size_t tag_type = AdvanceToNextTag(&ip, &tag); ^ /tmp/snappy-1.1.9/snappy.cc:1017:8: error: inlining failed in call to always_inline 'size_t snappy::AdvanceToNextTag(const uint8_t**, size_t*)': function body can be overwritten at link time size_t AdvanceToNextTag(const uint8_t** ip_p, size_t* tag) { ^ /tmp/snappy-1.1.9/snappy.cc:1097:53: error: called from here size_t tag_type = AdvanceToNextTag(&ip, &tag); ^ /tmp/snappy-1.1.9/snappy.cc:1017:8: error: inlining failed in call to always_inline 'size_t snappy::AdvanceToNextTag(const uint8_t**, size_t*)': function body can be overwritten at link time size_t AdvanceToNextTag(const uint8_t** ip_p, size_t* tag) { ^ /tmp/snappy-1.1.9/snappy.cc:1097:53: error: called from here size_t tag_type = AdvanceToNextTag(&ip, &tag); ^ CMakeFiles/snappy.dir/build.make:137: recipe for target 'CMakeFiles/snappy.dir/snappy.cc.o' failed Just like with other functions using SNAPPY_ATTRIBUTE_ALWAYS_INLINE macro (i.e. __attribute__((always_inline)) ) it is necessary to use C++ inline specifier.
Please note, this error appears only with GCC and -DBUILD_SHARED_LIBS=ON. Need to add this configuration to Travis matrix to cover this problem. |
It also fails with -DBUILD_SHARED_LIBS=OFF actually. As well as clang < 9 or apple-clang < 11 with an other error. |
To clarify my build configuration that lead to reported errors was:
I'm not familiar with project's CI configuration (what compilers, OSes and configuration options are used), but I believe it is better to have code that supports most of the compilers, instead of just latest versions. Right now I'm compiling with GCC 5.5.0 for Slackware 14.2, but soon I'll be compiling the same with GCC 10.3 for Slackware 15.0 and there are variety of other configurations with other distributions. |
Great! We hit this error as well in 1.1.9 with gcc-8 (but only for shared libs).
|
Patch taken from google/snappy#128
Patch taken from google/snappy#128
Patch taken from google/snappy#128
Although the total ignorance I updated the patch to avoid conflicts with the base branch. |
Is there any updates here? We also see this when we try to build the snappy on linux |
Current changes allow to build on linux |
@andypost Can you please, explain (i.e. what changed or give a commit reference)? |
@gdsotirov I'm building it for Alpinelinux (musl) you can see it in https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/24894 |
@andypost Ah, OK. I misunderstood you. I though you mean that "current changes" in this repository allow to build on Linux. Anyway, we'll apparently continue use the patch until upstream considers fixing the problem. |
- using patch for inlining google/snappy#128 - tests and benchmark are third-party, using additional sources and unittests
Why don't you fix it!! Debian gives different modification methods https://sources.debian.org/patches/snappy/1.1.9-2/0001-Add-inline-with-SNAPPY_ATTRIBUTE_ALWAYS_INLINE.patch/,and I also encountered this problem on MPIS. |
Patch seems to be applied with d644ca8. I assume that this PR can be closed. |
Sure. It took more than 2 years to add one word in the code to fix compilation... |
Add
inline
withSNAPPY_ATTRIBUTE_ALWAYS_INLINE
onAdvanceToNextTag
to fix the following compilation errors and a warning with GCC:Just like with other functions using
SNAPPY_ATTRIBUTE_ALWAYS_INLINE
macro (i.e.__attribute__((always_inline))
) it is necessary to use C++inline
specifier.