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

Fix the visibility compilation error for GCC <= 7 #312

Merged

Conversation

BewareMyPower
Copy link
Contributor

@BewareMyPower BewareMyPower commented Sep 8, 2023

Motivation

Fixes #311

#296 introduced a regression for GCC <= 7.

lib/RetryableOperation.h:109:66: error: 'pulsar::RetryableOperation::runImpl(pulsar::TimeDuration)::<lambda(pulsar::Result, const T&)> [with T = pulsar::LookupService::LookupResult]::<lambda(const boost::system::error_code&)>' declared with greater visibility than the type of its field 'pulsar::RetryableOperation::runImpl(pulsar::TimeDuration)::<lambda(pulsar::Result, const T&)> [with T = pulsar::LookupService::LookupResult]::<lambda(const boost::system::error_code&)>::' [-Werror=attributes]

It seems to be a bug for GCC <= 7 abort the visibility of the lambda expression might not be affected by the -fvisibility=hidden option.

Modifications

Add __attribute__((visibility("hidden"))) to
RetryableOperation::runImpl explicitly.

Documentation

  • doc-required
    (Your PR needs to update docs and you will update later)

  • doc-not-needed
    (Please explain why)

  • doc
    (Your PR contains doc changes)

  • doc-complete
    (Docs have been already added)

### Motivation

apache#296 introduced a
regression for GCC <= 7.

> lib/RetryableOperation.h:109:66: error: 'pulsar::RetryableOperation<T>::runImpl(pulsar::TimeDuration)::<lambda(pulsar::Result, const T&)> [with T = pulsar::LookupService::LookupResult]::<lambda(const boost::system::error_code&)>' declared with greater visibility than the type of its field 'pulsar::RetryableOperation<T>::runImpl(pulsar::TimeDuration)::<lambda(pulsar::Result, const T&)> [with T = pulsar::LookupService::LookupResult]::<lambda(const boost::system::error_code&)>::<this capture>' [-Werror=attributes]

It seems to be a bug for GCC <= 7 abort the visibility of the lambda
expression might not be affected by the `-fvisibility=hidden` option.

### Modifications

Add `__attribute__((visibility("hidden")))` to
`RetryableOperation::runImpl` explicitly.
@BewareMyPower BewareMyPower added bug Something isn't working build labels Sep 8, 2023
@BewareMyPower BewareMyPower self-assigned this Sep 8, 2023
@BewareMyPower BewareMyPower merged commit 84ac6fb into apache:main Sep 9, 2023
7 of 11 checks passed
@BewareMyPower BewareMyPower deleted the bewaremypower/fix-gcc-7-build branch September 9, 2023 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working build
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] GCC 7 Compiler Warning
2 participants