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

rados+rpm: Update symver defs and re-enable LTO #42602

Merged
merged 6 commits into from Aug 6, 2021
Merged

Conversation

b-ranto
Copy link
Contributor

@b-ranto b-ranto commented Aug 3, 2021

The gcc compiler now supports symver attribute. We should update the symvers to be able to support LTO on the platforms that support the symver attribute.

Fixes: https://tracker.ceph.com/issues/40060

Checklist

  • References tracker ticket
  • Updates documentation if necessary
  • Includes tests for new functionality or reproducer for bug

Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox

@b-ranto
Copy link
Contributor Author

b-ranto commented Aug 3, 2021

@b-ranto b-ranto requested review from tchaikov and badone August 3, 2021 10:00
@b-ranto
Copy link
Contributor Author

b-ranto commented Aug 3, 2021

It looks like we can't do this just yet. There is no support for the attribute in the older versions of gcc (it might have been introduced in GCC 10 iirc).

Maybe, we could do this conditionally -- check if the attribute is supported and fall-back to asm definitions if it is not?

@b-ranto
Copy link
Contributor Author

b-ranto commented Aug 4, 2021

OK, I have implemented conditional use of the attribute. It will only be used if the compiler supports the symver attribute.

Copy link
Contributor

@badone badone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

src/librados/librados_c.cc Show resolved Hide resolved
cmake/modules/CephChecks.cmake Show resolved Hide resolved
ceph.spec.in Outdated Show resolved Hide resolved
@smithfarm
Copy link
Contributor

@b-ranto Thanks for this! Could you add

Fixes: https://tracker.ceph.com/issues/40060

to one of the commits so the git history contains a link to the Redmine issue? (Maybe librados/librados_c: Use symver attribute if available is the most relevant?)

@smithfarm smithfarm self-requested a review August 5, 2021 08:31
@smithfarm
Copy link
Contributor

Also, if it's not too much trouble, could we hold off from merging this until I test that it doesn't break the openSUSE Factory build?

The build fails because the function definitions are out of order. This
also reuses the LIBRADOS_C_API_DEFAULT_F macro for function definitions.

Fixes: https://tracker.ceph.com/issues/40060
Signed-off-by: Boris Ranto <branto@redhat.com>
The gcc compiler now supports symver attribute. We should update the
symvers to be able to support LTO.

Fixes: https://tracker.ceph.com/issues/40060
Signed-off-by: Boris Ranto <branto@redhat.com>
@b-ranto
Copy link
Contributor Author

b-ranto commented Aug 5, 2021

@smithfarm Sure, we can wait for the openSUSE fatctory build -- that is why I was asking for the suse_version from which we can enable LTO. :-)

Anyway, I did put the fixes line to the commits before, I just forgot to add it to the latest commits, I have updated those too, now.

@smithfarm
Copy link
Contributor

smithfarm commented Aug 5, 2021

@b-ranto Thanks! Would it make sense (and be worth the trouble) to mention Fixes: https://tracker.ceph.com/issues/40060 in the PR description as well?

cmake/modules/CephChecks.cmake Outdated Show resolved Hide resolved
@smithfarm
Copy link
Contributor

@b-ranto master, quincy, and pacific only target openSUSE Leap 15.3/SLE-15-SP3 and above. So if this patchset works fine in SLE-15-SP3 and Factory, there won't be any need to add a suse_version guard to ceph.spec.in for this PR.

I will trigger a test build on SLE-15-SP3 and Factory now.

@b-ranto
Copy link
Contributor Author

b-ranto commented Aug 5, 2021

@smithfarm Sounds good, AFAIK, the support for the attribute landed in GCC 10 so if you use GCC 10 in these, you should be good.

@smithfarm
Copy link
Contributor

@smithfarm Sounds good, AFAIK, the support for the attribute landed in GCC 10 so if you use GCC 10 in these, you should be good.

Yeah, I got that part. What I'm looking at now is whether the cmake code and guards that are being added here are enough for this patch to work in SLE-15-SP3, which has gcc 7.

@smithfarm
Copy link
Contributor

The reason I'm looking at SLE-15-SP3 at all is because the Redmine ticket says this is going to be backported to pacific.

If that's wrong, and this is not going to be backported to pacific, then my task will be much simpler, since I'll only have to build it for openSUSE Factory :-)

@b-ranto
Copy link
Contributor Author

b-ranto commented Aug 5, 2021

Yes, it is also targeted for pacific. You will definitelly need to keep the bits that disable LTO for SLE-15-SP3 then.

b-ranto and others added 4 commits August 5, 2021 15:46
We can now use LTO when building ceph. The symver issue was fixed by
using the gcc __symver__ attribute. The systems that support it can now
re-enable LTO.

Fixes: https://tracker.ceph.com/issues/40060
Signed-off-by: Boris Ranto <branto@redhat.com>
We should check if -flto-partition=none is defined when the compiler
does not support symver attribute and fail the build if it is not.

Fixes: https://tracker.ceph.com/issues/40060
Co-authored-by: Kefu Chai <tchaikov@gmail.com>
Signed-off-by: Boris Ranto <branto@redhat.com>
We should check if either asm symver or attribute symver is defined and
not assume that attribute symver implies asm symver.

Fixes: https://tracker.ceph.com/issues/40060
Signed-off-by: Boris Ranto <branto@redhat.com>
@b-ranto
Copy link
Contributor Author

b-ranto commented Aug 5, 2021

jenkins test make check

@tchaikov
Copy link
Contributor

tchaikov commented Aug 6, 2021

just for the record, __attribute__((__symver__ ...)) is not supported by any of the compilers we are using when building packages in our CI at this moment. none of the versions of used gcc is greater or equal to 10 so far.

-- Performing Test HAVE_ATTR_SYMVER
-- Performing Test HAVE_ATTR_SYMVER - Failed
-- Performing Test HAVE_ASM_SYMVER
-- Performing Test HAVE_ASM_SYMVER - Success

@tchaikov tchaikov merged commit 8b94e73 into ceph:master Aug 6, 2021
@b-ranto
Copy link
Contributor Author

b-ranto commented Aug 6, 2021

Yeah, this was a RHEL 9 ~requirement:

https://bugzilla.redhat.com/show_bug.cgi?id=1986190

@b-ranto b-ranto deleted the wip-lto branch August 6, 2021 06:36
@wjwithagen
Copy link
Contributor

@b-ranto @tchaikov

This fails on FreeBSD/Clang.
Got to figure out where that refence is declared and why it is not available.
Problem is that not all gnu-ld tricks are available in llvm-ld.

/usr/local/bin/ld: CMakeFiles/librados-config.dir/librados-config.cc.o: in function `main':
/home/jenkins/workspace/ceph-master-compile/src/librados-config.cc:46: undefined reference to `rados_version'
/usr/local/bin/ld: ../lib/librados.so.2.0.0: undefined reference to `rados_nobjects_list_next2'
/usr/local/bin/ld: ../lib/librados.so.2.0.0: undefined reference to `rados_conf_parse_argv_remainder'
/usr/local/bin/ld: ../lib/librados.so.2.0.0: undefined reference to `rados_aio_create_completion'
/usr/local/bin/ld: ../lib/librados.so.2.0.0: undefined reference to `rados_create_with_context'
/usr/local/bin/ld: ../lib/librados.so.2.0.0: undefined reference to `rados_create2'
/usr/local/bin/ld: ../lib/librados.so.2.0.0: undefined reference to `rados_aio_get_return_value'
/usr/local/bin/ld: ../lib/librados.so.2.0.0: undefined reference to `rados_conf_parse_env'
/usr/local/bin/ld: ../lib/librados.so.2.0.0: undefined reference to `rados_aio_create_completion2'
/usr/local/bin/ld: ../lib/librados.so.2.0.0: undefined reference to `rados_conf_set'
/usr/local/bin/ld: ../lib/librados.so.2.0.0: undefined reference to `rados_create'
/usr/local/bin/ld: ../lib/librados.so.2.0.0: undefined reference to `rados_ioctx_create2'
/usr/local/bin/ld: ../lib/librados.so.2.0.0: undefined reference to `rados_conf_parse_argv'
/usr/local/bin/ld: ../lib/librados.so.2.0.0: undefined reference to `rados_conf_read_file'
/usr/local/bin/ld: ../lib/librados.so.2.0.0: undefined reference to `rados_ioctx_create'
/usr/local/bin/ld: ../lib/librados.so.2.0.0: undefined reference to `rados_nobjects_list_seek_cursor'
/usr/local/bin/ld: ../lib/librados.so.2.0.0: undefined reference to `rados_nobjects_list_seek'
/usr/local/bin/ld: ../lib/librados.so.2.0.0: undefined reference to `rados_nobjects_list_open'
c++: error: linker command failed with exit code 1 (use -v to see invocation)

@b-ranto
Copy link
Contributor Author

b-ranto commented Aug 6, 2021

@wjwithagen Can you share the output of the ./do_cmake.sh step (or equivalent for FreeBSD)? I am mostly interested in the HAVE_ATTR_SYMVER check. Does (your version of) llvm support attribute symver? If it does not, will it at least produce a warning for an unknown attribute?

@wjwithagen
Copy link
Contributor

@b-ranto
I think it does not:

/home/jenkins/workspace/ceph-master-compile/src/librados/librados_c.cc:57:48: note: expanded from macro 'LIBRADOS_C_API_BASE_DEFAULT'
  extern __typeof (_##fn) _##fn __attribute__((__symver__ (#fn "@@")))
                                               ^~~~~~~~~~~~~~~~~~~~~
/home/jenkins/workspace/ceph-master-compile/src/librados/librados_c.cc:263:1: warning: unknown attribute '__symver__' ignored [-Wunknown-attributes]
LIBRADOS_C_API_BASE_DEFAULT(rados_get_min_compatible_client);

But the ./do_cmake thinks different:

-- Performing Test HAVE_ATTR_SYMVER
-- Performing Test HAVE_ATTR_SYMVER - Success
-- Performing Test HAVE_ASM_SYMVER
-- Performing Test HAVE_ASM_SYMVER - Success

So I conditionalised HAVE_ASM_SYMVER:

#if defined(HAVE_ATTR_SYMVER) && !defined(__FreeBSD__)

Which works....

@b-ranto
Copy link
Contributor Author

b-ranto commented Aug 6, 2021

Yeah, gcc also only warns on that, we pass -Werror=attribute to the compiler to make it an error. It looks like llvm has a different option for that. We could probably change the flag to simply -Werror. Does llvm support that? Can you check please? You can change that, here:

https://github.com/ceph/ceph/blob/master/cmake/modules/CephChecks.cmake#L151

@tchaikov
Copy link
Contributor

tchaikov commented Aug 6, 2021

for clang, it should be -Wunknown-attributes.

@tchaikov
Copy link
Contributor

tchaikov commented Aug 6, 2021

lemme create a patch.

@tchaikov
Copy link
Contributor

tchaikov commented Aug 6, 2021

#42698

@b-ranto @wjwithagen

@wjwithagen
Copy link
Contributor

-Werror does work
-Wunknown-attributes does not help. I guess that it does generate a warning, but the warning is not yet promoted to error.
So it would require -Werror -Wunknown-attributes
Which leads to using -Werror I suggest.

@tchaikov
Copy link
Contributor

tchaikov commented Aug 6, 2021

-Werror does work
-Wunknown-attributes does not help. I guess that it does generate a warning, but the warning is not yet promoted to error.
So it would require -Werror -Wunknown-attributes
Which leads to using -Werror I suggest.

@wjwithagen just wanted to explain the option name, not to propose a solution in my previous comment. if we really go with a single option like Boris put in his change, then it should be -Werror-unknown-attributes. but i'd trade a solution with two special cases for a simpler but probably obscure one .

@tchaikov tchaikov mentioned this pull request Aug 6, 2021
3 tasks
bazaah added a commit to bazaah/aur-ceph that referenced this pull request Oct 16, 2022
As per the upstream, ceph now supports the symbols required for LTO.

Upstream-Ref: ceph/ceph#42602
bazaah added a commit to bazaah/aur-ceph that referenced this pull request Oct 21, 2022
As per the upstream, ceph now supports the symbols required for LTO.

Upstream-Ref: ceph/ceph#42602
bazaah added a commit to bazaah/aur-ceph that referenced this pull request Oct 21, 2022
As per the upstream, ceph now supports the symbols required for LTO.

See the comment in the diff for more.

Upstream-Ref: ceph/ceph#42602
bazaah added a commit to bazaah/aur-ceph that referenced this pull request Oct 25, 2022
As per the upstream, ceph now supports the symbols required for LTO.

See the comment in the diff for more.

Upstream-Ref: ceph/ceph#42602
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants